]> git.sur5r.net Git - cc65/blob - include/dbg.h
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / include / dbg.h
1 /*
2  * dbg.h
3  *
4  * Ullrich von Bassewitz, 08.08.1998
5  *
6  *
7  * This is the interface to the cc65 debugger. Since many of the functions
8  * used for the debugger are quite usable even in another context, they
9  * are declared here.
10  *
11  * To use the debugger, just call DbgStart in your application. This will
12  * clear the screen and startup the debugger with the program counter
13  * pointing to the next instruction after the call to DbgStart. Once DbgStart
14  * has been executed, the debugger will also catch any BRK opcode. Use the
15  * BREAK function declared below to insert additional breakpoints into your
16  * code.
17  *
18  * There are currently a lot of things that cannot be debugged, graphical
19  * applications are an example. The debugger does not save your screen
20  * contents, so even your text screen gets destroyed. However, you can
21  * debug the C and runtime library, even if the debugger is using this
22  * stuff itself.
23  *
24  * Note: When using the debugger, there are some other identifiers with
25  * external linkage, that start with Dbg. Avoid those names if you use the
26  * module.
27  */
28
29
30
31 #ifndef _DBG_H
32 #define _DBG_H
33
34
35
36 /*****************************************************************************/
37 /*                            Utuility functions                             */
38 /*****************************************************************************/
39
40
41
42 unsigned __fastcall__ DbgDisAsm (unsigned Addr, char* Buf, unsigned char Len);
43 /* Disassemble one instruction at address addr into the given buffer.
44  * The resulting line has the format, "AAAA__BB_BB_BB___OPC_OPERAND",
45  * where AAAA is the hexadecimal representation of addr, BB are the
46  * bytes (in hex) that make the instruction, OPC is the mnemonic, and
47  * OPERAND is an operand for the instruction.
48  * The buffer is filled with spaces up to the given length and terminated as
49  * a usual C string. NOTE: Buf must be able to hold Len+1 characters.
50  * The function returns the length of the disassembled instruction, so,
51  * to disassemble the next instruction, add the return value to addr
52  * and call the function again.
53  */
54
55 unsigned __fastcall__ DbgDisAsmLen (unsigned Addr);
56 /* Disassemble one instruction, but do only return the length, do not
57  * create a visible representation. This function is useful when
58  * disassembling backwards, it is much faster than DbgDisAsm.
59  */
60
61 int __fastcall__ DbgIsRAM (unsigned Addr);
62 /* Return true if we can read and write the given address */
63
64 char* DbgMemDump (unsigned Addr, char* Buf, unsigned char Len);
65 /* Create a line of a memory dump in the given buffer. The buffer contains
66  * the starting address (4 digits hex), then Len bytes in this format:
67  * "AAAA__XX_YY_ZZ_...". The passed char buffer must hold Len*3+5 bytes
68  * plus a terminator byte.
69  * The function does not work correctly if the created string is longer
70  * than 255 bytes.
71  * The return value is Buf.
72  */
73
74
75
76 /*****************************************************************************/
77 /*                         High level user interface                         */
78 /*****************************************************************************/
79
80
81
82 void __fastcall__ DbgInit (unsigned unused);
83 /* Initialize the debugger. Use 0 as parameter. The debugger will popup on
84  * next brk encountered.
85  */
86
87 #define BREAK()         __asm__ ("\tbrk")
88 /* Use this to insert breakpoints into your code */
89
90
91
92 /* End of dbg.h */
93 #endif
94
95
96