- enhanced 'info share' output

- made use of new dbghelp pure ELF symbol lookup
This commit is contained in:
Eric Pouech 2004-07-04 00:25:15 +00:00 committed by Alexandre Julliard
parent 6e2bca34cf
commit 10e8ed071a
3 changed files with 39 additions and 10 deletions

View File

@ -120,6 +120,7 @@ static const char* get_symtype_str(SYM_TYPE st)
{ {
switch (st) switch (st)
{ {
case -1: return "\\";
default: default:
case SymNone: return "--none--"; case SymNone: return "--none--";
case SymCoff: return "COFF"; case SymCoff: return "COFF";
@ -129,6 +130,7 @@ static const char* get_symtype_str(SYM_TYPE st)
case SymDeferred: return "Deferred"; case SymDeferred: return "Deferred";
case SymSym: return "Sym"; case SymSym: return "Sym";
case SymDia: return "DIA"; case SymDia: return "DIA";
case NumSymTypes: return "Stabs";
} }
} }
@ -139,11 +141,11 @@ struct info_module
unsigned num_used; unsigned num_used;
}; };
static void module_print_info(const IMAGEHLP_MODULE* mi) static void module_print_info(const IMAGEHLP_MODULE* mi, SYM_TYPE st)
{ {
dbg_printf("0x%08lx-%08lx\t%-16s%s\n", dbg_printf("0x%08lx-%08lx\t%-16s%s\n",
mi->BaseOfImage, mi->BaseOfImage + mi->ImageSize, mi->BaseOfImage, mi->BaseOfImage + mi->ImageSize,
get_symtype_str(mi->SymType), mi->ModuleName); get_symtype_str(st), mi->ModuleName);
} }
static int module_compare(const void* p1, const void* p2) static int module_compare(const void* p1, const void* p2)
@ -172,7 +174,6 @@ static BOOL CALLBACK info_mod_cb(PSTR mod_name, DWORD base, void* ctx)
im->mi[im->num_used].SizeOfStruct = sizeof(im->mi[im->num_used]); im->mi[im->num_used].SizeOfStruct = sizeof(im->mi[im->num_used]);
if (SymGetModuleInfo(dbg_curr_process->handle, base, &im->mi[im->num_used])) if (SymGetModuleInfo(dbg_curr_process->handle, base, &im->mi[im->num_used]))
{ {
module_print_info(&im->mi[im->num_used]);
im->num_used++; im->num_used++;
} }
return TRUE; return TRUE;
@ -202,7 +203,7 @@ void info_win32_module(DWORD base)
dbg_printf("'0x%08lx' is not a valid module address\n", base); dbg_printf("'0x%08lx' is not a valid module address\n", base);
return; return;
} }
module_print_info(&mi); module_print_info(&mi, mi.SymType);
} }
else else
{ {
@ -229,14 +230,14 @@ void info_win32_module(DWORD base)
if (strstr(im.mi[i].ModuleName, "<elf>")) if (strstr(im.mi[i].ModuleName, "<elf>"))
{ {
dbg_printf("ELF\t"); dbg_printf("ELF\t");
module_print_info(&im.mi[i]); module_print_info(&im.mi[i], (im.mi[i].SymType == SymDia) ? NumSymTypes : im.mi[i].SymType);
/* print all modules embedded in this one */ /* print all modules embedded in this one */
for (j = 0; j < im.num_used; j++) for (j = 0; j < im.num_used; j++)
{ {
if (!strstr(im.mi[j].ModuleName, "<elf>") && module_is_container(&im.mi[i], &im.mi[j])) if (!strstr(im.mi[j].ModuleName, "<elf>") && module_is_container(&im.mi[i], &im.mi[j]))
{ {
dbg_printf(" \\-PE\t"); dbg_printf(" \\-PE\t");
module_print_info(&im.mi[j]); module_print_info(&im.mi[j], -1);
} }
} }
} }
@ -253,7 +254,7 @@ void info_win32_module(DWORD base)
dbg_printf("ELF\t"); dbg_printf("ELF\t");
else else
dbg_printf("PE\t"); dbg_printf("PE\t");
module_print_info(&im.mi[i]); module_print_info(&im.mi[i], im.mi[i].SymType);
} }
} }
HeapFree(GetProcessHeap(), 0, im.mi); HeapFree(GetProcessHeap(), 0, im.mi);
@ -704,7 +705,6 @@ void info_wine_dbg_channel(BOOL turn_on, const char* chnl, const char* name)
if (symbol_get_lvalue("first_dll", -1, &lvalue, FALSE) != sglv_found) if (symbol_get_lvalue("first_dll", -1, &lvalue, FALSE) != sglv_found)
{ {
dbg_printf("Can't get first_dll symbol\n");
return; return;
} }
addr = memory_to_linear_addr(&lvalue.addr); addr = memory_to_linear_addr(&lvalue.addr);

View File

@ -204,6 +204,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
char tmp[sizeof(SYMBOL_INFO) + 256]; char tmp[sizeof(SYMBOL_INFO) + 256];
SYMBOL_INFO* si = (SYMBOL_INFO*)tmp; SYMBOL_INFO* si = (SYMBOL_INFO*)tmp;
char buffer[512]; char buffer[512];
DWORD opt;
if (strlen(name) + 4 > sizeof(buffer)) if (strlen(name) + 4 > sizeof(buffer))
{ {
@ -223,16 +224,27 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
buffer[1] = '!'; buffer[1] = '!';
strcpy(&buffer[2], name); strcpy(&buffer[2], name);
/* this is a wine specific options to return also ELF modules in the
* enumeration
*/
SymSetOptions((opt = SymGetOptions()) | 0x40000000);
if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv)) if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv))
{
SymSetOptions(opt);
return sglv_unknown; return sglv_unknown;
}
if (!sgv.num && (name[0] != '_')) if (!sgv.num && (name[0] != '_'))
{ {
buffer[2] = '_'; buffer[2] = '_';
strcpy(&buffer[3], name); strcpy(&buffer[3], name);
if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv)) if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv))
{
SymSetOptions(opt);
return sglv_unknown; return sglv_unknown;
}
} }
SymSetOptions(opt);
/* now grab local symbols */ /* now grab local symbols */
si->SizeOfStruct = sizeof(*si); si->SizeOfStruct = sizeof(*si);
@ -426,6 +438,7 @@ BOOL symbol_get_line(const char* filename, const char* name, IMAGEHLP_LINE* line
{ {
struct sgv_data sgv; struct sgv_data sgv;
char buffer[512]; char buffer[512];
DWORD opt;
sgv.num = 0; sgv.num = 0;
sgv.num_thunks = 0; sgv.num_thunks = 0;
@ -439,16 +452,27 @@ BOOL symbol_get_line(const char* filename, const char* name, IMAGEHLP_LINE* line
buffer[1] = '!'; buffer[1] = '!';
strcpy(&buffer[2], name); strcpy(&buffer[2], name);
/* this is a wine specific options to return also ELF modules in the
* enumeration
*/
SymSetOptions((opt = SymGetOptions()) | 0x40000000);
if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv)) if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv))
{
SymSetOptions(opt);
return sglv_unknown; return sglv_unknown;
}
if (!sgv.num && (name[0] != '_')) if (!sgv.num && (name[0] != '_'))
{ {
buffer[2] = '_'; buffer[2] = '_';
strcpy(&buffer[3], name); strcpy(&buffer[3], name);
if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv)) if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv))
{
SymSetOptions(opt);
return sglv_unknown; return sglv_unknown;
}
} }
SymSetOptions(opt);
switch (sgv.num) switch (sgv.num)
{ {
@ -547,6 +571,7 @@ static BOOL CALLBACK symbols_info_cb(SYMBOL_INFO* sym, ULONG size, void* ctx)
void symbol_info(const char* str) void symbol_info(const char* str)
{ {
char buffer[512]; char buffer[512];
DWORD opt;
if (strlen(str) + 3 >= sizeof(buffer)) if (strlen(str) + 3 >= sizeof(buffer))
{ {
@ -556,5 +581,10 @@ void symbol_info(const char* str)
buffer[0] = '*'; buffer[0] = '*';
buffer[1] = '!'; buffer[1] = '!';
strcpy(&buffer[2], str); strcpy(&buffer[2], str);
/* this is a wine specific options to return also ELF modules in the
* enumeration
*/
SymSetOptions((opt = SymGetOptions()) | 0x40000000);
SymEnumSymbols(dbg_curr_process->handle, 0, buffer, symbols_info_cb, NULL); SymEnumSymbols(dbg_curr_process->handle, 0, buffer, symbols_info_cb, NULL);
SymSetOptions(opt);
} }

View File

@ -42,9 +42,8 @@
* - UI * - UI
* + enable back the limited output (depth of structure printing and number of * + enable back the limited output (depth of structure printing and number of
* lines) * lines)
* + make the output as close as possible to what gdb does
* - symbol management: * - symbol management:
* + in most of the module enumeration for symbol lookup, we don't search in
* the ELF modules (should we turn wine extented flag for ELF modules on ?)
* + symbol table loading is broken * + symbol table loading is broken
* - type management: * - type management:
* + some bits of internal types are missing (like type casts and the address * + some bits of internal types are missing (like type casts and the address