all repos — mgba @ f6a7fedb2813d070a07cd6da65e8ddd666cd41d1

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_EXITING,
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
56	__attribute__((format (printf, 3, 4)))
57	void (*log)(struct ARMDebugger*, enum DebuggerLogLevel, const char* format, ...);
58};
59
60void ARMDebuggerCreate(struct ARMDebugger*);
61void ARMDebuggerRun(struct ARMDebugger*);
62void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason);
63void ARMDebuggerSetBreakpoint(struct ARMDebugger* debugger, uint32_t address);
64void ARMDebuggerClearBreakpoint(struct ARMDebugger* debugger, uint32_t address);
65void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address);
66void ARMDebuggerClearWatchpoint(struct ARMDebugger* debugger, uint32_t address);
67
68#endif