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)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) all DEBUG=true
default: all
clean:

View File

@ -3,7 +3,7 @@
* This file contains extra definitions that are convenient for debugger
* support.
*
* Copyright (c) ITB CompuPhase, 2005-2006
* Copyright (c) ITB CompuPhase, 2005
*
* 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
@ -42,6 +42,12 @@ extern "C" {
#define AMX_NO_ALIGN
#endif
#if defined __GNUC__
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#pragma pack(1) /* structures must be packed (byte-aligned) */
@ -57,72 +63,72 @@ extern "C" {
#endif
typedef struct tagAMX_DBG_HDR {
int32_t size ; /* size of the debug information chunk */
uint16_t magic ; /* signature, must be 0xf1ef */
int32_t size PACKED; /* size of the debug information chunk */
uint16_t magic PACKED; /* signature, must be 0xf1ef */
char file_version; /* file format version */
char amx_version; /* required version of the AMX */
int16_t flags ; /* currently unused */
int16_t files ; /* number of entries in the "file" table */
int16_t lines ; /* number of entries in the "line" table */
int16_t symbols ; /* number of entries in the "symbol" table */
int16_t tags ; /* number of entries in the "tag" table */
int16_t automatons ; /* number of entries in the "automaton" table */
int16_t states ; /* number of entries in the "state" table */
} AMX_DBG_HDR;
int16_t flags PACKED; /* currently unused */
int16_t files PACKED; /* number of entries in the "file" table */
int16_t lines PACKED; /* number of entries in the "line" table */
int16_t symbols PACKED; /* number of entries in the "symbol" table */
int16_t tags PACKED; /* number of entries in the "tag" table */
int16_t automatons PACKED; /* number of entries in the "automaton" table */
int16_t states PACKED; /* number of entries in the "state" table */
} PACKED AMX_DBG_HDR;
#define AMX_DBG_MAGIC 0xf1ef
typedef struct tagAMX_DBG_FILE {
ucell address ; /* address in the code segment where generated code (for this file) starts */
ucell address PACKED; /* address in the code segment where generated code (for this file) starts */
const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_FILE;
} PACKED AMX_DBG_FILE;
typedef struct tagAMX_DBG_LINE {
ucell address ; /* address in the code segment where generated code (for this line) starts */
int32_t line ; /* line number */
} AMX_DBG_LINE;
ucell address PACKED; /* address in the code segment where generated code (for this line) starts */
int32_t line PACKED; /* line number */
} PACKED AMX_DBG_LINE;
typedef struct tagAMX_DBG_SYMBOL {
ucell address ; /* address in the data segment or relative to the frame */
int16_t tag ; /* tag for the symbol */
ucell codestart ; /* address in the code segment from which this symbol is valid (in scope) */
ucell codeend ; /* address in the code segment until which this symbol is valid (in scope) */
ucell address PACKED; /* address in the data segment or relative to the frame */
int16_t tag PACKED; /* tag for the 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) */
char ident; /* kind of symbol (function/variable) */
char vclass; /* class of symbol (global/local) */
int16_t dim ; /* number of dimensions */
int16_t dim PACKED; /* number of dimensions */
const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_SYMBOL;
} PACKED AMX_DBG_SYMBOL;
typedef struct tagAMX_DBG_SYMDIM {
int16_t tag ; /* tag for the array dimension */
ucell size ; /* size of the array dimension */
} AMX_DBG_SYMDIM;
int16_t tag PACKED; /* tag for the array dimension */
ucell size PACKED; /* size of the array dimension */
} PACKED AMX_DBG_SYMDIM;
typedef struct tagAMX_DBG_TAG {
int16_t tag ; /* tag id */
int16_t tag PACKED; /* tag id */
const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_TAG;
} PACKED AMX_DBG_TAG;
typedef struct tagAMX_DBG_MACHINE {
int16_t automaton ; /* automaton id */
ucell address ; /* address of state variable */
int16_t automaton PACKED; /* automaton id */
ucell address PACKED; /* address of state variable */
const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_MACHINE;
} PACKED AMX_DBG_MACHINE;
typedef struct tagAMX_DBG_STATE {
int16_t state ; /* state id */
int16_t automaton ; /* automaton id */
int16_t state PACKED; /* state id */
int16_t automaton PACKED; /* automaton id */
const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_STATE;
} PACKED AMX_DBG_STATE;
typedef struct tagAMX_DBG {
AMX_DBG_HDR *hdr ; /* points to the AMX_DBG header */
AMX_DBG_FILE **filetbl ;
AMX_DBG_LINE *linetbl ;
AMX_DBG_SYMBOL **symboltbl ;
AMX_DBG_TAG **tagtbl ;
AMX_DBG_MACHINE **automatontbl ;
AMX_DBG_STATE **statetbl ;
} AMX_DBG;
AMX_DBG_HDR _FAR *hdr PACKED; /* points to the AMX_DBG header */
AMX_DBG_FILE _FAR **filetbl PACKED;
AMX_DBG_LINE _FAR *linetbl PACKED;
AMX_DBG_SYMBOL _FAR **symboltbl PACKED;
AMX_DBG_TAG _FAR **tagtbl PACKED;
AMX_DBG_MACHINE _FAR **automatontbl PACKED;
AMX_DBG_STATE _FAR **statetbl PACKED;
} PACKED AMX_DBG;
#if !defined iVARIABLE
#define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */
@ -134,7 +140,7 @@ typedef struct tagAMX_DBG {
int AMXAPI dbg_FreeInfo(AMX_DBG *amxdbg);
int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, FILE *fp);
int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, void *dbg_addr);
int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename);
int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcname);
@ -164,3 +170,4 @@ int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX
#endif
#endif /* AMXDBG_H_INCLUDED */