From 670824f4cfea75537847c9f99a7219b25b6812e8 Mon Sep 17 00:00:00 2001 From: Jason Green Date: Tue, 20 Nov 2007 15:38:01 -0500 Subject: [PATCH] Wrap TRACE strings using the debugstr() functions, and improve some other TRACEs for pe_module.c --- dlls/dbghelp/pe_module.c | 70 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 56 insertions(+), 14 deletions(-) diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 3027f5b..b025f2b 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -47,6 +47,10 @@ static BOOL pe_load_stabs(const struct process* pcs, struct module* module, unsigned int stabs = 0, stabstr = 0; BOOL ret = FALSE; + + TRACE("looking for STABS debug info {pcs = %p, module = %p, mapping = %p, nth = %p}\n", + pcs, module, mapping, nth); + section = (IMAGE_SECTION_HEADER*) ((char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader); for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++) @@ -55,11 +59,15 @@ static BOOL pe_load_stabs(const struct process* pcs, struct module* module, { stabs = section->VirtualAddress; stabsize = section->SizeOfRawData; + + TRACE("found a '.stab' section at 0x%08x {size = %d}\n", stabs, stabsize); } else if (!strncasecmp((const char*)section->Name, ".stabstr", 8)) { stabstr = section->VirtualAddress; stabstrsize = section->SizeOfRawData; + + TRACE("found a '.stabstr' section at 0x%08x {size = %d}\n", stabstr, stabstrsize); } } @@ -67,11 +75,13 @@ static BOOL pe_load_stabs(const struct process* pcs, struct module* module, { ret = stabs_parse(module, module->module.BaseOfImage - nth->OptionalHeader.ImageBase, - RtlImageRvaToVa(nth, (void*)mapping, stabs, NULL), + RtlImageRvaToVa(nth, (HMODULE)mapping, stabs, NULL), stabsize, - RtlImageRvaToVa(nth, (void*)mapping, stabstr, NULL), + RtlImageRvaToVa(nth, (HMODULE)mapping, stabstr, NULL), stabstrsize); } + + TRACE("%s the STABS debug info\n", ret ? "successfully loaded" : "failed to load"); return ret; } @@ -96,7 +106,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, const IMAGE_DEBUG_DIRECTORY* dbg; BOOL ret = FALSE; - WINE_TRACE("Processing DBG file %s\n", dbg_name); + WINE_TRACE("Processing DBG file %s\n", debugstr_a(dbg_name)); if (SymFindFileInPath(pcs->handle, NULL, dbg_name, NULL, 0, 0, 0, tmp, dbg_match, NULL) && (hFile = CreateFileA(tmp, GENERIC_READ, FILE_SHARE_READ, NULL, @@ -104,11 +114,12 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) && ((dbg_mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)) { + TRACE("opened .DBG file %s\n", debugstr_a(tmp)); hdr = (const IMAGE_SEPARATE_DEBUG_HEADER*)dbg_mapping; if (hdr->TimeDateStamp != timestamp) { WINE_ERR("Warning - %s has incorrect internal timestamp\n", - dbg_name); + debugstr_a(dbg_name)); /* * Well, sometimes this happens to DBG files which ARE REALLY the * right .DBG files but nonetheless this check fails. Anyway, @@ -136,7 +147,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, ERR("Wrong signature in .DBG file %s\n", debugstr_a(tmp)); } else - WINE_ERR("-Unable to peruse .DBG file %s (%s)\n", dbg_name, debugstr_a(tmp)); + WINE_ERR("-Unable to peruse .DBG file %s (%s)\n", debugstr_a(dbg_name), debugstr_a(tmp)); if (dbg_mapping) UnmapViewOfFile(dbg_mapping); if (hMap) CloseHandle(hMap); @@ -163,7 +174,7 @@ static BOOL pe_load_msc_debug_info(const struct process* pcs, nDbg = dir->Size / sizeof(IMAGE_DEBUG_DIRECTORY); if (!nDbg) return FALSE; - dbg = RtlImageRvaToVa(nth, (void*)mapping, dir->VirtualAddress, NULL); + dbg = RtlImageRvaToVa(nth, (HMODULE)mapping, dir->VirtualAddress, NULL); /* Parse debug directory */ if (nth->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) @@ -172,6 +183,9 @@ static BOOL pe_load_msc_debug_info(const struct process* pcs, const IMAGE_DEBUG_MISC* misc = (const IMAGE_DEBUG_MISC*) ((const char*)mapping + dbg->PointerToRawData); + + TRACE("debug information has been stripped\n"); + if (nDbg != 1 || dbg->Type != IMAGE_DEBUG_TYPE_MISC || misc->DataType != IMAGE_DEBUG_MISC_EXENAME) { @@ -180,12 +194,16 @@ static BOOL pe_load_msc_debug_info(const struct process* pcs, } else { + TRACE("loading a .DBG file from '%s'\n", (const char*)misc->Data); ret = pe_load_dbg_file(pcs, module, (const char*)misc->Data, nth->FileHeader.TimeDateStamp); } } else { const IMAGE_SECTION_HEADER *sectp = (const IMAGE_SECTION_HEADER*)((const char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader); + + + TRACE("debug info is embedded in the module\n"); /* Debug info is embedded into PE module */ ret = pe_load_debug_directory(pcs, module, mapping, sectp, nth->FileHeader.NumberOfSections, dbg, nDbg); @@ -235,7 +253,7 @@ static BOOL pe_load_export_debug_info(const struct process* pcs, #endif /* Add exported functions */ - if ((exports = RtlImageDirectoryEntryToData((void*)mapping, FALSE, + if ((exports = RtlImageDirectoryEntryToData((HMODULE)mapping, FALSE, IMAGE_DIRECTORY_ENTRY_EXPORT, &size))) { const WORD* ordinals = NULL; @@ -244,9 +262,9 @@ static BOOL pe_load_export_debug_info(const struct process* pcs, unsigned int j; char buffer[16]; - functions = RtlImageRvaToVa(nth, (void*)mapping, exports->AddressOfFunctions, NULL); - ordinals = RtlImageRvaToVa(nth, (void*)mapping, exports->AddressOfNameOrdinals, NULL); - names = RtlImageRvaToVa(nth, (void*)mapping, exports->AddressOfNames, NULL); + functions = RtlImageRvaToVa(nth, (HMODULE)mapping, exports->AddressOfFunctions, NULL); + ordinals = RtlImageRvaToVa(nth, (HMODULE)mapping, exports->AddressOfNameOrdinals, NULL); + names = RtlImageRvaToVa(nth, (HMODULE)mapping, exports->AddressOfNames, NULL); if (functions && ordinals && names) { @@ -297,20 +315,26 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module) { if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) { - nth = RtlImageNtHeader(mapping); + nth = RtlImageNtHeader((HMODULE)mapping); if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY)) { + TRACE("loading main debug info\n"); ret = pe_load_stabs(pcs, module, mapping, nth) || pe_load_msc_debug_info(pcs, module, mapping, nth); /* if we still have no debug info (we could only get SymExport at this * point), then do the SymExport except if we have an ELF container, * in which case we'll rely on the export's on the ELF side */ + + if (!ret) + ERR("loading debug information failed for module '%s'\n", debugstr_a(module->module_name)); } /* FIXME shouldn't we check that? if (!module_get_debug(pcs, module))l */ + TRACE("loading public debug symbols\n"); if (pe_load_export_debug_info(pcs, module, mapping, nth) && !ret) ret = TRUE; + TRACE("%s the debug symbols\n", ret ? "successfully loaded" : "failed to load"); UnmapViewOfFile(mapping); } CloseHandle(hMap); @@ -332,14 +356,23 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, HANDLE hMap; WCHAR loaded_name[MAX_PATH]; + + TRACE("(pcs = %p, name = '%s', hFile = %p, base = 0x%08x, size = %d)\n", + pcs, debugstr_w(name), hFile, base, size); + loaded_name[0] = '\0'; if (!hFile) { assert(name); - if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == NULL) + TRACE("attempting to find the executable image '%s'\n", debugstr_w(name)); + if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == 0){ + ERR("could not open the executable image\n"); return NULL; + } + + TRACE("found the executable at '%s'\n", debugstr_w(loaded_name)); opened = TRUE; } else if (name) strcpyW(loaded_name, name); @@ -352,23 +385,31 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) { - IMAGE_NT_HEADERS* nth = RtlImageNtHeader(mapping); + IMAGE_NT_HEADERS* nth = RtlImageNtHeader((HMODULE)mapping); if (nth) { if (!base) base = nth->OptionalHeader.ImageBase; if (!size) size = nth->OptionalHeader.SizeOfImage; + TRACE("reading module information\n"); module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size, nth->FileHeader.TimeDateStamp, nth->OptionalHeader.CheckSum); + if (module) { if (dbghelp_options & SYMOPT_DEFERRED_LOADS) module->module.SymType = SymDeferred; - else + else{ + TRACE("loading the debug information for module %p\n", module); pe_load_debug_info(pcs, module); + TRACE("done loading debug information\n"); + } } + + else + ERR("could not load the module '%s'\n", debugstr_w(loaded_name)); } UnmapViewOfFile(mapping); } @@ -376,6 +417,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, } if (opened) CloseHandle(hFile); + TRACE("done loading the module '%s'\n", debugstr_w(name)); return module; } -- 1.4.4.2