all repos — mgba @ da612b51e8ebb61e9e7588dbe48b76a815595c4f

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