CVS: winex/dlls/dbghelp dbghelp.c, 1.6, 1.7 module.c, 1.2, 1.3 msc.c, 1.2, 1.3 path.c, 1.2, 1.3 pe_module.c, 1.2, 1.3 stack.c, 1.2, 1.3 symbol.c, 1.2, 1.3
[email protected] 30 Aug 2007 14:17:03 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/dlls/dbghelp dbghelp.c,1.6,1.7 module.c,1.2,1.3 msc.c,1.2,1.3 path.c,1.2,1.3 pe_module.c,1.2,1.3 stack.c,1.2,1.3 symbol.c,1.2,1.3Update of /var/lib/cvsd/cvsroot/winex/dlls/dbghelp
In directory agravaine:/tmp/cvs-serv18742/dlls/dbghelp
Modified Files:
dbghelp.c module.c msc.c path.c pe_module.c stack.c symbol.c
Log Message:
- added lots of extra traces and some more (and louder) error checking
- improved the PDB file dumping tool to dump to files instead of the log. This is disabled by default.
- fixed an error in the file searcher that would cause the entire HD to be searched instead of just the listed directories.
Index: dbghelp.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/dbghelp.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dbghelp.c 30 Aug 2007 14:16:43 -0000 1.6
+++ dbghelp.c 30 Aug 2007 14:17:01 -0000 1.7
@@ -89,7 +89,7 @@
return TRUE;
}
-static struct process* process_first /* = NULL */;
+static struct process* process_first = NULL;
/******************************************************************
* process_find_by_handle
@@ -220,11 +220,17 @@
char tmp[MAX_PATH];
HANDLE hProcess = (HANDLE)user;
- if (!GetModuleFileNameExA(hProcess, (HMODULE)base,
- tmp, sizeof(tmp)))
+
+ TRACE("found module '%s' {base = 0x%08lx, size = 0x%08lx, user = %p}\n", name, base, size, user);
+
+ if (!GetModuleFileNameExA(hProcess, (HMODULE)base, tmp, sizeof(tmp))){
+ WARN("could not find the full path name of the module. Using the base name of '%s' instead\n", name);
lstrcpynA(tmp, name, sizeof(tmp));
+ }
+ TRACE("loading the module '%s' {base = 0x%08lx}\n", name, base);
SymLoadModule(hProcess, 0, tmp, name, base, size);
+ TRACE("done loading the module\n");
return TRUE;
}
@@ -272,8 +278,14 @@
TRACE("(hProcess = 0x%08x, userSearchPath = '%s', fInvadeProcess = %s)\n", hProcess, debugstr_w(UserSearchPath), fInvadeProcess ? "TRUE" : "FALSE");
- if (process_find_by_handle(hProcess))
- FIXME("what to do ??\n");
+ if (process_find_by_handle(hProcess)){
+ WARN("the symbols for this process have already been initialized!\n");
+
+ /* MSDN says to only call this function once unless SymCleanup() has been called since the last call.
+ It also says to call SymRefreshModuleList() instead if you just want the module list refreshed.
+ Native still returns TRUE even if the process has already been initialized. */
+ return TRUE;
+ }
pcs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pcs));
if (!pcs) return FALSE;
@@ -316,24 +328,39 @@
}
}
+ TRACE("got search path '%s'\n", debugstr_w(pcs->search_path));
pcs->lmodules = NULL;
pcs->dbg_hdr_addr = 0;
pcs->next = process_first;
process_first = pcs;
+
+ TRACE("checking if the process is live\n");
if (check_live_target(pcs))
{
- if (fInvadeProcess)
+ TRACE("we've got a live process\n");
+
+ if (fInvadeProcess){
+ TRACE("invading the process 0x%08x\n", pcs->handle);
+
EnumerateLoadedModules(hProcess, process_invade_cb, (void*)hProcess);
+
+ TRACE("done enumerating the modules\n");
+ }
+
+ TRACE("syncronizing module list\n");
elf_synchronize_module_list(pcs);
}
else if (fInvadeProcess)
{
+ WARN("process has already died. Cleaning up...\n");
SymCleanup(hProcess);
SetLastError(ERROR_INVALID_PARAMETER);
+ WARN("done cleaning up\n");
return FALSE;
}
+ TRACE("done!\n");
return TRUE;
}
@@ -360,6 +387,8 @@
ret = SymInitializeW(hProcess, sp, fInvadeProcess);
HeapFree(GetProcessHeap(), 0, sp);
+
+ TRACE("done symbol initialization\n");
return ret;
}
@@ -372,19 +401,26 @@
struct process** ppcs;
struct process* next;
+
+ TRACE("cleaning up the symbols for the process 0x%08x\n", hProcess);
+
for (ppcs = &process_first; *ppcs; ppcs = &(*ppcs)->next)
{
if ((*ppcs)->handle == hProcess)
{
+ TRACE("found process. Removing modules\n");
while ((*ppcs)->lmodules) module_remove(*ppcs, (*ppcs)->lmodules);
HeapFree(GetProcessHeap(), 0, (*ppcs)->search_path);
next = (*ppcs)->next;
HeapFree(GetProcessHeap(), 0, *ppcs);
*ppcs = next;
+ TRACE("done\n");
return TRUE;
}
}
+
+ ERR("this process has not had SymInitialize() called for it!\n");
return FALSE;
}
@@ -401,6 +437,7 @@
for (pcs = process_first; pcs; pcs = pcs->next)
{
+ TRACE("setting options for process %p (handle = 0x%08x)\n", pcs, pcs->handle);
pcs_callback(pcs, CBA_SET_OPTIONS, &opts);
}
return dbghelp_options = opts;
@@ -412,6 +449,7 @@
*/
DWORD WINAPI SymGetOptions(void)
{
+ TRACE("current options = 0x%08x\n", dbghelp_options);
return dbghelp_options;
}
Index: module.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/module.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- module.c 30 Aug 2007 14:16:43 -0000 1.2
+++ module.c 30 Aug 2007 14:17:01 -0000 1.3
@@ -524,21 +524,29 @@
*/
if (wImageName)
{
+ TRACE("loading the module '%s'\n", debugstr_w(wImageName));
module = module_is_already_loaded(pcs, wImageName);
+
+ TRACE("checking if the module's elf container is already loaded\n");
if (!module && module_is_elf_container_loaded(pcs, wImageName, BaseOfDll))
{
/* force the loading of DLL as builtin */
+ TRACE("loading the module '%s' as builtin {base = 0x%08llx, size = %ld}\n", debugstr_w(wImageName), BaseOfDll, SizeOfDll);
module = pe_load_builtin_module(pcs, wImageName, BaseOfDll, SizeOfDll);
}
}
if (!module)
{
+ TRACE("module '%s' not loaded yet. Trying as a native PE module\n", debugstr_w(wImageName));
/* otherwise, try a regular PE module */
if (!(module = pe_load_native_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)))
{
+ TRACE("PE load failed... Getting the dbg typename from filename '%s'\n", debugstr_w(wImageName));
/* and finally and ELF module */
- if (module_get_type_by_name(wImageName) == DMT_ELF)
+ if (module_get_type_by_name(wImageName) == DMT_ELF){
+ TRACE("found an ELF file. Loading\n");
module = elf_load_module(pcs, wImageName, BaseOfDll);
+ }
}
}
if (!module)
@@ -550,6 +558,7 @@
/* by default module_new fills module.ModuleName from a derivation
* of LoadedImageName. Overwrite it, if we have better information
*/
+ TRACE("setting the module name\n");
if (wModuleName)
module_set_module(module, wModuleName);
lstrcpynW(module->module.ImageName, wImageName,
@@ -797,6 +806,8 @@
hMods = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(hMods[0]));
if (!hMods) return FALSE;
+
+ TRACE("retrieving the module list for process 0x%08x\n", hProcess);
if (!EnumProcessModules(hProcess, hMods, 256 * sizeof(hMods[0]), &sz))
{
/* hProcess should also be a valid process handle !! */
@@ -804,12 +815,19 @@
HeapFree(GetProcessHeap(), 0, hMods);
return FALSE;
}
+
+
sz /= sizeof(HMODULE);
+
for (i = 0; i < sz; i++)
{
+ TRACE("getting info for the module 0x%08x\n", hMods[i]);
if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
- !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR)))
+ !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR))){
+ ERR("couldn't get info for 0x%08x\n", hMods[i]);
continue;
+ }
+
module_fill_module(baseW, modW, sizeof(modW) / sizeof(CHAR));
EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
UserContext);
@@ -975,9 +993,23 @@
struct process* pcs = process_find_by_handle(hProcess);
struct module* module;
- if (!pcs) return 0;
+
+ TRACE("(hProcess = 0x%08x, dwAddr = 0x%08lx)\n", hProcess, dwAddr);
+
+ if (!pcs){
+ ERR("no process with the handle 0x%08x has been initialized\n", hProcess);
+ return 0;
+ }
+
+
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
- if (!module) return 0;
+
+ if (!module){
+ ERR("no module containing the address 0x%08lx was found\n", dwAddr);
+ return 0;
+ }
+
+ TRACE("returning base address of 0x%016llx\n", module->module.BaseOfImage);
return module->module.BaseOfImage;
}
@@ -986,7 +1018,13 @@
*/
DWORD64 WINAPI SymGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr)
{
- if (!validate_addr64(dwAddr)) return 0;
+ TRACE("(hProcess = 0x%08x, dwAddr = 0x%016llx)\n",
+ hProcess, dwAddr);
+
+ if (!validate_addr64(dwAddr)){
+ return 0;
+ }
+
return SymGetModuleBase(hProcess, (DWORD)dwAddr);
}
Index: msc.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/msc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- msc.c 30 Aug 2007 14:16:43 -0000 1.2
+++ msc.c 30 Aug 2007 14:17:01 -0000 1.3
@@ -1746,7 +1746,10 @@
const DWORD* block_list;
DWORD i;
- if (!toc || file_nr >= toc->num_files) return NULL;
+ if (!toc || file_nr >= toc->num_files){
+ ERR("invalid TOC or file number {toc = %p, file_nr = %ld, num_files = %ld}\n", toc, file_nr, toc ? toc->num_files : -1);
+ return NULL;
+ }
if (toc->file_size[file_nr] == 0 || toc->file_size[file_nr] == 0xFFFFFFFF)
{
@@ -1938,6 +1941,8 @@
pdb_convert_types_header(&types, types_image);
+ TRACE("type info version number is %ld\n", types.version);
+
/* Check for unknown versions */
switch (types.version)
{
@@ -2070,19 +2075,44 @@
if (0) /* some tool to dump the internal files from a PDB file */
{
int i, num_files;
+ FILE * fp;
+ char filename[MAX_PATH];
- switch (pdb_lookup->kind)
- {
- case PDB_JG: num_files = pdb_lookup->u.jg.toc->num_files; break;
- case PDB_DS: num_files = pdb_lookup->u.ds.toc->num_files; break;
+
+ switch (pdb_lookup->kind){
+ case PDB_JG: num_files = pdb_lookup->u.jg.toc->num_files; break;
+ case PDB_DS: num_files = pdb_lookup->u.ds.toc->num_files; break;
}
- for (i = 1; i < num_files; i++)
+
+ for (i = 0; i < num_files; i++)
{
unsigned char* x = pdb_read_file(image, pdb_lookup, i);
- FIXME("********************** [%u]: size=%08x\n",
- i, pdb_get_file_size(pdb_lookup, i));
- dump(x, pdb_get_file_size(pdb_lookup, i));
+
+
+ /* prevent this from reading NULL memory */
+ if (x == NULL){
+ WARN("********************** file %d is empty or missing {size = %u}\n", i, pdb_get_file_size(pdb_lookup, i));
+
+ continue;
+ }
+
+
+ snprintf(filename, MAX_PATH, "pdbfile_%02d_%ubytes.bin", i, pdb_get_file_size(pdb_lookup, i));
+ fp = fopen(filename, "wb");
+
+ if (fp){
+ FIXME("********************** [file %d]: dumping to '%s' {size = %u}\n", i, filename, pdb_get_file_size(pdb_lookup, i));
+ fwrite(x, 1, pdb_get_file_size(pdb_lookup, i), fp);
+
+ fclose(fp);
+ }
+
+ else{
+ FIXME("********************** [file %d]: ERROR-> could not open the file '%s' to dump the data to\n", i, filename);
+ dump(x, pdb_get_file_size(pdb_lookup, i));
+ }
+
pdb_free(x);
}
}
@@ -2169,9 +2199,13 @@
WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename);
goto leave;
}
+
+ TRACE("initializing the PDB file '%s'\n", pdb_lookup->filename);
pdb_init(pdb_lookup, image, FALSE);
+ TRACE("reading the symbols table\n");
symbols_image = pdb_read_file(image, pdb_lookup, 3);
+
if (symbols_image)
{
PDB_SYMBOLS symbols;
@@ -2179,7 +2213,11 @@
BYTE* file;
int header_size = 0;
+
+ TRACE("converting the symbols header\n");
pdb_convert_symbols_header(&symbols, &header_size, symbols_image);
+
+
switch (symbols.version)
{
case 0: /* VC 4.0 */
@@ -2193,12 +2231,15 @@
symbols.version, symbols.version);
}
+ TRACE("processing symbol imports\n");
pdb_process_symbol_imports(pcs, msc_dbg, &symbols, symbols_image, image, pdb_lookup, module_index);
/* Read global symbol table */
+ TRACE("reading global symbol table\n");
modimage = pdb_read_file(image, pdb_lookup, symbols.gsym_file);
if (modimage)
{
+ TRACE("dunno what this does\n");
codeview_snarf(msc_dbg, modimage, 0,
pdb_get_file_size(pdb_lookup, symbols.gsym_file), NULL);
@@ -2206,6 +2247,7 @@
}
/* Read per-module symbol / linenumber tables */
+ TRACE("reading symbols and line numbers\n");
file = symbols_image + header_size;
while (file - symbols_image < header_size + symbols.module_size)
{
@@ -2238,9 +2280,13 @@
file = (BYTE*)((DWORD)(file_name + strlen(file_name) + 1 + 3) & ~3);
}
}
- else
+ else{
+ ERR("could not read the PDB file. Loading imports instead\n");
+
pdb_process_symbol_imports(pcs, msc_dbg, NULL, NULL, image, pdb_lookup,
module_index);
+ }
+
ret = TRUE;
leave:
@@ -2261,10 +2307,23 @@
{
BOOL ret;
+
+
+
+
+
memset(cv_zmodules, 0, sizeof(cv_zmodules));
+
+ TRACE("initializing basic types\n");
codeview_init_basic_types(msc_dbg->module);
+
+ TRACE("processing the PDB file\n");
ret = pdb_process_internal(pcs, msc_dbg, pdb_lookup, -1);
+
+ TRACE("clearing type table\n");
codeview_clear_type_table();
+
+ TRACE("checking status\n");
if (ret)
{
msc_dbg->module->module.SymType = SymCv;
@@ -2282,7 +2341,13 @@
msc_dbg->module->module.TypeInfo = TRUE;
msc_dbg->module->module.SourceIndexed = TRUE;
msc_dbg->module->module.Publics = TRUE;
+
+ TRACE("saved load results\n");
}
+
+ else
+ TRACE("failed to load the PDB file\n");
+
return ret;
}
@@ -2302,6 +2367,7 @@
}
else
{
+ TRACE("opened .PDB file '%s'\n", pdb_lookup->filename);
pdb_init(pdb_lookup, image, TRUE);
pdb_free_lookup(pdb_lookup);
}
@@ -2423,6 +2489,10 @@
case CODEVIEW_NB10_SIG:
{
const CODEVIEW_PDB_DATA* pdb = (const CODEVIEW_PDB_DATA*)msc_dbg->root;
+
+ TRACE("found NB10 type of PDB file {filePos = %ld, timestamp = %ld, unknown = %ld, name = '%s'}\n",
+ pdb->filepos, pdb->timestamp, pdb->unknown, pdb->name);
+
pdb_lookup.filename = pdb->name;
pdb_lookup.kind = PDB_JG;
pdb_lookup.u.jg.timestamp = pdb->timestamp;
@@ -2471,6 +2541,7 @@
int i;
struct msc_debug_info msc_dbg;
+
msc_dbg.module = module;
msc_dbg.nsect = nsect;
msc_dbg.sectp = sectp;
@@ -2481,11 +2552,41 @@
{
ret = FALSE;
+
+ TRACE("{pcs = %p, module = %p, mapping = %p, sectp = %p, nsect = %ld, dbg = %p, nDbg = %d}\n",
+ pcs, module, mapping, sectp, nsect, dbg, nDbg);
+
+ for (i = 0; i < nDbg; i++){
+ TRACE("debugDirectory[%d]:\n"
+ " Characteristics = 0x%08lx\n"
+ " TimeDateStamp = %ld\n"
+ " MajorVersion = %d\n"
+ " MinorVersion = %d\n"
+ " Type = %ld\n"
+ " SizeOfData = %ld\n"
+ " AddressOfRawData = 0x%08lx\n"
+ " PointerToRawData = 0x%08lx\n",
+ i,
+ dbg[i].Characteristics,
+ dbg[i].TimeDateStamp,
+ dbg[i].MajorVersion,
+ dbg[i].MinorVersion,
+ dbg[i].Type,
+ dbg[i].SizeOfData,
+ dbg[i].AddressOfRawData,
+ dbg[i].PointerToRawData);
+ }
+
+
+
/* First, watch out for OMAP data */
+ TRACE("checking for OMAP data\n");
for (i = 0; i < nDbg; i++)
{
if (dbg[i].Type == IMAGE_DEBUG_TYPE_OMAP_FROM_SRC)
{
+ TRACE("found OMAP data in directory entry %d\n", i);
+
msc_dbg.nomap = dbg[i].SizeOfData / sizeof(OMAP_DATA);
msc_dbg.omapp = (const OMAP_DATA*)(mapping + dbg[i].PointerToRawData);
break;
@@ -2493,24 +2594,32 @@
}
/* Now, try to parse CodeView debug info */
+ TRACE("checking for codeview debug info\n");
for (i = 0; i < nDbg; i++)
{
if (dbg[i].Type == IMAGE_DEBUG_TYPE_CODEVIEW)
{
+ TRACE("found codeview debug info in directory entry %d\n", i);
+
msc_dbg.root = mapping + dbg[i].PointerToRawData;
if ((ret = codeview_process_info(pcs, &msc_dbg))) goto done;
}
}
/* If not found, try to parse COFF debug info */
+ TRACE("checking for COFF debug info\n");
for (i = 0; i < nDbg; i++)
{
if (dbg[i].Type == IMAGE_DEBUG_TYPE_COFF)
{
+ TRACE("found COFF debug info in directory entry %d\n", i);
+
msc_dbg.root = mapping + dbg[i].PointerToRawData;
if ((ret = coff_process_info(&msc_dbg))) goto done;
}
}
+
+ TRACE("no other supported debug info!\n");
done:
/* FIXME: this should be supported... this is the debug information for
* functions compiled without a frame pointer (FPO = frame pointer omission)
Index: path.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/path.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- path.c 30 Aug 2007 14:16:43 -0000 1.2
+++ path.c 30 Aug 2007 14:17:01 -0000 1.3
@@ -238,9 +238,9 @@
WIN32_FIND_DATAW fd;
unsigned pos;
BOOL found = FALSE;
- static const WCHAR S_AllW[] = {'*','.','*','\0'};
- static const WCHAR S_DotW[] = {'.','\0'};
- static const WCHAR S_DotDotW[] = {'.','\0'};
+ static const WCHAR S_AllW[] = {'*', '.', '*', '\0'};
+ static const WCHAR S_DotW[] = {'.', '\0'};
+ static const WCHAR S_DotDotW[] = {'.', '.', '\0'};
pos = strlenW(buffer);
if (buffer[pos - 1] != '\\') buffer[pos++] = '\\';
@@ -505,6 +505,7 @@
hProcess, debugstr_w(searchPath), debugstr_w(full_path),
id, two, three, flags, buffer, cb, user);
+
if (!pcs) return FALSE;
if (!searchPath) searchPath = pcs->search_path;
Index: pe_module.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/pe_module.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pe_module.c 30 Aug 2007 14:16:43 -0000 1.2
+++ pe_module.c 30 Aug 2007 14:17:01 -0000 1.3
@@ -59,11 +59,15 @@
{
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);
}
}
@@ -76,6 +80,8 @@
RtlImageRvaToVa(nth, (HMODULE)mapping, stabstr, NULL),
stabstrsize);
}
+
+ TRACE("%s the STABS debug info\n", ret ? "successfully loaded" : "failed to load");
return ret;
}
@@ -108,6 +114,7 @@
((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", tmp);
hdr = (const IMAGE_SEPARATE_DEBUG_HEADER*)dbg_mapping;
if (hdr->TimeDateStamp != timestamp)
{
@@ -176,6 +183,9 @@
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)
{
@@ -184,12 +194,16 @@
}
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);
@@ -302,6 +316,7 @@
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
@@ -310,8 +325,10 @@
*/
}
/* 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);
@@ -343,8 +360,13 @@
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);
@@ -364,16 +386,24 @@
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);
}
@@ -381,6 +411,7 @@
}
if (opened) CloseHandle(hFile);
+ TRACE("done loading the module '%s'\n", debugstr_w(name));
return module;
}
Index: stack.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/stack.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- stack.c 30 Aug 2007 14:16:43 -0000 1.2
+++ stack.c 30 Aug 2007 14:17:01 -0000 1.3
@@ -188,6 +188,7 @@
{
THREAD_BASIC_INFORMATION info;
+
if ((frame->AddrPC.Mode == AddrModeFlat) &&
(frame->AddrFrame.Mode != AddrModeFlat))
{
@@ -206,6 +207,7 @@
sizeof(info), NULL) == STATUS_SUCCESS)
{
curr_switch = (unsigned long)info.TebBaseAddress + FIELD_OFFSET(TEB, WOW32Reserved);
+
if (!sw_read_mem(cb, curr_switch, &next_switch, sizeof(next_switch)))
{
WARN("[start] Can't read TEB:WOW32Reserved\n");
@@ -270,13 +272,25 @@
ERR("[continue] not in 32-bit stack mode!\n");
do_switch = curr_switch && frame->AddrFrame.Offset >= curr_switch;
+ TRACE("do_switch = %s {curr_switch = 0x%08lx, frame->AddrFrame.Offset = 0x%08lx}\n",
+ do_switch ? "TRUE" : "FALSE",
+ curr_switch,
+ frame->AddrFrame.Offset);
}
else
{
assert(curr_mode == stm_16bit);
+ if (curr_mode != stm_16bit)
+ ERR("[continue] not in 16-bit stack mode!\n");
+
do_switch = curr_switch &&
frame->AddrFrame.Segment == SELECTOROF(curr_switch) &&
frame->AddrFrame.Offset >= OFFSETOF(curr_switch);
+ TRACE("do_switch = %s {curr_switch = 0x%08lx, frame->AddrFrame.Offset = 0x%08lx, frame->AddrFrame.Segment = 0x%08x}\n",
+ do_switch ? "TRUE" : "FALSE",
+ curr_switch,
+ frame->AddrFrame.Offset,
+ frame->AddrFrame.Segment);
}
if (do_switch)
@@ -380,20 +394,28 @@
frame->AddrPC = frame->AddrReturn;
if (curr_mode == stm_16bit)
{
+ DWORD addr;
+
+
frame->AddrStack.Offset = frame->AddrFrame.Offset + 2 * sizeof(WORD);
+ addr = sw_xlat_addr(cb, &frame->AddrFrame);
+
/* "pop up" previous BP value */
- if (!sw_read_mem(cb, sw_xlat_addr(cb, &frame->AddrFrame),
- &val, sizeof(WORD)))
+ if (!sw_read_mem(cb, addr, &val, sizeof(WORD))){
+ ERR("[continue16] could not read the BP value from 0x%08lx\n", addr);
goto done_err;
+ }
+
frame->AddrFrame.Offset = val;
}
else
{
frame->AddrStack.Offset = frame->AddrFrame.Offset + 2 * sizeof(DWORD);
/* "pop up" previous EBP value */
- if (!sw_read_mem(cb, frame->AddrFrame.Offset,
- &frame->AddrFrame.Offset, sizeof(DWORD)))
+ if (!sw_read_mem(cb, frame->AddrFrame.Offset, &frame->AddrFrame.Offset, sizeof(DWORD))){
+ ERR("[continue32] could not read the EBP value from 0x%08lx\n", frame->AddrFrame.Offset);
goto done_err;
+ }
}
}
}
@@ -403,12 +425,16 @@
int i;
p = sw_xlat_addr(cb, &frame->AddrFrame);
- if (!sw_read_mem(cb, p + sizeof(WORD), &val, sizeof(WORD)))
+ if (!sw_read_mem(cb, p + sizeof(WORD), &val, sizeof(WORD))){
+ ERR("[next16] could not read 16-bit return address\n");
goto done_err;
+ }
frame->AddrReturn.Offset = val;
/* get potential cs if a far call was used */
- if (!sw_read_mem(cb, p + 2 * sizeof(WORD), &val, sizeof(WORD)))
+ if (!sw_read_mem(cb, p + 2 * sizeof(WORD), &val, sizeof(WORD))){
+ ERR("[next16] could not read 16-bit return address segment\n");
goto done_err;
+ }
if (frame->AddrFrame.Offset & 1)
frame->AddrReturn.Segment = val; /* far call assumed */
else
@@ -536,6 +562,8 @@
return FALSE;
}
+
+ TRACE("copying stack frame info to a 32-bit frame\n");
addr_64to32(&frame64->AddrPC, &frame32.AddrPC);
addr_64to32(&frame64->AddrReturn, &frame32.AddrReturn);
addr_64to32(&frame64->AddrFrame, &frame32.AddrFrame);
@@ -549,6 +577,7 @@
frame32.Reserved[2] = (ULONG)frame64->Reserved[2];
/* we don't handle KdHelp */
+ TRACE("setting up callback frame\n");
swcb.hProcess = hProcess;
swcb.hThread = hThread;
swcb.is32 = FALSE;
@@ -558,7 +587,9 @@
swcb.u.s64.f_tabl_acs = (FunctionTableAccessRoutine) ? FunctionTableAccessRoutine : SymFunctionTableAccess64;
swcb.u.s64.f_modl_bas = (GetModuleBaseRoutine) ? GetModuleBaseRoutine : SymGetModuleBase64;
+ TRACE("performing 32-bit stack walk\n");
ret = stack_walk(&swcb, &frame32);
+ TRACE("done stack walk. Converting back...\n");
addr_32to64(&frame32.AddrPC, &frame64->AddrPC);
addr_32to64(&frame32.AddrReturn, &frame64->AddrReturn);
@@ -586,6 +617,7 @@
frame64->KdHelp.SystemRangeStart = 0xC0000000;
frame64->KdHelp.Reserved[0] /* KiUserExceptionDispatcher */ = 0xE0005000;
+ TRACE("done filling in stack frame\n");
return ret;
}
Index: symbol.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/symbol.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- symbol.c 30 Aug 2007 14:16:43 -0000 1.2
+++ symbol.c 30 Aug 2007 14:17:01 -0000 1.3
@@ -500,10 +500,15 @@
sym_info->info = (DWORD)sym;
sym_info->Reserved[0] = sym_info->Reserved[1] = 0;
+
if (!symt_get_info(sym, TI_GET_LENGTH, &size) &&
(!sym_info->TypeIndex ||
- !symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size)))
+ !symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size))){
+ ERR("couldn't get the size of the symbol\n");
size = 0;
+ }
+
+ TRACE("the symbol has a size of %lld bytes (as DWORD = %ld)\n", size, (DWORD)size);
sym_info->Size = (DWORD)size;
sym_info->ModBase = pair->requested->module.BaseOfImage;
sym_info->Flags = 0;
@@ -512,14 +517,17 @@
switch (sym->tag)
{
case SymTagData:
+ TRACE("the symbol is data\n");
{
const struct symt_data* data = (const struct symt_data*)sym;
switch (data->kind)
{
case DataIsParam:
+ TRACE("the symbol is a parameter\n");
sym_info->Flags |= SYMFLAG_PARAMETER;
/* fall through */
case DataIsLocal:
+ TRACE("the symbol is a local variable\n");
{
struct location loc = data->u.var;
@@ -550,11 +558,14 @@
}
break;
case DataIsGlobal:
+ TRACE("the symbol is global\n");
case DataIsFileStatic:
+ TRACE("the symbol is static\n");
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
sym_info->Register = 0;
break;
case DataIsConstant:
+ TRACE("the symbol is a constant\n");
sym_info->Flags |= SYMFLAG_VALUEPRESENT;
switch (data->u.value.n1.n2.vt)
{
@@ -577,39 +588,65 @@
}
break;
case SymTagPublicSymbol:
+ TRACE("the symbol is a public symbol\n");
sym_info->Flags |= SYMFLAG_EXPORT;
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
break;
case SymTagFunction:
+ TRACE("the symbol is a function\n");
sym_info->Flags |= SYMFLAG_FUNCTION;
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
break;
case SymTagThunk:
+ TRACE("the symbol is a thunk\n");
sym_info->Flags |= SYMFLAG_THUNK;
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
break;
default:
+ TRACE("the symbol's type is unknown\n");
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address);
sym_info->Register = 0;
break;
}
sym_info->Scope = 0; /* FIXME */
sym_info->Tag = sym->tag;
+
+ TRACE("trying to retrieve the name for the symbol %p\n", sym);
name = symt_get_name(sym);
+ TRACE("found the name '%s'\n", name);
+
if (sym_info->MaxNameLen)
{
+ TRACE("attempting to undecorate the function name\n");
if (sym->tag != SymTagPublicSymbol || !(dbghelp_options & SYMOPT_UNDNAME) ||
(sym_info->NameLen = UnDecorateSymbolName(name, sym_info->Name,
sym_info->MaxNameLen, UNDNAME_COMPLETE) == 0))
{
+ if (sym->tag != SymTagPublicSymbol || !(dbghelp_options & SYMOPT_UNDNAME) || sym_info->NameLen == 0)
+ TRACE("not undecorating the symbol '%s'\n", name);
+
+ else
+ ERR("could not undecorate the symbol '%s'\n", name);
+
sym_info->NameLen = min(strlen(name), sym_info->MaxNameLen - 1);
memcpy(sym_info->Name, name, sym_info->NameLen);
sym_info->Name[sym_info->NameLen] = '\0';
}
+
+ else
+ TRACE("undecorated the name to '%s'\n", sym_info->Name);
}
- TRACE_(dbghelp_symt)("%p => %s %u %s\n",
+
+ else
+ TRACE("sym_info->MaxNameLen was not set!\n");
+
+
+ TRACE("%p => %s %lu %s\n",
+ sym, sym_info->Name, sym_info->Size,
+ wine_dbgstr_longlong(sym_info->Address));
+ /*TRACE_(dbghelp_symt)("%p => %s %lu %s\n",
sym, sym_info->Name, sym_info->Size,
- wine_dbgstr_longlong(sym_info->Address));
+ wine_dbgstr_longlong(sym_info->Address));*/
}
struct sym_enum
@@ -1047,14 +1084,68 @@
struct module_pair pair;
struct symt_ht* sym;
+
+ TRACE("(hProcess = 0x%08x, Address = 0x%016llx, Displacement = %p, Symbol = %p)\n", hProcess, Address, Displacement, Symbol);
+ /*TRACE("Symbol->MaxNameLen = %lu\n", Symbol->MaxNameLen);
+ TRACE("SYMBOL_INFO struct (size = %lu, reportedSize = %lu):\n"
+ " SizeOfStruct = %lu\n"
+ " TypeIndex = %lu\n"
+ " Reserved[0] = %lu\n"
+ " Reserved[1] = %lu\n"
+ " info = %lu\n"
+ " Size = %lu\n"
+ " ModBase = %lu\n"
+ " Flags = %lu\n"
+ " Value = %lu\n"
+ " Address = %lu\n"
+ " Register = %lu\n"
+ " Scope = %lu\n"
+ " Tag = %lu\n"
+ " NameLen = %lu\n"
+ " MaxNameLen = %lu\n"
+ " Name[1] = %lu\n",
+ sizeof(SYMBOL_INFO), Symbol->SizeOfStruct,
+ (intptr_t)&Symbol->SizeOfStruct - (intptr_t)Symbol,
+ (intptr_t)&Symbol->TypeIndex - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Reserved[0] - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Reserved[1] - (intptr_t)Symbol,
+ (intptr_t)&Symbol->info - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Size - (intptr_t)Symbol,
+ (intptr_t)&Symbol->ModBase - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Flags - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Value - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Address - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Register - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Scope - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Tag - (intptr_t)Symbol,
+ (intptr_t)&Symbol->NameLen - (intptr_t)Symbol,
+ (intptr_t)&Symbol->MaxNameLen - (intptr_t)Symbol,
+ (intptr_t)&Symbol->Name[0] - (intptr_t)Symbol);*/
+
+
pair.pcs = process_find_by_handle(hProcess);
- if (!pair.pcs) return FALSE;
+ if (!pair.pcs){
+ ERR("the process 0x%08x has not been initialized\n", hProcess);
+ return FALSE;
+ }
+
+
pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN);
- if (!module_get_debug(&pair)) return FALSE;
- if ((sym = symt_find_nearest(pair.effective, Address)) == NULL) return FALSE;
+ if (!module_get_debug(&pair)){
+ ERR("could not find the module that contains the address 0x%016llx or it does not have debug info\n", Address);
+ return FALSE;
+ }
+
+
+ if ((sym = symt_find_nearest(pair.effective, Address)) == NULL){
+ ERR("could not find the nearest symbol to the address 0x%016llx\n", Address);
+ return FALSE;
+ }
+
symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol);
*Displacement = Address - Symbol->Address;
+ TRACE("found the symbol '%s' near address 0x%016llx {displacement = 0x%016llx}\n", Symbol->Name, Address, *Displacement);
return TRUE;
}