all repos — mgba @ c5d243fca282cf11d7f2c38010fce18361babdc2

mGBA Game Boy Advance Emulator

src/debugger/debugger.h (view raw)

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