summaryrefslogtreecommitdiffhomepage
path: root/dev/LibDebugger/NeKernelContract.h
blob: 78140e7b30ff9cbc29c9af7410b98608d9f0544d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

/***
  (C) 2025 Amlal El Mahrouss
 */

#ifndef LD_NEKERNEL_CONTRACT_H
#define LD_NEKERNEL_CONTRACT_H

#ifdef LD_NEKERNEL_DEBUGGER

#include <LibDebugger/DebuggerContract.h>

#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>

#define kDebugUnboundPort 0x0FEED

#define kDebugMag0 'K'
#define kDebugMag1 'D'
#define kDebugMag2 'B'
#define kDebugMag3 'G'

#define kDebugSourceFile 23
#define kDebugLine 33
#define kDebugTeam 43
#define kDebugEOP 49

namespace LibDebugger::NeKernel {
class NeKernelContract;

namespace Detail {
  class NeKernelDebugHeader;

  inline constexpr size_t kDebugTypeLen = 256U;

  typedef char rt_debug_type[kDebugTypeLen];

  class NeKernelDebugHeader final {
   public:
    int16_t       fPort;
    int16_t       fPortKind;
    rt_debug_type fPortBlob;
  };
}  // namespace Detail

class NeKernelContract : public DebuggerContract {
 public:
  NeKernelContract();
  ~NeKernelContract() override;

 public:
  NeKernelContract& operator=(const NeKernelContract&) = default;
  NeKernelContract(const NeKernelContract&)            = default;

  // Override additional methods from DebuggerContract
  bool Attach(std::string path, std::string argv, ProcessID& pid) noexcept override;
  bool Breakpoint(std::string symbol) noexcept override;
  bool Break() noexcept override;
  bool Continue() noexcept override;
  bool Detach() noexcept override;

 private:
  std::string m_ip_address;
  std::string m_port;
  int64_t     m_socket{0};
};
}  // namespace LibDebugger::NeKernel

#endif  // ifdef LD_NEKERNEL_DEBUGGER

#endif  // LD_NEKERNEL_CONTRACT_H