all repos — mgba @ 6560db2ef58e1a192a2356fd8ae1de65379b838c

mGBA Game Boy Advance Emulator

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
 8extern const uint32_t ARM_DEBUGGER_ID;
 9
10enum DebuggerState {
11	DEBUGGER_PAUSED,
12	DEBUGGER_RUNNING,
13	DEBUGGER_EXITING,
14	DEBUGGER_SHUTDOWN
15};
16
17struct DebugBreakpoint {
18	struct DebugBreakpoint* next;
19	uint32_t address;
20};
21
22enum DebuggerEntryReason {
23	DEBUGGER_ENTER_MANUAL,
24	DEBUGGER_ENTER_ATTACHED,
25	DEBUGGER_ENTER_BREAKPOINT,
26	DEBUGGER_ENTER_WATCHPOINT,
27	DEBUGGER_ENTER_ILLEGAL_OP
28};
29
30enum DebuggerLogLevel {
31	DEBUGGER_LOG_DEBUG = 0x01,
32	DEBUGGER_LOG_INFO = 0x02,
33	DEBUGGER_LOG_WARN = 0x04,
34	DEBUGGER_LOG_ERROR = 0x08
35};
36
37struct ARMDebugger {
38	struct ARMComponent d;
39	enum DebuggerState state;
40	struct ARMCore* cpu;
41
42	struct DebugBreakpoint* breakpoints;
43	struct DebugBreakpoint* watchpoints;
44	struct ARMMemory originalMemory;
45
46	void (*init)(struct ARMDebugger*);
47	void (*deinit)(struct ARMDebugger*);
48	void (*paused)(struct ARMDebugger*);
49	void (*entered)(struct ARMDebugger*, enum DebuggerEntryReason);
50
51	__attribute__((format (printf, 3, 4)))
52	void (*log)(struct ARMDebugger*, enum DebuggerLogLevel, const char* format, ...);
53};
54
55void ARMDebuggerCreate(struct ARMDebugger*);
56void ARMDebuggerRun(struct ARMDebugger*);
57void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason);
58void ARMDebuggerSetBreakpoint(struct ARMDebugger* debugger, uint32_t address);
59void ARMDebuggerClearBreakpoint(struct ARMDebugger* debugger, uint32_t address);
60void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address);
61void ARMDebuggerClearWatchpoint(struct ARMDebugger* debugger, uint32_t address);
62
63#endif