src/debugger/debugger.h (view raw)
1#ifndef DEBUGGER_H
2#define DEBUGGER_H
3
4#include "common.h"
5
6#include "arm.h"
7
8enum DebuggerState {
9 DEBUGGER_PAUSED,
10 DEBUGGER_RUNNING,
11 DEBUGGER_EXITING,
12 DEBUGGER_SHUTDOWN
13};
14
15struct DebugBreakpoint {
16 struct DebugBreakpoint* next;
17 uint32_t address;
18};
19
20struct DebugMemoryShim {
21 struct ARMMemory d;
22 struct ARMMemory* original;
23
24 struct ARMDebugger* p;
25 struct DebugBreakpoint* watchpoints;
26};
27
28enum DebuggerEntryReason {
29 DEBUGGER_ENTER_MANUAL,
30 DEBUGGER_ENTER_ATTACHED,
31 DEBUGGER_ENTER_BREAKPOINT,
32 DEBUGGER_ENTER_WATCHPOINT,
33 DEBUGGER_ENTER_ILLEGAL_OP
34};
35
36enum DebuggerLogLevel {
37 DEBUGGER_LOG_DEBUG = 0x01,
38 DEBUGGER_LOG_INFO = 0x02,
39 DEBUGGER_LOG_WARN = 0x04,
40 DEBUGGER_LOG_ERROR = 0x08
41};
42
43struct ARMDebugger {
44 enum DebuggerState state;
45 struct ARMCore* cpu;
46
47 struct DebugBreakpoint* breakpoints;
48 struct DebugMemoryShim memoryShim;
49
50 void (*init)(struct ARMDebugger*);
51 void (*deinit)(struct ARMDebugger*);
52 void (*paused)(struct ARMDebugger*);
53 void (*entered)(struct ARMDebugger*, enum DebuggerEntryReason);
54
55 __attribute__((format (printf, 3, 4)))
56 void (*log)(struct ARMDebugger*, enum DebuggerLogLevel, const char* format, ...);
57};
58
59void ARMDebuggerInit(struct ARMDebugger*, struct ARMCore*);
60void ARMDebuggerDeinit(struct ARMDebugger*);
61void ARMDebuggerRun(struct ARMDebugger*);
62void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason);
63void ARMDebuggerSetBreakpoint(struct ARMDebugger* debugger, uint32_t address);
64void ARMDebuggerClearBreakpoint(struct ARMDebugger* debugger, uint32_t address);
65void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address);
66
67#endif