--- hatari/src/debug/symbols.c 2019/04/09 08:48:37 1.1.1.1 +++ hatari/src/debug/symbols.c 2019/04/09 08:50:21 1.1.1.3 @@ -12,7 +12,8 @@ * Symbol/address file contents are identical to "nm" output i.e. composed * of a hexadecimal addresses followed by a space, letter indicating symbol * type (T = text/code, D = data, B = BSS), space and the symbol name. - * Empty lines and lines starting with '#' are ignored. + * Empty lines and lines starting with '#' are ignored. AHCC SYM output + * compatible. */ const char Symbols_fileid[] = "Hatari symbols.c : " __DATE__ " " __TIME__; @@ -34,7 +35,7 @@ typedef struct { } symbol_t; typedef struct { - int count; + unsigned int count; symbol_t *addresses; /* items sorted by address */ symbol_t *names; /* items sorted by symbol name */ } symbol_list_t; @@ -97,7 +98,7 @@ static int symbols_by_name(const void *s static symbol_list_t* Symbols_Load(const char *filename, Uint32 offset, Uint32 maxaddr, symtype_t gettype) { symbol_list_t *list; - char symchar, buffer[80], name[MAX_SYM_SIZE+1], *buf; + char symchar, buffer[128], name[MAX_SYM_SIZE+1], *buf; int count, line, symbols; symtype_t symtype; Uint32 address; @@ -111,8 +112,8 @@ static symbol_list_t* Symbols_Load(const /* count content lines */ symbols = 0; while (fgets(buffer, sizeof(buffer), fp)) { - /* skip comments */ - if (*buffer == '#') { + /* skip comments (AHCC SYM file comments start with '*') */ + if (*buffer == '#' || *buffer == '*') { continue; } /* skip empty lines */ @@ -139,8 +140,8 @@ static symbol_list_t* Symbols_Load(const /* read symbols */ count = 0; for (line = 1; fgets(buffer, sizeof(buffer), fp); line++) { - /* skip comments */ - if (*buffer == '#') { + /* skip comments (AHCC SYM file comments start with '*') */ + if (*buffer == '#' || *buffer == '*') { continue; } /* skip empty lines */ @@ -160,6 +161,7 @@ static symbol_list_t* Symbols_Load(const } switch (toupper(symchar)) { case 'T': symtype = SYMTYPE_TEXT; break; + case 'O': symtype = SYMTYPE_DATA; break; /* AHCC type for _StkSize etc */ case 'D': symtype = SYMTYPE_DATA; break; case 'B': symtype = SYMTYPE_BSS; break; default: @@ -210,7 +212,7 @@ static symbol_list_t* Symbols_Load(const */ static void Symbols_Free(symbol_list_t* list) { - int i; + unsigned int i; if (!list) { return; @@ -235,8 +237,8 @@ static void Symbols_Free(symbol_list_t* */ static char* Symbols_MatchByName(symbol_list_t* list, symtype_t symtype, const char *text, int state) { + static unsigned int i, len; const symbol_t *entry; - static int i, len; if (!list) { return NULL; @@ -426,8 +428,8 @@ const char* Symbols_GetByDspAddress(Uint static void Symbols_Show(symbol_list_t* list, const char *sorttype) { symbol_t *entry, *entries; + unsigned int i; char symchar; - int i; if (!list) { fprintf(stderr, "No symbols!\n"); @@ -538,3 +540,15 @@ int Symbols_Command(int nArgc, char *psA } return DEBUGGER_CMDDONE; } + +/** + * Return how many symbols are loaded/available + */ +unsigned int Symbols_CpuCount(void) +{ + return (CpuSymbolsList ? CpuSymbolsList->count : 0); +} +unsigned int Symbols_DspCount(void) +{ + return (DspSymbolsList ? DspSymbolsList->count : 0); +}