1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus-core - m64p_debugger.h *
3 * Mupen64Plus homepage: https://mupen64plus.org/ *
4 * Copyright (C) 2009 Richard Goedeken *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21
22/* This header file defines typedefs for function pointers to Core Debugger
23 * functions.
24 */
25
26#if !defined(M64P_DEBUGGER_H)
27#define M64P_DEBUGGER_H
28
29#include "m64p_types.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/* DebugSetCallbacks()
36 *
37 * This function is called by the front-end to supply debugger callback
38 * function pointers. If debugger is enabled and then later disabled within the
39 * UI, this function may be called with NULL pointers in order to disable the
40 * callbacks.
41 */
42typedef m64p_error (*ptr_DebugSetCallbacks)(void (*)(void), void (*)(unsigned int), void (*)(void));
43#if defined(M64P_CORE_PROTOTYPES)
44EXPORT m64p_error CALL DebugSetCallbacks(void (*)(void), void (*)(unsigned int), void (*)(void));
45#endif
46
47/* DebugSetCoreCompare()
48 *
49 * This function is called by the front-end to supply callback function pointers
50 * for the Core Comparison feature.
51 */
52typedef m64p_error (*ptr_DebugSetCoreCompare)(void (*)(unsigned int), void (*)(int, void *));
53#if defined(M64P_CORE_PROTOTYPES)
54EXPORT m64p_error CALL DebugSetCoreCompare(void (*)(unsigned int), void (*)(int, void *));
55#endif
56
57/* DebugSetRunState()
58 *
59 * This function sets the run state of the R4300 CPU emulator.
60 */
61typedef m64p_error (*ptr_DebugSetRunState)(m64p_dbg_runstate);
62#if defined(M64P_CORE_PROTOTYPES)
63EXPORT m64p_error CALL DebugSetRunState(m64p_dbg_runstate);
64#endif
65
66/* DebugGetState()
67 *
68 * This function reads and returns a debugger state variable, which are
69 * enumerated in m64p_types.h.
70 */
71typedef int (*ptr_DebugGetState)(m64p_dbg_state);
72#if defined(M64P_CORE_PROTOTYPES)
73EXPORT int CALL DebugGetState(m64p_dbg_state);
74#endif
75
76/* DebugStep()
77 *
78 * This function signals the debugger to advance one instruction when in the
79 * stepping mode.
80 */
81typedef m64p_error (*ptr_DebugStep)(void);
82#if defined(M64P_CORE_PROTOTYPES)
83EXPORT m64p_error CALL DebugStep(void);
84#endif
85
86/* DebugDecodeOp()
87 *
88 * This is a helper function for the debugger front-end. This instruction takes
89 * a PC value and an R4300 instruction opcode and writes the disassembled
90 * instruction mnemonic and arguments into character buffers. This is intended
91 * to be used to display disassembled code.
92 */
93typedef void (*ptr_DebugDecodeOp)(unsigned int, char *, char *, int);
94#if defined(M64P_CORE_PROTOTYPES)
95EXPORT void CALL DebugDecodeOp(unsigned int, char *, char *, int);
96#endif
97
98/* DebugMemGetRecompInfo()
99 *
100 * This function is used by the front-end to retrieve disassembly information
101 * about recompiled code. For example, the dynamic recompiler may take a single
102 * R4300 instruction and compile it into 10 x86 instructions. This function may
103 * then be used to retrieve the disassembled code of the 10 x86 instructions.
104 */
105typedef void * (*ptr_DebugMemGetRecompInfo)(m64p_dbg_mem_info, unsigned int, int);
106#if defined(M64P_CORE_PROTOTYPES)
107EXPORT void * CALL DebugMemGetRecompInfo(m64p_dbg_mem_info, unsigned int, int);
108#endif
109
110/* DebugMemGetMemInfo()
111 *
112 * This function returns an integer value regarding the memory location address,
113 * corresponding to the information requested by mem_info_type, which is a type
114 * enumerated in m64p_types.h.
115 */
116typedef int (*ptr_DebugMemGetMemInfo)(m64p_dbg_mem_info, unsigned int);
117#if defined(M64P_CORE_PROTOTYPES)
118EXPORT int CALL DebugMemGetMemInfo(m64p_dbg_mem_info, unsigned int);
119#endif
120
121/* DebugMemGetPointer()
122 *
123 * This function returns a memory pointer (in x86 memory space) to a block of
124 * emulated N64 memory. This may be used to retrieve a pointer to a special N64
125 * block (such as the serial, video, or audio registers) or the RDRAM.
126 */
127typedef void * (*ptr_DebugMemGetPointer)(m64p_dbg_memptr_type);
128#if defined(M64P_CORE_PROTOTYPES)
129EXPORT void * CALL DebugMemGetPointer(m64p_dbg_memptr_type);
130#endif
131
132/* DebugMemRead**()
133 *
134 * These functions retrieve a value from the emulated N64 memory. The returned
135 * value will be correctly byte-swapped for the host architecture.
136 */
137typedef unsigned long long (*ptr_DebugMemRead64)(unsigned int);
138typedef unsigned int (*ptr_DebugMemRead32)(unsigned int);
139typedef unsigned short (*ptr_DebugMemRead16)(unsigned int);
140typedef unsigned char (*ptr_DebugMemRead8)(unsigned int);
141#if defined(M64P_CORE_PROTOTYPES)
142EXPORT unsigned long long CALL DebugMemRead64(unsigned int);
143EXPORT unsigned int CALL DebugMemRead32(unsigned int);
144EXPORT unsigned short CALL DebugMemRead16(unsigned int);
145EXPORT unsigned char CALL DebugMemRead8(unsigned int);
146#endif
147
148/* DebugMemWrite**()
149 *
150 * These functions write a value into the emulated N64 memory. The given value
151 * will be correctly byte-swapped before storage.
152 */
153typedef void (*ptr_DebugMemWrite64)(unsigned int, unsigned long long);
154typedef void (*ptr_DebugMemWrite32)(unsigned int, unsigned int);
155typedef void (*ptr_DebugMemWrite16)(unsigned int, unsigned short);
156typedef void (*ptr_DebugMemWrite8)(unsigned int, unsigned char);
157#if defined(M64P_CORE_PROTOTYPES)
158EXPORT void CALL DebugMemWrite64(unsigned int, unsigned long long);
159EXPORT void CALL DebugMemWrite32(unsigned int, unsigned int);
160EXPORT void CALL DebugMemWrite16(unsigned int, unsigned short);
161EXPORT void CALL DebugMemWrite8(unsigned int, unsigned char);
162#endif
163
164/* DebugGetCPUDataPtr()
165 *
166 * This function returns a memory pointer (in x86 memory space) to a specific
167 * register in the emulated R4300 CPU.
168 */
169typedef void * (*ptr_DebugGetCPUDataPtr)(m64p_dbg_cpu_data);
170#if defined(M64P_CORE_PROTOTYPES)
171EXPORT void * CALL DebugGetCPUDataPtr(m64p_dbg_cpu_data);
172#endif
173
174/* DebugBreakpointLookup()
175 *
176 * This function searches through all current breakpoints in the debugger to
177 * find one that matches the given input parameters. If a matching breakpoint
178 * is found, the index number is returned. If no breakpoints are found, -1 is
179 * returned.
180 */
181typedef int (*ptr_DebugBreakpointLookup)(unsigned int, unsigned int, unsigned int);
182#if defined(M64P_CORE_PROTOTYPES)
183EXPORT int CALL DebugBreakpointLookup(unsigned int, unsigned int, unsigned int);
184#endif
185
186/* DebugBreakpointCommand()
187 *
188 * This function is used to process common breakpoint commands, such as adding,
189 * removing, or searching the breakpoints. The meanings of the index and ptr
190 * input parameters vary by command.
191 */
192typedef int (*ptr_DebugBreakpointCommand)(m64p_dbg_bkp_command, unsigned int, m64p_breakpoint *);
193#if defined(M64P_CORE_PROTOTYPES)
194EXPORT int CALL DebugBreakpointCommand(m64p_dbg_bkp_command, unsigned int, m64p_breakpoint *);
195#endif
196
197/* DebugBreakpointTriggeredBy()
198 *
199 * This function is used to retrieve the trigger flags and address for the
200 * most recently triggered breakpoint.
201 */
202typedef void (*ptr_DebugBreakpointTriggeredBy)(uint32_t *, uint32_t *);
203#if defined(M64P_CORE_PROTOTYPES)
204EXPORT void CALL DebugBreakpointTriggeredBy(uint32_t *, uint32_t *);
205#endif
206
207/* DebugVirtualToPhysical()
208 *
209 * This function is used to translate virtual addresses to physical addresses.
210 * Memory read/write breakpoints operate on physical addresses.
211 */
212typedef uint32_t (*ptr_DebugVirtualToPhysical)(uint32_t);
213#if defined(M64P_CORE_PROTOTYPES)
214EXPORT uint32_t CALL DebugVirtualToPhysical(uint32_t);
215#endif
216
217#ifdef __cplusplus
218}
219#endif
220
221#endif /* #define M64P_DEBUGGER_H */
222
223