Added 'info symbol' command to look for defined symbols.

This commit is contained in:
Eric Pouech 2003-01-11 22:48:42 +00:00 committed by Alexandre Julliard
parent e9005937ad
commit 6843fee633
4 changed files with 66 additions and 1 deletions

View File

@ -52,7 +52,7 @@ int yyerror(char *);
%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
@ -234,6 +234,7 @@ info_command:
| 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(); }

View File

@ -152,6 +152,7 @@ STRING \"[^\n"]+\"
<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; }

View File

@ -388,6 +388,7 @@ extern BOOL DEBUG_GetLineNumberAddr( const struct name_hash *, const int lineno,
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 );

View File

@ -1334,3 +1334,65 @@ int DEBUG_SetLocalSymbolType(struct wine_locals * sym, struct datatype * 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);
}