Eric Pouech : dbghelp: In find_nearest,
now return the symbol instead of its index in module->sorttable.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Dec 6 05:49:00 CST 2006
Module: wine
Branch: master
Commit: 4806320b4829c7007fce3d796fbe6cef9682d2a8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4806320b4829c7007fce3d796fbe6cef9682d2a8
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Tue Dec 5 22:13:23 2006 +0100
dbghelp: In find_nearest, now return the symbol instead of its index in module->sorttable.
---
dlls/dbghelp/dbghelp_private.h | 3 ++-
dlls/dbghelp/dwarf.c | 8 ++++----
dlls/dbghelp/elf_module.c | 21 ++++++++++-----------
dlls/dbghelp/symbol.c | 34 ++++++++++++++--------------------
4 files changed, 30 insertions(+), 36 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 19864db..f575bcf 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -485,7 +485,8 @@ extern BOOL dwarf2_parse(struct
/* symbol.c */
extern const char* symt_get_name(const struct symt* sym);
extern int symt_cmp_addr(const void* p1, const void* p2);
-extern int symt_find_nearest(struct module* module, DWORD addr);
+extern struct symt_ht*
+ symt_find_nearest(struct module* module, DWORD addr);
extern struct symt_compiland*
symt_new_compiland(struct module* module, unsigned long address,
unsigned src_idx);
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index aaab3fb..a3af469 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -1700,15 +1700,15 @@ static void dwarf2_set_line_number(struc
struct vector* v, unsigned file, unsigned line)
{
struct symt_function* func;
- int idx;
+ struct symt_ht* symt;
unsigned* psrc;
if (!file || !(psrc = vector_at(v, file - 1))) return;
TRACE("%s %lx %s %u\n", module->module.ModuleName, address, source_get(module, *psrc), line);
- if ((idx = symt_find_nearest(module, address)) == -1 ||
- module->addr_sorttab[idx]->symt.tag != SymTagFunction) return;
- func = (struct symt_function*)module->addr_sorttab[idx];
+ if (!(symt = symt_find_nearest(module, address)) ||
+ symt->symt.tag != SymTagFunction) return;
+ func = (struct symt_function*)symt;
symt_add_func_line(module, func, *psrc, line, address - func->address);
}
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 78a8962..9a90d43 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -543,7 +543,7 @@ static int elf_new_wine_thunks(struct mo
struct hash_table_iter hti;
struct symtab_elt* ste;
DWORD addr;
- int idx;
+ struct symt_ht* symt;
hash_table_iter_init(ht_symtab, &hti, NULL);
while ((ste = hash_table_iter_up(&hti)))
@@ -562,11 +562,10 @@ static int elf_new_wine_thunks(struct mo
{
ULONG64 ref_addr;
- idx = symt_find_nearest(module, addr);
- if (idx != -1)
- symt_get_info(&module->addr_sorttab[idx]->symt,
- TI_GET_ADDRESS, &ref_addr);
- if (idx == -1 || addr != ref_addr)
+ symt = symt_find_nearest(module, addr);
+ if (symt)
+ symt_get_info(&symt->symt, TI_GET_ADDRESS, &ref_addr);
+ if (!symt || addr != ref_addr)
{
/* creating public symbols for all the ELF symbols which haven't been
* used yet (ie we have no debug information on them)
@@ -596,14 +595,14 @@ static int elf_new_wine_thunks(struct mo
*/
module->sortlist_valid = TRUE;
}
- else if (strcmp(ste->ht_elt.name, module->addr_sorttab[idx]->hash_elt.name))
+ else if (strcmp(ste->ht_elt.name, symt->hash_elt.name))
{
ULONG64 xaddr = 0, xsize = 0;
DWORD kind = -1;
- symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_ADDRESS, &xaddr);
- symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_LENGTH, &xsize);
- symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_DATAKIND, &kind);
+ symt_get_info(&symt->symt, TI_GET_ADDRESS, &xaddr);
+ symt_get_info(&symt->symt, TI_GET_LENGTH, &xsize);
+ symt_get_info(&symt->symt, TI_GET_DATAKIND, &kind);
/* If none of symbols has a correct size, we consider they are both markers
* Hence, we can silence this warning
@@ -615,7 +614,7 @@ static int elf_new_wine_thunks(struct mo
FIXME("Duplicate in %s: %s<%08x-%08x> %s<%s-%s>\n",
module->module.ModuleName,
ste->ht_elt.name, addr, ste->symp->st_size,
- module->addr_sorttab[idx]->hash_elt.name,
+ symt->hash_elt.name,
wine_dbgstr_longlong(xaddr), wine_dbgstr_longlong(xsize));
}
}
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c
index b318bb7..f4b0612 100644
--- a/dlls/dbghelp/symbol.c
+++ b/dlls/dbghelp/symbol.c
@@ -154,7 +154,7 @@ struct symt_public* symt_new_public(stru
TRACE_(dbghelp_symt)("Adding public symbol %s:%s @%lx\n",
module->module.ModuleName, name, address);
if ((dbghelp_options & SYMOPT_AUTO_PUBLICS) &&
- symt_find_nearest(module, address) != -1)
+ symt_find_nearest(module, address) != NULL)
return NULL;
if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
{
@@ -648,14 +648,14 @@ static BOOL resort_symbols(struct module
}
/* assume addr is in module */
-int symt_find_nearest(struct module* module, DWORD addr)
+struct symt_ht* symt_find_nearest(struct module* module, DWORD addr)
{
int mid, high, low;
ULONG64 ref_addr, ref_size;
if (!module->sortlist_valid || !module->addr_sorttab)
{
- if (!resort_symbols(module)) return -1;
+ if (!resort_symbols(module)) return NULL;
}
/*
@@ -665,13 +665,13 @@ int symt_find_nearest(struct module* mod
high = module->module.NumSyms;
symt_get_info(&module->addr_sorttab[0]->symt, TI_GET_ADDRESS, &ref_addr);
- if (addr < ref_addr) return -1;
+ if (addr < ref_addr) return NULL;
if (high)
{
symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_ADDRESS, &ref_addr);
if (!symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_LENGTH, &ref_size) || !ref_size)
ref_size = 0x1000; /* arbitrary value */
- if (addr >= ref_addr + ref_size) return -1;
+ if (addr >= ref_addr + ref_size) return NULL;
}
while (high > low + 1)
@@ -703,12 +703,12 @@ int symt_find_nearest(struct module* mod
}
/* finally check that we fit into the found symbol */
symt_get_info(&module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr);
- if (addr < ref_addr) return -1;
+ if (addr < ref_addr) return NULL;
if (!symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_LENGTH, &ref_size) || !ref_size)
ref_size = 0x1000; /* arbitrary value */
- if (addr >= ref_addr + ref_size) return -1;
+ if (addr >= ref_addr + ref_size) return NULL;
- return low;
+ return module->addr_sorttab[low];
}
static BOOL symt_enum_locals_helper(struct module_pair* pair,
@@ -758,7 +758,6 @@ static BOOL symt_enum_locals(struct proc
struct module_pair pair;
struct symt_ht* sym;
DWORD pc = pcs->ctx_frame.InstructionOffset;
- int idx;
se->sym_info->SizeOfStruct = sizeof(*se->sym_info);
se->sym_info->MaxNameLen = sizeof(se->buffer) - sizeof(SYMBOL_INFO);
@@ -766,9 +765,8 @@ static BOOL symt_enum_locals(struct proc
pair.pcs = pcs;
pair.requested = module_find_by_addr(pair.pcs, pc, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE;
- if ((idx = symt_find_nearest(pair.effective, pc)) == -1) return FALSE;
+ if ((sym = symt_find_nearest(pair.effective, pc)) == NULL) return FALSE;
- sym = pair.effective->addr_sorttab[idx];
if (sym->symt.tag == SymTagFunction)
{
BOOL ret;
@@ -998,15 +996,12 @@ BOOL WINAPI SymFromAddr(HANDLE hProcess,
{
struct module_pair pair;
struct symt_ht* sym;
- int idx;
pair.pcs = process_find_by_handle(hProcess);
if (!pair.pcs) return FALSE;
pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE;
- if ((idx = symt_find_nearest(pair.effective, Address)) == -1) return FALSE;
-
- sym = pair.effective->addr_sorttab[idx];
+ if ((sym = symt_find_nearest(pair.effective, Address)) == NULL) return FALSE;
symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol);
*Displacement = Address - Symbol->Address;
@@ -1252,7 +1247,7 @@ BOOL WINAPI SymGetLineFromAddr(HANDLE hP
PDWORD pdwDisplacement, PIMAGEHLP_LINE Line)
{
struct module_pair pair;
- int idx;
+ struct symt_ht* symt;
TRACE("%p %08x %p %p\n", hProcess, dwAddr, pdwDisplacement, Line);
@@ -1262,11 +1257,10 @@ BOOL WINAPI SymGetLineFromAddr(HANDLE hP
if (!pair.pcs) return FALSE;
pair.requested = module_find_by_addr(pair.pcs, dwAddr, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE;
- if ((idx = symt_find_nearest(pair.effective, dwAddr)) == -1) return FALSE;
+ if ((symt = symt_find_nearest(pair.effective, dwAddr)) == NULL) return FALSE;
- if (pair.effective->addr_sorttab[idx]->symt.tag != SymTagFunction) return FALSE;
- if (!symt_fill_func_line_info(pair.effective,
- (struct symt_function*)pair.effective->addr_sorttab[idx],
+ if (symt->symt.tag != SymTagFunction) return FALSE;
+ if (!symt_fill_func_line_info(pair.effective, (struct symt_function*)symt,
dwAddr, Line)) return FALSE;
*pdwDisplacement = dwAddr - Line->Address;
return TRUE;
More information about the wine-cvs
mailing list