fixed debug section not being packed -- oops!

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40636
This commit is contained in:
David Anderson 2007-03-16 18:19:26 +00:00
parent d5ca9a3872
commit 632608b5bb
2 changed files with 176 additions and 166 deletions

View File

@ -55,6 +55,9 @@ all:
spcomp: $(OBJ_LINUX) spcomp: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -ldl -lm -o$(BIN_DIR)/$(BINARY) $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) all DEBUG=true
default: all default: all
clean: clean:

View File

@ -1,166 +1,173 @@
/* Abstract Machine for the Pawn compiler, debugger support /* Abstract Machine for the Pawn compiler, debugger support
* *
* This file contains extra definitions that are convenient for debugger * This file contains extra definitions that are convenient for debugger
* support. * support.
* *
* Copyright (c) ITB CompuPhase, 2005-2006 * Copyright (c) ITB CompuPhase, 2005
* *
* This software is provided "as-is", without any express or implied warranty. * This software is provided "as-is", without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from * In no event will the authors be held liable for any damages arising from
* the use of this software. * the use of this software.
* *
* Permission is granted to anyone to use this software for any purpose, * Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it * including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions: * freely, subject to the following restrictions:
* *
* 1. The origin of this software must not be misrepresented; you must not * 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in * claim that you wrote the original software. If you use this software in
* a product, an acknowledgment in the product documentation would be * a product, an acknowledgment in the product documentation would be
* appreciated but is not required. * appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be * 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software. * misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution. * 3. This notice may not be removed or altered from any source distribution.
* *
* Version: $Id$ * Version: $Id$
*/ */
#ifndef AMXDBG_H_INCLUDED #ifndef AMXDBG_H_INCLUDED
#define AMXDBG_H_INCLUDED #define AMXDBG_H_INCLUDED
#ifndef AMX_H_INCLUDED #ifndef AMX_H_INCLUDED
#include "amx.h" #include "amx.h"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Some compilers do not support the #pragma align, which should be fine. Some /* Some compilers do not support the #pragma align, which should be fine. Some
* compilers give a warning on unknown #pragmas, which is not so fine... * compilers give a warning on unknown #pragmas, which is not so fine...
*/ */
#if defined SN_TARGET_PS2 || defined __GNUC__ #if defined SN_TARGET_PS2 || defined __GNUC__
#define AMX_NO_ALIGN #define AMX_NO_ALIGN
#endif #endif
#if !defined AMX_NO_ALIGN #if defined __GNUC__
#if defined LINUX || defined __FreeBSD__ #define PACKED __attribute__((packed))
#pragma pack(1) /* structures must be packed (byte-aligned) */ #else
#elif defined MACOS && defined __MWERKS__ #define PACKED
#pragma options align=mac68k #endif
#else
#pragma pack(push) #if !defined AMX_NO_ALIGN
#pragma pack(1) /* structures must be packed (byte-aligned) */ #if defined LINUX || defined __FreeBSD__
#if defined __TURBOC__ #pragma pack(1) /* structures must be packed (byte-aligned) */
#pragma option -a- /* "pack" pragma for older Borland compilers */ #elif defined MACOS && defined __MWERKS__
#endif #pragma options align=mac68k
#endif #else
#endif #pragma pack(push)
#pragma pack(1) /* structures must be packed (byte-aligned) */
typedef struct tagAMX_DBG_HDR { #if defined __TURBOC__
int32_t size ; /* size of the debug information chunk */ #pragma option -a- /* "pack" pragma for older Borland compilers */
uint16_t magic ; /* signature, must be 0xf1ef */ #endif
char file_version ; /* file format version */ #endif
char amx_version ; /* required version of the AMX */ #endif
int16_t flags ; /* currently unused */
int16_t files ; /* number of entries in the "file" table */ typedef struct tagAMX_DBG_HDR {
int16_t lines ; /* number of entries in the "line" table */ int32_t size PACKED; /* size of the debug information chunk */
int16_t symbols ; /* number of entries in the "symbol" table */ uint16_t magic PACKED; /* signature, must be 0xf1ef */
int16_t tags ; /* number of entries in the "tag" table */ char file_version; /* file format version */
int16_t automatons ; /* number of entries in the "automaton" table */ char amx_version; /* required version of the AMX */
int16_t states ; /* number of entries in the "state" table */ int16_t flags PACKED; /* currently unused */
} AMX_DBG_HDR; int16_t files PACKED; /* number of entries in the "file" table */
#define AMX_DBG_MAGIC 0xf1ef int16_t lines PACKED; /* number of entries in the "line" table */
int16_t symbols PACKED; /* number of entries in the "symbol" table */
typedef struct tagAMX_DBG_FILE { int16_t tags PACKED; /* number of entries in the "tag" table */
ucell address ; /* address in the code segment where generated code (for this file) starts */ int16_t automatons PACKED; /* number of entries in the "automaton" table */
const char name[1] ; /* ASCII string, zero-terminated */ int16_t states PACKED; /* number of entries in the "state" table */
} AMX_DBG_FILE; } PACKED AMX_DBG_HDR;
#define AMX_DBG_MAGIC 0xf1ef
typedef struct tagAMX_DBG_LINE {
ucell address ; /* address in the code segment where generated code (for this line) starts */ typedef struct tagAMX_DBG_FILE {
int32_t line ; /* line number */ ucell address PACKED; /* address in the code segment where generated code (for this file) starts */
} AMX_DBG_LINE; const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_FILE;
typedef struct tagAMX_DBG_SYMBOL {
ucell address ; /* address in the data segment or relative to the frame */ typedef struct tagAMX_DBG_LINE {
int16_t tag ; /* tag for the symbol */ ucell address PACKED; /* address in the code segment where generated code (for this line) starts */
ucell codestart ; /* address in the code segment from which this symbol is valid (in scope) */ int32_t line PACKED; /* line number */
ucell codeend ; /* address in the code segment until which this symbol is valid (in scope) */ } PACKED AMX_DBG_LINE;
char ident ; /* kind of symbol (function/variable) */
char vclass ; /* class of symbol (global/local) */ typedef struct tagAMX_DBG_SYMBOL {
int16_t dim ; /* number of dimensions */ ucell address PACKED; /* address in the data segment or relative to the frame */
const char name[1] ; /* ASCII string, zero-terminated */ int16_t tag PACKED; /* tag for the symbol */
} AMX_DBG_SYMBOL; ucell codestart PACKED; /* address in the code segment from which this symbol is valid (in scope) */
ucell codeend PACKED; /* address in the code segment until which this symbol is valid (in scope) */
typedef struct tagAMX_DBG_SYMDIM { char ident; /* kind of symbol (function/variable) */
int16_t tag ; /* tag for the array dimension */ char vclass; /* class of symbol (global/local) */
ucell size ; /* size of the array dimension */ int16_t dim PACKED; /* number of dimensions */
} AMX_DBG_SYMDIM; const char name[1]; /* ASCII string, zero-terminated */
} PACKED AMX_DBG_SYMBOL;
typedef struct tagAMX_DBG_TAG {
int16_t tag ; /* tag id */ typedef struct tagAMX_DBG_SYMDIM {
const char name[1] ; /* ASCII string, zero-terminated */ int16_t tag PACKED; /* tag for the array dimension */
} AMX_DBG_TAG; ucell size PACKED; /* size of the array dimension */
} PACKED AMX_DBG_SYMDIM;
typedef struct tagAMX_DBG_MACHINE {
int16_t automaton ; /* automaton id */ typedef struct tagAMX_DBG_TAG {
ucell address ; /* address of state variable */ int16_t tag PACKED; /* tag id */
const char name[1] ; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_MACHINE; } PACKED AMX_DBG_TAG;
typedef struct tagAMX_DBG_STATE { typedef struct tagAMX_DBG_MACHINE {
int16_t state ; /* state id */ int16_t automaton PACKED; /* automaton id */
int16_t automaton ; /* automaton id */ ucell address PACKED; /* address of state variable */
const char name[1] ; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_STATE; } PACKED AMX_DBG_MACHINE;
typedef struct tagAMX_DBG { typedef struct tagAMX_DBG_STATE {
AMX_DBG_HDR *hdr ; /* points to the AMX_DBG header */ int16_t state PACKED; /* state id */
AMX_DBG_FILE **filetbl ; int16_t automaton PACKED; /* automaton id */
AMX_DBG_LINE *linetbl ; const char name[1]; /* ASCII string, zero-terminated */
AMX_DBG_SYMBOL **symboltbl ; } PACKED AMX_DBG_STATE;
AMX_DBG_TAG **tagtbl ;
AMX_DBG_MACHINE **automatontbl ; typedef struct tagAMX_DBG {
AMX_DBG_STATE **statetbl ; AMX_DBG_HDR _FAR *hdr PACKED; /* points to the AMX_DBG header */
} AMX_DBG; AMX_DBG_FILE _FAR **filetbl PACKED;
AMX_DBG_LINE _FAR *linetbl PACKED;
#if !defined iVARIABLE AMX_DBG_SYMBOL _FAR **symboltbl PACKED;
#define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */ AMX_DBG_TAG _FAR **tagtbl PACKED;
#define iREFERENCE 2 /* iVARIABLE, but must be dereferenced */ AMX_DBG_MACHINE _FAR **automatontbl PACKED;
#define iARRAY 3 AMX_DBG_STATE _FAR **statetbl PACKED;
#define iREFARRAY 4 /* an array passed by reference (i.e. a pointer) */ } PACKED AMX_DBG;
#define iFUNCTN 9
#endif #if !defined iVARIABLE
#define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */
#define iREFERENCE 2 /* iVARIABLE, but must be dereferenced */
int AMXAPI dbg_FreeInfo(AMX_DBG *amxdbg); #define iARRAY 3
int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, FILE *fp); #define iREFARRAY 4 /* an array passed by reference (i.e. a pointer) */
#define iFUNCTN 9
int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename); #endif
int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcname);
int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, long *line);
int AMXAPI dbg_FreeInfo(AMX_DBG *amxdbg);
int AMXAPI dbg_GetFunctionAddress(AMX_DBG *amxdbg, const char *funcname, const char *filename, ucell *address); int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, void *dbg_addr);
int AMXAPI dbg_GetLineAddress(AMX_DBG *amxdbg, long line, const char *filename, ucell *address);
int AMXAPI dbg_GetAutomatonName(AMX_DBG *amxdbg, int automaton, const char **name); int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename);
int AMXAPI dbg_GetStateName(AMX_DBG *amxdbg, int state, const char **name); int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcname);
int AMXAPI dbg_GetTagName(AMX_DBG *amxdbg, int tag, const char **name); int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, long *line);
int AMXAPI dbg_GetVariable(AMX_DBG *amxdbg, const char *symname, ucell scopeaddr, const AMX_DBG_SYMBOL **sym);
int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX_DBG_SYMDIM **symdim); int AMXAPI dbg_GetFunctionAddress(AMX_DBG *amxdbg, const char *funcname, const char *filename, ucell *address);
int AMXAPI dbg_GetLineAddress(AMX_DBG *amxdbg, long line, const char *filename, ucell *address);
int AMXAPI dbg_GetAutomatonName(AMX_DBG *amxdbg, int automaton, const char **name);
#if !defined AMX_NO_ALIGN int AMXAPI dbg_GetStateName(AMX_DBG *amxdbg, int state, const char **name);
#if defined LINUX || defined __FreeBSD__ int AMXAPI dbg_GetTagName(AMX_DBG *amxdbg, int tag, const char **name);
#pragma pack() /* reset default packing */ int AMXAPI dbg_GetVariable(AMX_DBG *amxdbg, const char *symname, ucell scopeaddr, const AMX_DBG_SYMBOL **sym);
#elif defined MACOS && defined __MWERKS__ int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX_DBG_SYMDIM **symdim);
#pragma options align=reset
#else
#pragma pack(pop) /* reset previous packing */ #if !defined AMX_NO_ALIGN
#endif #if defined LINUX || defined __FreeBSD__
#endif #pragma pack() /* reset default packing */
#elif defined MACOS && defined __MWERKS__
#ifdef __cplusplus #pragma options align=reset
} #else
#endif #pragma pack(pop) /* reset previous packing */
#endif
#endif /* AMXDBG_H_INCLUDED */ #endif
#ifdef __cplusplus
}
#endif
#endif /* AMXDBG_H_INCLUDED */