Eric Pouech : dbghelp: Return better values in module information.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jan 23 10:35:14 CST 2006
Module: wine
Branch: refs/heads/master
Commit: 0509fe72c94d58653e43b58912d3e6bf7835e877
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=0509fe72c94d58653e43b58912d3e6bf7835e877
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Mon Jan 23 16:38:57 2006 +0100
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
---
dlls/dbghelp/dbghelp_private.h | 1 +
dlls/dbghelp/module.c | 48 +++++++++++++++++++++++++++++-----------
dlls/dbghelp/symbol.c | 12 +++-------
3 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index a4950fa..3f5fcf6 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -334,6 +334,7 @@ extern BOOL elf_synchronize_modu
extern DWORD WINAPI addr_to_linear(HANDLE hProcess, HANDLE hThread, ADDRESS* addr);
/* module.c */
+extern int module_compute_num_syms(struct module* module);
extern struct module*
module_find_by_addr(const struct process* pcs, unsigned long addr,
enum module_type type);
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 0227aa0..17974ef 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -271,6 +271,7 @@ struct module* module_get_debug(const st
}
if (!ret) module->module.SymType = SymNone;
assert(module->module.SymType != SymDeferred);
+ module_compute_num_syms(module);
}
return (module && module->module.SymType != SymNone) ? module : NULL;
}
@@ -359,6 +360,18 @@ enum module_type module_get_type_by_name
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.@)
*/
@@ -404,7 +417,7 @@ DWORD WINAPI SymLoadModule(HANDLE hProce
WARN("Couldn't locate %s\n", ImageName);
return 0;
}
-
+ module_compute_num_syms(module);
done:
/* by default pe_load_module fills module.ModuleName from a derivation
* of ImageName. Overwrite it, if we have better information
@@ -436,6 +449,7 @@ DWORD64 WINAPI SymLoadModuleEx(HANDLE h
if (!module) return FALSE;
if (ModuleName)
lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName));
+ module->module.SymType = SymVirtual;
return TRUE;
}
@@ -601,7 +615,10 @@ BOOL WINAPI SymGetModuleInfo(HANDLE hPr
{
module = module_get_container(pcs, module);
if (module && module->module.SymType != SymNone)
+ {
ModuleInfo->SymType = module->module.SymType;
+ ModuleInfo->NumSyms = module->module.NumSyms;
+ }
}
return TRUE;
@@ -616,8 +633,8 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE h
{
struct process* pcs = process_find_by_handle(hProcess);
struct module* module;
- DWORD sz;
IMAGEHLP_MODULE64 mod;
+ char* ptr;
TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo);
@@ -626,6 +643,7 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE h
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
if (!module) return FALSE;
+ mod.SizeOfStruct = ModuleInfo->SizeOfStruct;
mod.BaseOfImage = module->module.BaseOfImage;
mod.ImageSize = module->module.ImageSize;
mod.TimeDateStamp = module->module.TimeDateStamp;
@@ -635,18 +653,21 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE h
strcpy(mod.ModuleName, module->module.ModuleName);
strcpy(mod.ImageName, module->module.ImageName);
strcpy(mod.LoadedImageName, module->module.LoadedImageName);
- /* FIXME: all following attributes need to be set */
- mod.LoadedPdbName[0] = '\0';
- mod.CVSig = 0;
+ /* FIXME: for now, using some 'rather sane' value */
+ sprintf(mod.LoadedPdbName, ".\%s.pdb", module->module.ModuleName);
+ mod.CVSig = 0x53445352; /* RSDS */
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;
memset(&mod.PdbSig70, 0, sizeof(mod.PdbSig70));
mod.PdbAge = 0;
- mod.PdbUnmatched = 0;
- mod.DbgUnmatched = 0;
- mod.LineNumbers = 0;
- mod.GlobalSymbols = 0;
- mod.TypeInfo = 0;
+ mod.PdbUnmatched = FALSE;
+ mod.DbgUnmatched = FALSE;
+ mod.LineNumbers = TRUE;
+ mod.GlobalSymbols = TRUE;
+ mod.TypeInfo = TRUE;
mod.SourceIndexed = 0;
mod.Publics = 0;
@@ -654,11 +675,12 @@ BOOL WINAPI SymGetModuleInfo64(HANDLE h
{
module = module_get_container(pcs, module);
if (module && module->module.SymType != SymNone)
+ {
mod.SymType = module->module.SymType;
+ mod.NumSyms = module->module.NumSyms;
+ }
}
- sz = ModuleInfo->SizeOfStruct;
- memcpy(ModuleInfo, &mod, sz);
- ModuleInfo->SizeOfStruct = sz;
+ memcpy(ModuleInfo, &mod, mod.SizeOfStruct);
return TRUE;
}
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index faeee98..7cf9c9e 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -575,24 +575,20 @@ static BOOL symt_enum_module(struct modu
*/
static BOOL resort_symbols(struct module* module)
{
- int nsym = 0;
+ int nsym;
void* ptr;
struct symt_ht* sym;
struct hash_table_iter hti;
- hash_table_iter_init(&module->ht_symbols, &hti, NULL);
- while ((ptr = hash_table_iter_up(&hti)))
- nsym++;
-
- if (!(module->module.NumSyms = nsym)) return FALSE;
+ if (!module_compute_num_syms(module)) return FALSE;
if (module->addr_sorttab)
module->addr_sorttab = HeapReAlloc(GetProcessHeap(), 0,
module->addr_sorttab,
- nsym * sizeof(struct symt_ht*));
+ module->module.NumSyms * sizeof(struct symt_ht*));
else
module->addr_sorttab = HeapAlloc(GetProcessHeap(), 0,
- nsym * sizeof(struct symt_ht*));
+ module->module.NumSyms * sizeof(struct symt_ht*));
if (!module->addr_sorttab) return FALSE;
nsym = 0;
More information about the wine-cvs
mailing list