all repos — mgba @ f4fcdf35d4d88616a3bda9bce7384df0e83a6964

mGBA Game Boy Advance Emulator

src/debugger/debugger.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef DEBUGGER_H
 7#define DEBUGGER_H
 8
 9#include "util/common.h"
10
11#include "arm.h"
12
13extern const uint32_t ARM_DEBUGGER_ID;
14
15enum DebuggerState {
16	DEBUGGER_PAUSED,
17	DEBUGGER_RUNNING,
18	DEBUGGER_CUSTOM,
19	DEBUGGER_SHUTDOWN
20};
21
22struct DebugBreakpoint {
23	struct DebugBreakpoint* next;
24	uint32_t address;
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 DebugBreakpoint* watchpoints;
49	struct ARMMemory originalMemory;
50
51	void (*init)(struct ARMDebugger*);
52	void (*deinit)(struct ARMDebugger*);
53	void (*paused)(struct ARMDebugger*);
54	void (*entered)(struct ARMDebugger*, enum DebuggerEntryReason);
55	void (*custom)(struct ARMDebugger*);
56
57	__attribute__((format (printf, 3, 4)))
58	void (*log)(struct ARMDebugger*, enum DebuggerLogLevel, const char* format, ...);
59};
60
61void ARMDebuggerCreate(struct ARMDebugger*);
62void ARMDebuggerRun(struct ARMDebugger*);
63void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason);
64void ARMDebuggerSetBreakpoint(struct ARMDebugger* debugger, uint32_t address);
65void ARMDebuggerClearBreakpoint(struct ARMDebugger* debugger, uint32_t address);
66void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address);
67void ARMDebuggerClearWatchpoint(struct ARMDebugger* debugger, uint32_t address);
68
69#endif