src/debugger/debugger.h (view raw)
1#ifndef DEBUGGER_H
2#define DEBUGGER_H
3
4#ifdef USE_DEBUGGER
5#include <histedit.h>
6
7#include "arm.h"
8#endif
9
10enum DebuggerState {
11 DEBUGGER_PAUSED,
12 DEBUGGER_RUNNING,
13 DEBUGGER_EXITING,
14 DEBUGGER_SHUTDOWN
15};
16
17#ifdef USE_DEBUGGER
18
19struct DebugBreakpoint {
20 struct DebugBreakpoint* next;
21 int32_t address;
22};
23
24struct DebugMemoryShim {
25 struct ARMMemory d;
26 struct ARMMemory* original;
27
28 struct ARMDebugger* p;
29 struct DebugBreakpoint* watchpoints;
30};
31
32enum DebuggerEntryReason {
33 DEBUGGER_ENTER_MANUAL,
34 DEBUGGER_ENTER_BREAKPOINT,
35 DEBUGGER_ENTER_WATCHPOINT,
36 DEBUGGER_ENTER_ILLEGAL_OP
37};
38
39struct ARMDebugger {
40 enum DebuggerState state;
41 struct ARMCore* cpu;
42
43 EditLine* elstate;
44 History* histate;
45
46 struct DebugBreakpoint* breakpoints;
47 struct DebugMemoryShim memoryShim;
48
49 void (*init)(struct ARMDebugger*, struct ARMCore*);
50 void (*deinit)(struct ARMDebugger*);
51 void (*paused)(struct ARMDebugger*);
52 void (*entered)(struct ARMDebugger*, enum DebuggerEntryReason);
53};
54
55void ARMDebuggerInit(struct ARMDebugger*, struct ARMCore*);
56void ARMDebuggerDeinit(struct ARMDebugger*);
57void ARMDebuggerRun(struct ARMDebugger*);
58void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason);
59
60#else
61
62struct ARMDebugger {
63 enum DebuggerState state;
64};
65
66#endif
67
68#endif