summaryrefslogtreecommitdiffhomepage
path: root/src/DebuggerKit/DebuggerContract.h
blob: 424bd807f431cee506577c3a76355f602f37e16b (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
/* ========================================

  Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.

======================================== */

#pragma once

#include <DebuggerKit/Config.h>
#include <unordered_map>

#define DK_DEBUGGER_CONTRACT : public ::DebuggerKit::DebuggerContract

namespace DebuggerKit {
class DebuggerContract;

/// =========================================================== ///
/// \brief Process ID
/// =========================================================== ///
typedef uint64_t ProcessID;

/// =========================================================== ///
/// \brief Address type, a la BSD.
/// =========================================================== ///
typedef char* CAddress;

/// =========================================================== ///
/// \brief Debugger contract class in C++, as per the design states.
/// \author Amlal El Mahrouss
/// =========================================================== ///
class DebuggerContract {
 public:
  explicit DebuggerContract() = default;
  virtual ~DebuggerContract() = default;

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

 public:
  virtual bool Attach(std::string path, std::string argv, ProcessID& pid) noexcept = 0;
  virtual bool BreakAt(std::string symbol) noexcept                                = 0;
  virtual bool Break() noexcept                                                    = 0;
  virtual bool Continue() noexcept                                                 = 0;
  virtual bool Detach() noexcept                                                   = 0;

  virtual std::unordered_map<uintptr_t, uintptr_t>& Get() { return m_breakpoints; }

 protected:
  ProcessID                                m_pid{(ProcessID) ~0};
  std::unordered_map<uintptr_t, uintptr_t> m_breakpoints;
};
}  // namespace DebuggerKit