info symbol <s>
where <s> is a regular expression
it'll display all known symbols match regex <s>
I made the assumption that regex (header, lib) was standard across unices. if not, let me know & I'll add the configure bits
A+
--
Eric Pouech
Name: wd_syminfo ChangeLog: added 'info symbol' command to look after defined symbols License: X11 GenDate: 2003/01/02 14:32:35 UTC ModifiedFiles: programs/winedbg/dbg.y programs/winedbg/debug.l programs/winedbg/debugger.h programs/winedbg/hash.c AddedFiles: =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/dbg.y,v retrieving revision 1.3 diff -u -u -r1.3 dbg.y --- programs/winedbg/dbg.y 12 Dec 2002 23:34:01 -0000 1.3 +++ programs/winedbg/dbg.y 1 Jan 2003 16:03:38 -0000 @@ -52,7 +52,7 @@ %token tCONT tPASS tSTEP tLIST tNEXT tQUIT tHELP tBACKTRACE tINFO tWALK tUP tDOWN %token tENABLE tDISABLE tBREAK tWATCH tDELETE tSET tMODE tPRINT tEXAM tABORT tVM86 -%token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tREGS tWND tQUEUE tLOCAL tEXCEPTION +%token tCLASS tMAPS tMODULE tSTACK tSEGMENTS tSYMBOL tREGS tWND tQUEUE tLOCAL tEXCEPTION %token tPROCESS tTHREAD tMODREF tEOL tEOF %token tFRAME tSHARE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE %token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE @@ -231,9 +231,10 @@ | tINFO tMODULE expr_value tEOL { DEBUG_DumpModule( $3 ); DEBUG_FreeExprMem(); } | tINFO tQUEUE expr_value tEOL { DEBUG_DumpQueue( $3 ); DEBUG_FreeExprMem(); } | tINFO tREGS tEOL { DEBUG_InfoRegisters(&DEBUG_context); } | tINFO tSEGMENTS expr_value tEOL { DEBUG_InfoSegments( $3, 1 ); DEBUG_FreeExprMem(); } | tINFO tSEGMENTS tEOL { DEBUG_InfoSegments( 0, -1 ); } | tINFO tSTACK tEOL { DEBUG_InfoStack(); } + | tINFO tSYMBOL tSTRING { DEBUG_InfoSymbols($3); } | tINFO tMAPS tEOL { DEBUG_InfoVirtual(); } | tINFO tWND expr_value tEOL{ DEBUG_InfoWindow( (HWND)$3 ); DEBUG_FreeExprMem(); } | tINFO tLOCAL tEOL { DEBUG_InfoLocals(); } Index: programs/winedbg/debug.l =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/debug.l,v retrieving revision 1.1 diff -u -u -r1.1 debug.l --- programs/winedbg/debug.l 13 Sep 2002 17:54:28 -0000 1.1 +++ programs/winedbg/debug.l 1 Jan 2003 16:00:27 -0000 @@ -152,6 +152,7 @@ <INFO_CMD>registers|regs|reg|re { return tREGS; } <INFO_CMD>segments|segment|segm|seg|se { return tSEGMENTS; } <INFO_CMD>stack|stac|sta|st { return tSTACK; } +<INFO_CMD>symbol|sym { BEGIN(ASTRING_EXPECTED); return tSYMBOL; } <INFO_CMD>maps|map { return tMAPS; } <INFO_CMD,WALK_CMD>window|windo|wind|win|wnd { return tWND; } <HELP_CMD>info|inf|in { return tINFO; } Index: programs/winedbg/debugger.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/debugger.h,v retrieving revision 1.2 diff -u -u -r1.2 debugger.h --- programs/winedbg/debugger.h 16 Sep 2002 19:26:48 -0000 1.2 +++ programs/winedbg/debugger.h 1 Jan 2003 16:03:25 -0000 @@ -388,6 +388,7 @@ extern int DEBUG_SetLocalSymbolType(struct wine_locals * sym, struct datatype * type); extern BOOL DEBUG_Normalize(struct name_hash * nh ); +void DEBUG_InfoSymbols(const char* str); /* debugger/info.c */ extern void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format ); Index: programs/winedbg/hash.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/hash.c,v retrieving revision 1.3 diff -u -u -r1.3 hash.c --- programs/winedbg/hash.c 6 Nov 2002 19:55:04 -0000 1.3 +++ programs/winedbg/hash.c 1 Jan 2003 16:03:18 -0000 @@ -1333,4 +1343,66 @@ sym->type = type; return TRUE; +} + +static int cmp_sym_by_name(const void * p1, const void * p2) +{ + struct name_hash ** name1 = (struct name_hash **) p1; + struct name_hash ** name2 = (struct name_hash **) p2; + + return strcmp( (*name1)->name, (*name2)->name ); +} + +#include <regex.h> + +void DEBUG_InfoSymbols(const char* str) +{ + int i; + struct name_hash* nh; + struct name_hash** array = NULL; + unsigned num_used_array = 0; + unsigned num_alloc_array = 0; + const char* name; + enum dbg_mode mode; + regex_t preg; + + regcomp(&preg, str, REG_NOSUB); + + /* grab all symbols */ + for (i = 0; i < NR_NAME_HASH; i++) + { + for (nh = name_hash_table[i]; nh; nh = nh->next) + { + if (regexec(&preg, nh->name, 0, NULL, 0) == 0) + { + if (num_used_array == num_alloc_array) + { + array = HeapReAlloc(GetProcessHeap(), 0, array, sizeof(*array) * (num_alloc_array += 32)); + if (!array) return; + } + array[num_used_array++] = nh; + } + } + } + regfree(&preg); + + /* now sort them by alphabetical order */ + qsort(array, num_used_array, sizeof(*array), cmp_sym_by_name); + + /* and display them */ + for (i = 0; i < num_used_array; i++) + { + mode = DEBUG_GetSelectorType(array[i]->value.addr.seg); + name = DEBUG_FindNearestSymbol( &array[i]->value.addr, TRUE, + NULL, 0, NULL ); + + if (mode != MODE_32) + DEBUG_Printf( DBG_CHN_MESG, "%04lx:%04lx :", + array[i]->value.addr.seg & 0xFFFF, + array[i]->value.addr.off ); + else + DEBUG_Printf( DBG_CHN_MESG, "%08lx :", array[i]->value.addr.off ); + if (name) DEBUG_Printf( DBG_CHN_MESG, " %s\n", name ); + } + HeapFree(GetProcessHeap(), 0, array); }