1 module m64p_debugger;
2 
3 import m64p_types;
4 
5 @nogc nothrow __gshared extern(C):
6 
7     /* DebugSetCallbacks()
8     *
9     * This function is called by the front-end to supply debugger callback
10     * function pointers. If debugger is enabled and then later disabled within the
11     * UI, this function may be called with NULL pointers in order to disable the
12     * callbacks. 
13     */
14     m64p_error function(void function(), void function(uint), void function()) DebugSetCallbacks;
15 
16     /* DebugSetCoreCompare()
17     *
18     * This function is called by the front-end to supply callback function pointers
19     * for the Core Comparison feature.
20     */
21     m64p_error function(void function(uint), void function(int, void*)) DebugSetCoreCompare;
22 
23     /* DebugSetRunState()
24     *
25     * This function sets the run state of the R4300 CPU emulator.
26     */
27     m64p_error function(m64p_dbg_runstate) DebugSetRunState;
28 
29     /* DebugGetState()
30     *
31     * This function reads and returns a debugger state variable, which are
32     * enumerated in m64p_types.h. 
33     */
34     int function(m64p_dbg_state) DebugGetState;
35 
36     /* DebugStep()
37     *
38     * This function signals the debugger to advance one instruction when in the
39     * stepping mode.
40     */
41     m64p_error function() DebugStep;
42 
43     /* DebugDecodeOp()
44     *
45     * This is a helper function for the debugger front-end. This instruction takes
46     * a PC value and an R4300 instruction opcode and writes the disassembled
47     * instruction mnemonic and arguments into character buffers. This is intended
48     * to be used to display disassembled code. 
49     */
50     void function(uint, char*, char*, int) DebugDecodeOp;
51 
52     /* DebugMemGetRecompInfo()
53     *
54     * This function is used by the front-end to retrieve disassembly information
55     * about recompiled code. For example, the dynamic recompiler may take a single
56     * R4300 instruction and compile it into 10 x86 instructions. This function may
57     * then be used to retrieve the disassembled code of the 10 x86 instructions.
58     */
59     void* function(m64p_dbg_mem_info, uint, int) DebugMemGetRecompInfo;
60 
61     /* DebugMemGetMemInfo()
62     *
63     * This function returns an integer value regarding the memory location address,
64     * corresponding to the information requested by mem_info_type, which is a type
65     * enumerated in m64p_types.h.
66     */
67     int function(m64p_dbg_mem_info, uint) DebugMemGetMemInfo;
68 
69     /* DebugMemGetPointer()
70     *
71     * This function returns a memory pointer (in x86 memory space) to a block of
72     * emulated N64 memory. This may be used to retrieve a pointer to a special N64
73     * block (such as the serial, video, or audio registers) or the RDRAM.
74     */
75     void* function(m64p_dbg_mem_type) DebugMemGetPointer;
76 
77     /* DebugMemRead**()
78     *
79     * These functions retrieve a value from the emulated N64 memory. The returned
80     * value will be correctly byte-swapped for the host architecture. 
81     */
82     ulong function(uint) DebugMemRead64;
83     uint function(uint) DebugMemRead32;
84     ushort function(uint) DebugMemRead16;
85     ubyte function(uint) DebugMemRead8;
86 
87     /* DebugMemWrite**()
88     *
89     * These functions write a value into the emulated N64 memory. The given value
90     * will be correctly byte-swapped before storage. 
91     */
92     void function(uint, ulong) DebugMemWrite64;
93     void function(uint, uint) DebugMemWrite32;
94     void function(uint, ushort) DebugMemWrite16;
95     void function(uint, ubyte) DebugMemWrite8;
96 
97     /* DebugGetCPUDataPtr()
98     *
99     * This function returns a memory pointer (in x86 memory space) to a specific
100     * register in the emulated R4300 CPU.
101     */
102     void* function(m64p_dbg_cpu_data) DebugGetCPUDataPtr;
103 
104     /* DebugBreakpointLookup()
105     *
106     * This function searches through all current breakpoints in the debugger to
107     * find one that matches the given input parameters. If a matching breakpoint
108     * is found, the index number is returned. If no breakpoints are found, -1 is
109     * returned. 
110     */
111     int function(uint, uint, uint) DebugBreakpointLookup;
112 
113     /* DebugBreakpointCommand()
114     *
115     * This function is used to process common breakpoint commands, such as adding,
116     * removing, or searching the breakpoints. The meanings of the index and ptr
117     * input parameters vary by command.
118     */
119     int function(m64p_dbg_bkp_command, uint, m64p_breakpoint*) DebugBreakpointCommand;
120 
121     /* DebugBreakpointTriggeredBy()
122     *
123     * This function is used to retrieve the trigger flags and address for the
124     * most recently triggered breakpoint.
125     */
126     void function(uint*, uint*) DebugBreakpointTriggeredBy;
127 
128     /* DebugVirtualToPhysical()
129     *
130     * This function is used to translate virtual addresses to physical addresses.
131     * Memory read/write breakpoints operate on physical addresses.
132     */
133     uint function(uint) DebugVirtualToPhysical;