From: Eric Pouech epouech@codeweavers.com
Rely solely on extended module information.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp_private.h | 2 +- dlls/dbghelp/elf_module.c | 5 +---- dlls/dbghelp/module.c | 23 +++++++++++++-------- programs/winedbg/info.c | 37 ++++++++++++++++++++-------------- 4 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index a7ec4bcc426..ac23b0fd6b1 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -717,7 +717,6 @@ extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs, ULONG_P void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG rva) DECLSPEC_HIDDEN;
/* module.c */ -extern const WCHAR S_ElfW[] DECLSPEC_HIDDEN; extern const WCHAR S_WineLoaderW[] DECLSPEC_HIDDEN; extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN; extern const struct loader_ops empty_loader_ops DECLSPEC_HIDDEN; @@ -749,6 +748,7 @@ extern BOOL module_remove(struct process* pcs, struct module* module) DECLSPEC_HIDDEN; extern void module_set_module(struct module* module, const WCHAR* name) DECLSPEC_HIDDEN; extern WCHAR* get_wine_loader_name(struct process *pcs) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC DECLSPEC_HIDDEN; +extern BOOL module_is_wine_host(const WCHAR* module_name, const WCHAR* ext) DECLSPEC_HIDDEN;
/* msc.c */ extern BOOL pe_load_debug_directory(const struct process* pcs, diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 5ada8c70c9b..303863c773b 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -1082,11 +1082,8 @@ static BOOL elf_load_debug_info_from_map(struct module* module, } lret = dwarf2_parse(module, module->reloc_delta, thunks, fmap); ret = ret || lret; - } - if (wcsstr(module->modulename, S_ElfW) || !wcscmp(module->modulename, S_WineLoaderW)) - { /* add the thunks for native libraries */ - if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY)) + if (module_is_wine_host(module->modulename, L".so")) elf_new_wine_thunks(module, ht_symtab, thunks); } /* add all the public symbols from symtab */ diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 469f911707a..14ec60bcb89 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -35,7 +35,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
#define NOTE_GNU_BUILD_ID 3
-const WCHAR S_ElfW[] = L"<elf>"; const WCHAR S_WineLoaderW[] = L"<wine-loader>"; static const WCHAR * const ext[] = {L".acm", L".dll", L".drv", L".exe", L".ocx", L".vxd", NULL};
@@ -54,6 +53,20 @@ static int match_ext(const WCHAR* ptr, size_t len) return 0; }
+/* FIXME: implemented from checking on modulename (ie foo.dll.so) + * and Wine loader, but fails to identify unixlib. + * Would require a stronger tagging of ELF modules. + */ +BOOL module_is_wine_host(const WCHAR* module_name, const WCHAR* ext) +{ + size_t len, extlen; + if (!wcscmp(module_name, S_WineLoaderW)) return TRUE; + len = wcslen(module_name); + extlen = wcslen(ext); + return len > extlen && !wcsicmp(&module_name[len - extlen], ext) && + match_ext(module_name, len - extlen); +} + static const WCHAR* get_filename(const WCHAR* name, const WCHAR* endptr) { const WCHAR* ptr; @@ -101,7 +114,7 @@ static BOOL is_wine_loader(const WCHAR *module) static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) { const WCHAR *ptr, *endptr; - size_t len, l; + size_t len;
endptr = in + lstrlenW(in); endptr -= match_ext(in, endptr - in); @@ -111,12 +124,6 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) out[len] = '\0'; if (is_wine_loader(out)) lstrcpynW(out, S_WineLoaderW, size); - else - { - if (len > 3 && !wcsicmp(&out[len - 3], L".so") && - (l = match_ext(out, len - 3))) - lstrcpyW(&out[len - l - 3], L"<elf>"); - } while ((*out = towlower(*out))) out++; }
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 1fa2076cbd2..aeffd11f3eb 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -131,6 +131,17 @@ struct info_modules unsigned num_used; };
+static const char* get_module_type(const struct info_module* im) +{ + switch (im->ext_module_info.type) + { + case DMT_ELF: return "ELF"; + case DMT_MACHO: return "Mach-O"; + case DMT_PE: return "PE"; + default: return "----"; + } +} + static const char* get_symtype_str(const struct info_module* im) { switch (im->mi.SymType) @@ -181,13 +192,15 @@ static const char* get_machine_str(DWORD machine) static void module_print_info(const struct info_module *module, BOOL is_embedded, BOOL multi_machine) { if (multi_machine) - dbg_printf("%16I64x-%16I64x\t%s\t%-16s%s\n", + dbg_printf("%s%s\t%16I64x-%16I64x\t%s\t%-16s%s\n", + is_embedded ? " \-" : "", get_module_type(module), module->mi.BaseOfImage, module->mi.BaseOfImage + module->mi.ImageSize, get_machine_str(module->mi.MachineType), is_embedded ? "\" : get_symtype_str(module), module->name); else - dbg_printf("%*.*I64x-%*.*I64x\t%-16s%s\n", + dbg_printf("%s%s\t%*.*I64x-%*.*I64x\t%-16s%s\n", + is_embedded ? " \-" : "", get_module_type(module), ADDRWIDTH, ADDRWIDTH, module->mi.BaseOfImage, ADDRWIDTH, ADDRWIDTH, module->mi.BaseOfImage + module->mi.ImageSize, is_embedded ? "\" : get_symtype_str(module), module->name); @@ -207,7 +220,9 @@ static int __cdecl module_compare(const void* p1, const void* p2) static inline BOOL module_is_container(const struct info_module *wmod_cntnr, const struct info_module *wmod_child) { - return wmod_cntnr->mi.BaseOfImage <= wmod_child->mi.BaseOfImage && + return (wmod_cntnr->ext_module_info.type == DMT_ELF || wmod_cntnr->ext_module_info.type == DMT_MACHO) && + (wmod_child->ext_module_info.type == DMT_PE) && + wmod_cntnr->mi.BaseOfImage <= wmod_child->mi.BaseOfImage && wmod_cntnr->mi.BaseOfImage + wmod_cntnr->mi.ImageSize >= wmod_child->mi.BaseOfImage + wmod_child->mi.ImageSize; } @@ -289,33 +304,25 @@ void info_win32_module(DWORD64 base, BOOL multi_machine) (base < im.modules[i].mi.BaseOfImage || base >= im.modules[i].mi.BaseOfImage + im.modules[i].mi.ImageSize)) continue; if (!multi_machine && machine != im.modules[i].mi.MachineType) continue; - if (strstr(im.modules[i].name, "<elf>")) + if (im.modules[i].ext_module_info.type == DMT_ELF || im.modules[i].ext_module_info.type == DMT_MACHO) { - dbg_printf("ELF\t"); module_print_info(&im.modules[i], FALSE, multi_machine); /* print all modules embedded in this one */ for (j = 0; j < im.num_used; j++) { - if (!strstr(im.modules[j].name, "<elf>") && module_is_container(&im.modules[i], &im.modules[j])) - { - dbg_printf(" \-PE\t"); + if (module_is_container(&im.modules[i], &im.modules[j])) module_print_info(&im.modules[j], TRUE, multi_machine); - } } } else { /* check module is not embedded in another module */ - for (j = 0; j < im.num_used; j++) + for (j = 0; j < im.num_used; j++) { - if (strstr(im.modules[j].name, "<elf>") && module_is_container(&im.modules[j], &im.modules[i])) + if (module_is_container(&im.modules[j], &im.modules[i])) break; } if (j < im.num_used) continue; - if (strstr(im.modules[i].name, ".so") || strchr(im.modules[i].name, '<')) - dbg_printf("ELF\t"); - else - dbg_printf("PE\t"); module_print_info(&im.modules[i], FALSE, multi_machine); } num_printed++;