dbghelp: Return better values in module information.

- 32/64: number of symbols is now correct
- 64: the 64 bit extra fields are now initialized with some non null
  yet sensible value
This commit is contained in:
Eric Pouech 2006-01-23 16:38:57 +01:00 committed by Alexandre Julliard
parent bdf32ee032
commit 0509fe72c9
3 changed files with 40 additions and 21 deletions

View File

@ -334,6 +334,7 @@ extern BOOL elf_synchronize_module_list(struct process* pcs);
extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr); extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
/* module.c */ /* module.c */
extern int module_compute_num_syms(struct module* module);
extern struct module* extern struct module*
module_find_by_addr(const struct process* pcs, unsigned long addr, module_find_by_addr(const struct process* pcs, unsigned long addr,
enum module_type type); enum module_type type);

View File

@ -271,6 +271,7 @@ struct module* module_get_debug(const struct process* pcs, struct module* module
} }
if (!ret) module->module.SymType = SymNone; if (!ret) module->module.SymType = SymNone;
assert(module->module.SymType != SymDeferred); assert(module->module.SymType != SymDeferred);
module_compute_num_syms(module);
} }
return (module && module->module.SymType != SymNone) ? module : NULL; return (module && module->module.SymType != SymNone) ? module : NULL;
} }
@ -359,6 +360,18 @@ enum module_type module_get_type_by_name(const char* name)
return DMT_PE; return DMT_PE;
} }
int module_compute_num_syms(struct module* module)
{
struct hash_table_iter hti;
void* ptr;
module->module.NumSyms = 0;
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
while ((ptr = hash_table_iter_up(&hti)))
module->module.NumSyms++;
return module->module.NumSyms;
}
/*********************************************************************** /***********************************************************************
* SymLoadModule (DBGHELP.@) * SymLoadModule (DBGHELP.@)
*/ */
@ -404,7 +417,7 @@ DWORD WINAPI SymLoadModule(HANDLE hProcess, HANDLE hFile, const char* ImageName,
WARN("Couldn't locate %s\n", ImageName); WARN("Couldn't locate %s\n", ImageName);
return 0; return 0;
} }
module_compute_num_syms(module);
done: done:
/* by default pe_load_module fills module.ModuleName from a derivation /* by default pe_load_module fills module.ModuleName from a derivation
* of ImageName. Overwrite it, if we have better information * of ImageName. Overwrite it, if we have better information
@ -436,6 +449,7 @@ DWORD64 WINAPI SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, PCSTR ImageName,
if (!module) return FALSE; if (!module) return FALSE;
if (ModuleName) if (ModuleName)
lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName)); lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName));
module->module.SymType = SymVirtual;
return TRUE; return TRUE;
} }
@ -601,7 +615,10 @@ BOOL WINAPI SymGetModuleInfo(HANDLE hProcess, DWORD dwAddr,
{ {
module = module_get_container(pcs, module); module = module_get_container(pcs, module);
if (module && module->module.SymType != SymNone) if (module && module->module.SymType != SymNone)
{
ModuleInfo->SymType = module->module.SymType; ModuleInfo->SymType = module->module.SymType;
ModuleInfo->NumSyms = module->module.NumSyms;
}
} }
return TRUE; return TRUE;
@ -616,8 +633,8 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr,
{ {
struct process* pcs = process_find_by_handle(hProcess); struct process* pcs = process_find_by_handle(hProcess);
struct module* module; struct module* module;
DWORD sz;
IMAGEHLP_MODULE64 mod; IMAGEHLP_MODULE64 mod;
char* ptr;
TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo); TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo);
@ -626,6 +643,7 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr,
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN); module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
if (!module) return FALSE; if (!module) return FALSE;
mod.SizeOfStruct = ModuleInfo->SizeOfStruct;
mod.BaseOfImage = module->module.BaseOfImage; mod.BaseOfImage = module->module.BaseOfImage;
mod.ImageSize = module->module.ImageSize; mod.ImageSize = module->module.ImageSize;
mod.TimeDateStamp = module->module.TimeDateStamp; mod.TimeDateStamp = module->module.TimeDateStamp;
@ -635,18 +653,21 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr,
strcpy(mod.ModuleName, module->module.ModuleName); strcpy(mod.ModuleName, module->module.ModuleName);
strcpy(mod.ImageName, module->module.ImageName); strcpy(mod.ImageName, module->module.ImageName);
strcpy(mod.LoadedImageName, module->module.LoadedImageName); strcpy(mod.LoadedImageName, module->module.LoadedImageName);
/* FIXME: all following attributes need to be set */ /* FIXME: for now, using some 'rather sane' value */
mod.LoadedPdbName[0] = '\0'; sprintf(mod.LoadedPdbName, ".\%s.pdb", module->module.ModuleName);
mod.CVSig = 0; mod.CVSig = 0x53445352; /* RSDS */
memset(mod.CVData, 0, sizeof(mod.CVData)); memset(mod.CVData, 0, sizeof(mod.CVData));
strcpy(mod.CVData, module->module.LoadedImageName);
if ((ptr = strrchr(mod.CVData, '.')))
strcpy(ptr + 1, "pdb");
mod.PdbSig = 0; mod.PdbSig = 0;
memset(&mod.PdbSig70, 0, sizeof(mod.PdbSig70)); memset(&mod.PdbSig70, 0, sizeof(mod.PdbSig70));
mod.PdbAge = 0; mod.PdbAge = 0;
mod.PdbUnmatched = 0; mod.PdbUnmatched = FALSE;
mod.DbgUnmatched = 0; mod.DbgUnmatched = FALSE;
mod.LineNumbers = 0; mod.LineNumbers = TRUE;
mod.GlobalSymbols = 0; mod.GlobalSymbols = TRUE;
mod.TypeInfo = 0; mod.TypeInfo = TRUE;
mod.SourceIndexed = 0; mod.SourceIndexed = 0;
mod.Publics = 0; mod.Publics = 0;
@ -654,11 +675,12 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr,
{ {
module = module_get_container(pcs, module); module = module_get_container(pcs, module);
if (module && module->module.SymType != SymNone) if (module && module->module.SymType != SymNone)
{
mod.SymType = module->module.SymType; mod.SymType = module->module.SymType;
mod.NumSyms = module->module.NumSyms;
}
} }
sz = ModuleInfo->SizeOfStruct; memcpy(ModuleInfo, &mod, mod.SizeOfStruct);
memcpy(ModuleInfo, &mod, sz);
ModuleInfo->SizeOfStruct = sz;
return TRUE; return TRUE;
} }

View File

@ -575,24 +575,20 @@ static BOOL symt_enum_module(struct module* module, regex_t* regex,
*/ */
static BOOL resort_symbols(struct module* module) static BOOL resort_symbols(struct module* module)
{ {
int nsym = 0; int nsym;
void* ptr; void* ptr;
struct symt_ht* sym; struct symt_ht* sym;
struct hash_table_iter hti; struct hash_table_iter hti;
hash_table_iter_init(&module->ht_symbols, &hti, NULL); if (!module_compute_num_syms(module)) return FALSE;
while ((ptr = hash_table_iter_up(&hti)))
nsym++;
if (!(module->module.NumSyms = nsym)) return FALSE;
if (module->addr_sorttab) if (module->addr_sorttab)
module->addr_sorttab = HeapReAlloc(GetProcessHeap(), 0, module->addr_sorttab = HeapReAlloc(GetProcessHeap(), 0,
module->addr_sorttab, module->addr_sorttab,
nsym * sizeof(struct symt_ht*)); module->module.NumSyms * sizeof(struct symt_ht*));
else else
module->addr_sorttab = HeapAlloc(GetProcessHeap(), 0, module->addr_sorttab = HeapAlloc(GetProcessHeap(), 0,
nsym * sizeof(struct symt_ht*)); module->module.NumSyms * sizeof(struct symt_ht*));
if (!module->addr_sorttab) return FALSE; if (!module->addr_sorttab) return FALSE;
nsym = 0; nsym = 0;