CVS: winex/dlls/dbghelp symbol.c,1.5,1.6
[email protected] 30 Aug 2007 14:19:59 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/dlls/dbghelp symbol.c,1.5,1.6Update of /var/lib/cvsd/cvsroot/winex/dlls/dbghelp
In directory agravaine:/tmp/cvs-serv19772/dlls/dbghelp
Modified Files:
symbol.c
Log Message:
added line number error checking and fixed a symbol lookup bug
trac #1970
- added some more error checking in the SymGetLineFromAddr*() functions
- fixed a small bug in symbol size lookup - some globals and locals didn't have sizes and their size was being reported as the size of the previous symbol. They were all being reported as overlapping symbols (which was wrong)
- added support for looking up symbols from modules with only public symbols
- fixed some compile warnings
Index: symbol.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dbghelp/symbol.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- symbol.c 30 Aug 2007 14:19:24 -0000 1.5
+++ symbol.c 30 Aug 2007 14:19:57 -0000 1.6
@@ -783,12 +783,14 @@
for (i = 0; i < (signed)module->num_sorttab;){
/* retrieve the address and size of the symbol */
+ size = 1;
symt_get_info(&module->addr_sorttab[i].symt->symt, TI_GET_ADDRESS, &addr);
symt_get_info(&module->addr_sorttab[i].symt->symt, TI_GET_LENGTH, &size);
for (j = k = i + 1; j < (signed)module->num_sorttab; j++){
/* retrieve the address and size of the [potentially] overlapping symbol */
+ size2 = 1;
symt_get_info(&module->addr_sorttab[j].symt->symt, TI_GET_ADDRESS, &addr2);
symt_get_info(&module->addr_sorttab[j].symt->symt, TI_GET_LENGTH, &size2);
@@ -803,10 +805,11 @@
else{
/* this symbol's address starts within it's container symbol's address space, but it's address
- space ends outside the container's address space. Theoretically this shouldn't happen, but
- we'll add a loud fixme here just to make sure */
- FIXME("!!! symbol %d overlaps the end of its container symbol {addr = 0x%08llx - 0x%08llx (size = 0x%llx), addr2 = 0x%08llx - 0x%08llx (size2 = 0x%llx)}\n",
- j,
+ space ends outside the container's address space. Theoretically this shouldn't happen so
+ we'll just stick a loud FIXME here. */
+ FIXME("!!! symbol '%s'(#%d) overlaps the end of its container symbol '%s' (#%d) {addr = 0x%08llx - 0x%08llx (size = 0x%llx), addr2 = 0x%08llx - 0x%08llx (size2 = 0x%llx)}\n",
+ symt_get_name(&module->addr_sorttab[j].symt->symt), j,
+ symt_get_name(&module->addr_sorttab[i].symt->symt), i,
addr, addr + size, size,
addr2, addr2 + size2, size2);
FIXME("!!! these symbols may not be able to be found!\n");
@@ -1432,8 +1435,21 @@
pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN);
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;
+ pair.effective = pair.requested;
+
+ /* no module found => fail */
+ if (pair.effective == NULL){
+ ERR("could not find the module that contains the address 0x%08llx\n", Address);
+
+ return FALSE;
+ }
+
+ /* no symbols found in the module => fail */
+ if (pair.effective->ht_symbols.num_elts == 0){
+ ERR("the module at 0x%08llx ('%s') does not have any symbols loaded for it\n", pair.effective->module.BaseOfImage, pair.effective->module_name);
+
+ return FALSE;
+ }
}
@@ -1498,7 +1514,7 @@
Symbol->Size = si->Size;
Symbol->Flags = si->Flags;
len = min(Symbol->MaxNameLength, si->MaxNameLen);
- lstrcpynA(Symbol->Name, si->Name, len);
+ lstrcpynA(Symbol->Name, si->Name, (int)len);
return TRUE;
}
@@ -1526,7 +1542,7 @@
Symbol->Size = si->Size;
Symbol->Flags = si->Flags;
len = min(Symbol->MaxNameLength, si->MaxNameLen);
- lstrcpynA(Symbol->Name, si->Name, len);
+ lstrcpynA(Symbol->Name, si->Name, (int)len);
return TRUE;
}
@@ -1616,7 +1632,7 @@
Symbol->Size = si->Size;
Symbol->Flags = si->Flags;
len = min(Symbol->MaxNameLength, si->MaxNameLen);
- lstrcpynA(Symbol->Name, si->Name, len);
+ lstrcpynA(Symbol->Name, si->Name, (int)len);
return TRUE;
}
@@ -1692,19 +1708,52 @@
struct module_pair pair;
struct symt_ht* symt;
- TRACE("%x %08lx %p %p\n", hProcess, dwAddr, pdwDisplacement, Line);
+ TRACE("(hProcess = 0x%08x, dwAddr = %08lx, pdwDisplacement = 0x%p, Line = 0x%p)\n", hProcess, dwAddr, pdwDisplacement, Line);
+
+ if (Line->SizeOfStruct < sizeof(*Line)){
+ WARN("the destination struct is too small {sizeOfStruct = %ld, sizeof(*Line) = %lu}\n", Line->SizeOfStruct, sizeof(*Line));
+
+ return FALSE;
+ }
- if (Line->SizeOfStruct < sizeof(*Line)) return FALSE;
pair.pcs = process_find_by_handle(hProcess);
- if (!pair.pcs) return FALSE;
+ if (!pair.pcs){
+ WARN("could not find the process for 0x%08x\n", hProcess);
+
+ return FALSE;
+ }
+
+
pair.requested = module_find_by_addr(pair.pcs, dwAddr, DMT_UNKNOWN);
- if (!module_get_debug(&pair)) return FALSE;
- if ((symt = symt_find_nearest(pair.effective, dwAddr)) == NULL) return FALSE;
- if (symt->symt.tag != SymTagFunction) return FALSE;
- if (!symt_fill_func_line_info(pair.effective, (struct symt_function*)symt,
- dwAddr, Line)) return FALSE;
+ if (!module_get_debug(&pair)){
+ WARN("this module does not have debug information\n");
+
+ return FALSE;
+ }
+
+
+ if ((symt = symt_find_nearest(pair.effective, dwAddr)) == NULL){
+ WARN("could not find the function for the address 0x%08lx\n", dwAddr);
+
+ return FALSE;
+ }
+
+
+ if (symt->symt.tag != SymTagFunction){
+ WARN("the symbol that was found for 0x%08lx is not a function\n", dwAddr);
+
+ return FALSE;
+ }
+
+
+ if (!symt_fill_func_line_info(pair.effective, (struct symt_function*)symt, dwAddr, Line)){
+ WARN("could not fill the line info for the function %s()\n", symt_get_name(&symt->symt));
+
+ return FALSE;
+ }
+
*pdwDisplacement = dwAddr - Line->Address;
return TRUE;
}
@@ -1726,7 +1775,9 @@
* copy_line_W64_from_32 (internal)
*
*/
-static void copy_line_W64_from_32(struct process* pcs, IMAGEHLP_LINEW64* l64, const IMAGEHLP_LINE* l32)
+static void copy_line_W64_from_32(struct process* pcs,
+ IMAGEHLP_LINEW64* l64,
+ const IMAGEHLP_LINE* l32)
{
unsigned len;
@@ -1760,11 +1811,28 @@
{
IMAGEHLP_LINE line32;
- if (Line->SizeOfStruct < sizeof(*Line)) return FALSE;
- if (!validate_addr64(dwAddr)) return FALSE;
+
+ if (Line->SizeOfStruct < sizeof(*Line)) {
+ WARN("the destination struct is too small!\n");
+
+ return FALSE;
+ }
+
+
+ if (!validate_addr64(dwAddr)){
+ WARN("passed a 64-bit address!\n");
+
+ return FALSE;
+ }
+
+
line32.SizeOfStruct = sizeof(line32);
- if (!SymGetLineFromAddr(hProcess, (DWORD)dwAddr, pdwDisplacement, &line32))
+ if (!SymGetLineFromAddr(hProcess, (DWORD)dwAddr, pdwDisplacement, &line32)){
+ WARN("could not get the line number info for the address 0x%08llx\n", dwAddr);
+
return FALSE;
+ }
+
copy_line_64_from_32(Line, &line32);
return TRUE;
}
@@ -1964,9 +2032,9 @@
if (!UnDecoratedName) return 0;
if (!p_undname(UnDecoratedName, DecoratedName, UndecoratedLength,
- und_alloc, und_free, Flags))
+ und_alloc, und_free, (unsigned short)Flags))
return 0;
- return strlen(UnDecoratedName);
+ return (DWORD)strlen(UnDecoratedName);
}
/******************************************************************