1 /* Abstract Machine for the Pawn compiler, debugger support
3 * This file contains extra definitions that are convenient for debugger
6 * Copyright (c) ITB CompuPhase, 2005-2006
8 * This software is provided "as-is", without any express or implied warranty.
9 * In no event will the authors be held liable for any damages arising from
10 * the use of this software.
12 * Permission is granted to anyone to use this software for any purpose,
13 * including commercial applications, and to alter it and redistribute it
14 * freely, subject to the following restrictions:
16 * 1. The origin of this software must not be misrepresented; you must not
17 * claim that you wrote the original software. If you use this software in
18 * a product, an acknowledgment in the product documentation would be
19 * appreciated but is not required.
20 * 2. Altered source versions must be plainly marked as such, and must not be
21 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source distribution.
27 #ifndef AMXDBG_H_INCLUDED
28 #define AMXDBG_H_INCLUDED
30 #ifndef AMX_H_INCLUDED
38 /* Some compilers do not support the #pragma align, which should be fine. Some
39 * compilers give a warning on unknown #pragmas, which is not so fine...
41 #if defined SN_TARGET_PS2 || defined __GNUC__
45 #if !defined AMX_NO_ALIGN
46 #if defined LINUX || defined __FreeBSD__
47 #pragma pack(1) /* structures must be packed (byte-aligned) */
48 #elif defined MACOS && defined __MWERKS__
49 #pragma options align=mac68k
52 #pragma pack(1) /* structures must be packed (byte-aligned) */
53 #if defined __TURBOC__
54 #pragma option -a- /* "pack" pragma for older Borland compilers */
59 typedef struct tagAMX_DBG_HDR {
60 int32_t size ; /* size of the debug information chunk */
61 uint16_t magic ; /* signature, must be 0xf1ef */
62 char file_version ; /* file format version */
63 char amx_version ; /* required version of the AMX */
64 int16_t flags ; /* currently unused */
65 int16_t files ; /* number of entries in the "file" table */
66 int16_t lines ; /* number of entries in the "line" table */
67 int16_t symbols ; /* number of entries in the "symbol" table */
68 int16_t tags ; /* number of entries in the "tag" table */
69 int16_t automatons ; /* number of entries in the "automaton" table */
70 int16_t states ; /* number of entries in the "state" table */
72 #define AMX_DBG_MAGIC 0xf1ef
74 typedef struct tagAMX_DBG_FILE {
75 ucell address ; /* address in the code segment where generated code (for this file) starts */
76 const char name[1] ; /* ASCII string, zero-terminated */
79 typedef struct tagAMX_DBG_LINE {
80 ucell address ; /* address in the code segment where generated code (for this line) starts */
81 int32_t line ; /* line number */
84 typedef struct tagAMX_DBG_SYMBOL {
85 ucell address ; /* address in the data segment or relative to the frame */
86 int16_t tag ; /* tag for the symbol */
87 ucell codestart ; /* address in the code segment from which this symbol is valid (in scope) */
88 ucell codeend ; /* address in the code segment until which this symbol is valid (in scope) */
89 char ident ; /* kind of symbol (function/variable) */
90 char vclass ; /* class of symbol (global/local) */
91 int16_t dim ; /* number of dimensions */
92 const char name[1] ; /* ASCII string, zero-terminated */
95 typedef struct tagAMX_DBG_SYMDIM {
96 int16_t tag ; /* tag for the array dimension */
97 ucell size ; /* size of the array dimension */
100 typedef struct tagAMX_DBG_TAG {
101 int16_t tag ; /* tag id */
102 const char name[1] ; /* ASCII string, zero-terminated */
105 typedef struct tagAMX_DBG_MACHINE {
106 int16_t automaton ; /* automaton id */
107 ucell address ; /* address of state variable */
108 const char name[1] ; /* ASCII string, zero-terminated */
111 typedef struct tagAMX_DBG_STATE {
112 int16_t state ; /* state id */
113 int16_t automaton ; /* automaton id */
114 const char name[1] ; /* ASCII string, zero-terminated */
117 typedef struct tagAMX_DBG {
118 AMX_DBG_HDR *hdr ; /* points to the AMX_DBG header */
119 AMX_DBG_FILE **filetbl ;
120 AMX_DBG_LINE *linetbl ;
121 AMX_DBG_SYMBOL **symboltbl ;
122 AMX_DBG_TAG **tagtbl ;
123 AMX_DBG_MACHINE **automatontbl ;
124 AMX_DBG_STATE **statetbl ;
127 #if !defined iVARIABLE
128 #define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */
129 #define iREFERENCE 2 /* iVARIABLE, but must be dereferenced */
131 #define iREFARRAY 4 /* an array passed by reference (i.e. a pointer) */
136 int AMXAPI dbg_FreeInfo(AMX_DBG *amxdbg);
137 int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, FILE *fp);
139 int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename);
140 int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcname);
141 int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, long *line);
143 int AMXAPI dbg_GetFunctionAddress(AMX_DBG *amxdbg, const char *funcname, const char *filename, ucell *address);
144 int AMXAPI dbg_GetLineAddress(AMX_DBG *amxdbg, long line, const char *filename, ucell *address);
145 int AMXAPI dbg_GetAutomatonName(AMX_DBG *amxdbg, int automaton, const char **name);
146 int AMXAPI dbg_GetStateName(AMX_DBG *amxdbg, int state, const char **name);
147 int AMXAPI dbg_GetTagName(AMX_DBG *amxdbg, int tag, const char **name);
148 int AMXAPI dbg_GetVariable(AMX_DBG *amxdbg, const char *symname, ucell scopeaddr, const AMX_DBG_SYMBOL **sym);
149 int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX_DBG_SYMDIM **symdim);
152 #if !defined AMX_NO_ALIGN
153 #if defined LINUX || defined __FreeBSD__
154 #pragma pack() /* reset default packing */
155 #elif defined MACOS && defined __MWERKS__
156 #pragma options align=reset
158 #pragma pack(pop) /* reset previous packing */
166 #endif /* AMXDBG_H_INCLUDED */