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 ARM_DEBUGGER_H
7 #define ARM_DEBUGGER_H
8 
9 #include <mgba-util/common.h>
10 
11 CXX_GUARD_START
12 
13 #include <mgba/debugger/debugger.h>
14 
15 #include <mgba/internal/arm/arm.h>
16 #include <mgba-util/vector.h>
17 
18 struct ParseTree;
19 struct ARMDebugBreakpoint {
20 	struct mBreakpoint d;
21 	struct {
22 		uint32_t opcode;
23 		enum ExecutionMode mode;
24 	} sw;
25 };
26 
27 DECLARE_VECTOR(ARMDebugBreakpointList, struct ARMDebugBreakpoint);
28 
29 struct ARMDebugger {
30 	struct mDebuggerPlatform d;
31 	struct ARMCore* cpu;
32 
33 	struct ARMDebugBreakpointList breakpoints;
34 	struct ARMDebugBreakpointList swBreakpoints;
35 	struct mWatchpointList watchpoints;
36 	struct ARMMemory originalMemory;
37 
38 	ssize_t nextId;
39 
40 	void (*entered)(struct mDebugger*, enum mDebuggerEntryReason, struct mDebuggerEntryInfo*);
41 
42 	ssize_t (*setSoftwareBreakpoint)(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);
43 	void (*clearSoftwareBreakpoint)(struct ARMDebugger*, const struct ARMDebugBreakpoint*);
44 };
45 
46 struct mDebuggerPlatform* ARMDebuggerPlatformCreate(void);
47 ssize_t ARMDebuggerSetSoftwareBreakpoint(struct mDebuggerPlatform* debugger, uint32_t address, enum ExecutionMode mode);
48 
49 CXX_GUARD_END
50 
51 #endif
52