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 original;
22
23 struct ARMDebugger* p;
24 struct DebugBreakpoint* watchpoints;
25};
26
27enum DebuggerEntryReason {
28 DEBUGGER_ENTER_MANUAL,
29 DEBUGGER_ENTER_ATTACHED,
30 DEBUGGER_ENTER_BREAKPOINT,
31 DEBUGGER_ENTER_WATCHPOINT,
32 DEBUGGER_ENTER_ILLEGAL_OP
33};
34
35enum DebuggerLogLevel {
36 DEBUGGER_LOG_DEBUG = 0x01,
37 DEBUGGER_LOG_INFO = 0x02,
38 DEBUGGER_LOG_WARN = 0x04,
39 DEBUGGER_LOG_ERROR = 0x08
40};
41
42struct ARMDebugger {
43 struct ARMComponent d;
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 ARMDebuggerCreate(struct ARMDebugger*);
60void ARMDebuggerRun(struct ARMDebugger*);
61void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason);
62void ARMDebuggerSetBreakpoint(struct ARMDebugger* debugger, uint32_t address);
63void ARMDebuggerClearBreakpoint(struct ARMDebugger* debugger, uint32_t address);
64void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address);
65
66#endif