Commit a49adbc4 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Base and symbols.

- report the correct image base for a symbol which is seen as being in a builtin PE module, whilst its debug information is gotten from an ELF module - module_get_debug now returns a pair of modules (the requested that has to be presented back to the client and the effective one, which contains the debug info) - reworked SymFromName in order to provide also the revelant module base address
parent bc31b388
......@@ -315,6 +315,12 @@ struct line_info
} u;
};
struct module_pair
{
struct module* requested; /* in: to module_get_debug() */
struct module* effective; /* out: module with debug info */
};
/* dbghelp.c */
extern struct process* process_find_by_handle(HANDLE hProcess);
extern HANDLE hMsvcrt;
......@@ -342,8 +348,7 @@ extern struct module*
extern struct module*
module_find_by_name(const struct process* pcs,
const char* name, enum module_type type);
extern struct module*
module_get_debug(const struct process* pcs, struct module*);
extern BOOL module_get_debug(const struct process* pcs, struct module_pair*);
extern struct module*
module_new(struct process* pcs, const char* name,
enum module_type type, BOOL virtual,
......
......@@ -229,37 +229,36 @@ struct module* module_get_containee(const struct process* pcs,
* container (and also force the ELF container's debug info loading if deferred)
* - otherwise return the module itself if it has some debug info
*/
struct module* module_get_debug(const struct process* pcs, struct module* module)
BOOL module_get_debug(const struct process* pcs, struct module_pair* pair)
{
struct module* parent;
IMAGEHLP_DEFERRED_SYMBOL_LOAD64 idsl64;
if (!module) return NULL;
/* for a PE builtin, always get info from parent */
if ((parent = module_get_container(pcs, module)))
module = parent;
if (!pair->requested) return FALSE;
/* for a PE builtin, always get info from container */
if (!(pair->effective = module_get_container(pcs, pair->requested)))
pair->effective = pair->requested;
/* if deferred, force loading */
if (module->module.SymType == SymDeferred)
if (pair->effective->module.SymType == SymDeferred)
{
BOOL ret;
if (module->is_virtual) ret = FALSE;
else switch (module->type)
if (pair->effective->is_virtual) ret = FALSE;
else switch (pair->effective->type)
{
case DMT_ELF:
ret = elf_load_debug_info(module, NULL);
ret = elf_load_debug_info(pair->effective, NULL);
break;
case DMT_PE:
idsl64.SizeOfStruct = sizeof(idsl64);
idsl64.BaseOfImage = module->module.BaseOfImage;
idsl64.CheckSum = module->module.CheckSum;
idsl64.TimeDateStamp = module->module.TimeDateStamp;
strcpy(idsl64.FileName, module->module.ImageName);
idsl64.BaseOfImage = pair->effective->module.BaseOfImage;
idsl64.CheckSum = pair->effective->module.CheckSum;
idsl64.TimeDateStamp = pair->effective->module.TimeDateStamp;
strcpy(idsl64.FileName, pair->effective->module.ImageName);
idsl64.Reparse = FALSE;
idsl64.hFile = INVALID_HANDLE_VALUE;
pcs_callback(pcs, CBA_DEFERRED_SYMBOL_LOAD_START, &idsl64);
ret = pe_load_debug_info(pcs, module);
ret = pe_load_debug_info(pcs, pair->effective);
pcs_callback(pcs,
ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
&idsl64);
......@@ -268,11 +267,11 @@ struct module* module_get_debug(const struct process* pcs, struct module* module
ret = FALSE;
break;
}
if (!ret) module->module.SymType = SymNone;
assert(module->module.SymType != SymDeferred);
module_compute_num_syms(module);
if (!ret) pair->effective->module.SymType = SymNone;
assert(pair->effective->module.SymType != SymDeferred);
module_compute_num_syms(pair->effective);
}
return (module && module->module.SymType != SymNone) ? module : NULL;
return pair->effective->module.SymType != SymNone;
}
/***********************************************************************
......
......@@ -102,7 +102,7 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask,
PVOID UserContext)
{
struct process* pcs;
struct module* module;
struct module_pair pair;
SOURCEFILE sf;
char* ptr;
......@@ -112,15 +112,15 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask,
if (ModBase)
{
module = module_find_by_addr(pcs, ModBase, DMT_UNKNOWN);
if (!(module = module_get_debug(pcs, module))) return FALSE;
pair.requested = module_find_by_addr(pcs, ModBase, DMT_UNKNOWN);
if (!module_get_debug(pcs, &pair)) return FALSE;
}
else
{
if (Mask[0] == '!')
{
module = module_find_by_name(pcs, Mask + 1, DMT_UNKNOWN);
if (!(module = module_get_debug(pcs, module))) return FALSE;
pair.requested = module_find_by_name(pcs, Mask + 1, DMT_UNKNOWN);
if (!module_get_debug(pcs, &pair)) return FALSE;
}
else
{
......@@ -128,8 +128,8 @@ BOOL WINAPI SymEnumSourceFiles(HANDLE hProcess, ULONG64 ModBase, PCSTR Mask,
return FALSE;
}
}
if (!module->sources) return FALSE;
for (ptr = module->sources; *ptr; ptr += strlen(ptr) + 1)
if (!pair.effective->sources) return FALSE;
for (ptr = pair.effective->sources; *ptr; ptr += strlen(ptr) + 1)
{
/* FIXME: not using Mask */
sf.ModBase = ModBase;
......@@ -148,7 +148,7 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland,
PCSTR srcfile, PSYM_ENUMLINES_CALLBACK cb, PVOID user)
{
struct process* pcs;
struct module* module;
struct module_pair pair;
struct hash_table_iter hti;
struct symt_ht* sym;
regex_t re;
......@@ -168,13 +168,13 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland,
return FALSE;
}
if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland);
module = module_find_by_addr(pcs, base, DMT_UNKNOWN);
if (!(module = module_get_debug(pcs, module))) return FALSE;
pair.requested = module_find_by_addr(pcs, base, DMT_UNKNOWN);
if (!module_get_debug(pcs, &pair)) return FALSE;
sci.SizeOfStruct = sizeof(sci);
sci.ModBase = base;
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
hash_table_iter_init(&pair.effective->ht_symbols, &hti, NULL);
while ((ptr = hash_table_iter_up(&hti)))
{
sym = GET_ENTRY(ptr, struct symt_ht, hash_elt);
......@@ -186,7 +186,7 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland,
{
if (dli->is_source_file)
{
file = (char*)source_get(module, dli->u.source_file);
file = (char*)source_get(pair.effective, dli->u.source_file);
if (regexec(&re, file, 0, NULL, 0) != 0) file = "";
strcpy(sci.FileName, file);
}
......
......@@ -373,7 +373,7 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll,
PVOID UserContext)
{
struct process* pcs;
struct module* module;
struct module_pair pair;
char buffer[sizeof(SYMBOL_INFO) + 256];
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
const char* tmp;
......@@ -386,20 +386,20 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll,
UserContext);
if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
if (!(module = module_get_debug(pcs, module))) return FALSE;
pair.requested = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
if (!module_get_debug(pcs, &pair)) return FALSE;
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
while ((pos = vector_iter_up(&module->vtypes, pos)))
while ((pos = vector_iter_up(&pair.effective->vtypes, pos)))
{
type = *(struct symt**)pos;
sym_info->TypeIndex = (DWORD)type;
sym_info->info = 0; /* FIXME */
symt_get_info(type, TI_GET_LENGTH, &size);
sym_info->Size = size;
sym_info->ModBase = module->module.BaseOfImage;
sym_info->ModBase = pair.requested->module.BaseOfImage;
sym_info->Flags = 0; /* FIXME */
sym_info->Value = 0; /* FIXME */
sym_info->Address = 0; /* FIXME */
......@@ -788,12 +788,12 @@ BOOL WINAPI SymGetTypeInfo(HANDLE hProcess, DWORD64 ModBase,
PVOID pInfo)
{
struct process* pcs = process_find_by_handle(hProcess);
struct module* module;
struct module_pair pair;
if (!pcs) return FALSE;
module = module_find_by_addr(pcs, ModBase, DMT_UNKNOWN);
if (!(module = module_get_debug(pcs, module)))
pair.requested = module_find_by_addr(pcs, ModBase, DMT_UNKNOWN);
if (!module_get_debug(pcs, &pair))
{
FIXME("Someone didn't properly set ModBase (%s)\n", wine_dbgstr_longlong(ModBase));
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment