dbghelp: In find_nearest, now return the symbol instead of its index in module->sorttable.

oldstable
Eric Pouech 2006-12-05 22:13:23 +01:00 committed by Alexandre Julliard
parent 08712bc3a9
commit 4806320b48
4 changed files with 30 additions and 36 deletions

View File

@ -485,7 +485,8 @@ extern BOOL dwarf2_parse(struct module* module, unsigned long load_offse
/* symbol.c */ /* symbol.c */
extern const char* symt_get_name(const struct symt* sym); extern const char* symt_get_name(const struct symt* sym);
extern int symt_cmp_addr(const void* p1, const void* p2); 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* extern struct symt_compiland*
symt_new_compiland(struct module* module, unsigned long address, symt_new_compiland(struct module* module, unsigned long address,
unsigned src_idx); unsigned src_idx);

View File

@ -1700,15 +1700,15 @@ static void dwarf2_set_line_number(struct module* module, unsigned long address,
struct vector* v, unsigned file, unsigned line) struct vector* v, unsigned file, unsigned line)
{ {
struct symt_function* func; struct symt_function* func;
int idx; struct symt_ht* symt;
unsigned* psrc; unsigned* psrc;
if (!file || !(psrc = vector_at(v, file - 1))) return; if (!file || !(psrc = vector_at(v, file - 1))) return;
TRACE("%s %lx %s %u\n", module->module.ModuleName, address, source_get(module, *psrc), line); TRACE("%s %lx %s %u\n", module->module.ModuleName, address, source_get(module, *psrc), line);
if ((idx = symt_find_nearest(module, address)) == -1 || if (!(symt = symt_find_nearest(module, address)) ||
module->addr_sorttab[idx]->symt.tag != SymTagFunction) return; symt->symt.tag != SymTagFunction) return;
func = (struct symt_function*)module->addr_sorttab[idx]; func = (struct symt_function*)symt;
symt_add_func_line(module, func, *psrc, line, address - func->address); symt_add_func_line(module, func, *psrc, line, address - func->address);
} }

View File

@ -543,7 +543,7 @@ static int elf_new_wine_thunks(struct module* module, struct hash_table* ht_symt
struct hash_table_iter hti; struct hash_table_iter hti;
struct symtab_elt* ste; struct symtab_elt* ste;
DWORD addr; DWORD addr;
int idx; struct symt_ht* symt;
hash_table_iter_init(ht_symtab, &hti, NULL); hash_table_iter_init(ht_symtab, &hti, NULL);
while ((ste = hash_table_iter_up(&hti))) while ((ste = hash_table_iter_up(&hti)))
@ -562,11 +562,10 @@ static int elf_new_wine_thunks(struct module* module, struct hash_table* ht_symt
{ {
ULONG64 ref_addr; ULONG64 ref_addr;
idx = symt_find_nearest(module, addr); symt = symt_find_nearest(module, addr);
if (idx != -1) if (symt)
symt_get_info(&module->addr_sorttab[idx]->symt, symt_get_info(&symt->symt, TI_GET_ADDRESS, &ref_addr);
TI_GET_ADDRESS, &ref_addr); if (!symt || addr != ref_addr)
if (idx == -1 || addr != ref_addr)
{ {
/* creating public symbols for all the ELF symbols which haven't been /* creating public symbols for all the ELF symbols which haven't been
* used yet (ie we have no debug information on them) * used yet (ie we have no debug information on them)
@ -596,14 +595,14 @@ static int elf_new_wine_thunks(struct module* module, struct hash_table* ht_symt
*/ */
module->sortlist_valid = TRUE; 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; ULONG64 xaddr = 0, xsize = 0;
DWORD kind = -1; DWORD kind = -1;
symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_ADDRESS, &xaddr); symt_get_info(&symt->symt, TI_GET_ADDRESS, &xaddr);
symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_LENGTH, &xsize); symt_get_info(&symt->symt, TI_GET_LENGTH, &xsize);
symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_DATAKIND, &kind); symt_get_info(&symt->symt, TI_GET_DATAKIND, &kind);
/* If none of symbols has a correct size, we consider they are both markers /* If none of symbols has a correct size, we consider they are both markers
* Hence, we can silence this warning * Hence, we can silence this warning
@ -615,7 +614,7 @@ static int elf_new_wine_thunks(struct module* module, struct hash_table* ht_symt
FIXME("Duplicate in %s: %s<%08x-%08x> %s<%s-%s>\n", FIXME("Duplicate in %s: %s<%08x-%08x> %s<%s-%s>\n",
module->module.ModuleName, module->module.ModuleName,
ste->ht_elt.name, addr, ste->symp->st_size, 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)); wine_dbgstr_longlong(xaddr), wine_dbgstr_longlong(xsize));
} }
} }

View File

@ -154,7 +154,7 @@ struct symt_public* symt_new_public(struct module* module,
TRACE_(dbghelp_symt)("Adding public symbol %s:%s @%lx\n", TRACE_(dbghelp_symt)("Adding public symbol %s:%s @%lx\n",
module->module.ModuleName, name, address); module->module.ModuleName, name, address);
if ((dbghelp_options & SYMOPT_AUTO_PUBLICS) && if ((dbghelp_options & SYMOPT_AUTO_PUBLICS) &&
symt_find_nearest(module, address) != -1) symt_find_nearest(module, address) != NULL)
return NULL; return NULL;
if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
{ {
@ -648,14 +648,14 @@ static BOOL resort_symbols(struct module* module)
} }
/* assume addr is in 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; int mid, high, low;
ULONG64 ref_addr, ref_size; ULONG64 ref_addr, ref_size;
if (!module->sortlist_valid || !module->addr_sorttab) 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* module, DWORD addr)
high = module->module.NumSyms; high = module->module.NumSyms;
symt_get_info(&module->addr_sorttab[0]->symt, TI_GET_ADDRESS, &ref_addr); 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) if (high)
{ {
symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_ADDRESS, &ref_addr); 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) if (!symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_LENGTH, &ref_size) || !ref_size)
ref_size = 0x1000; /* arbitrary value */ 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) while (high > low + 1)
@ -703,12 +703,12 @@ int symt_find_nearest(struct module* module, DWORD addr)
} }
/* finally check that we fit into the found symbol */ /* finally check that we fit into the found symbol */
symt_get_info(&module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr); 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) if (!symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_LENGTH, &ref_size) || !ref_size)
ref_size = 0x1000; /* arbitrary value */ 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, static BOOL symt_enum_locals_helper(struct module_pair* pair,
@ -758,7 +758,6 @@ static BOOL symt_enum_locals(struct process* pcs, const char* mask,
struct module_pair pair; struct module_pair pair;
struct symt_ht* sym; struct symt_ht* sym;
DWORD pc = pcs->ctx_frame.InstructionOffset; DWORD pc = pcs->ctx_frame.InstructionOffset;
int idx;
se->sym_info->SizeOfStruct = sizeof(*se->sym_info); se->sym_info->SizeOfStruct = sizeof(*se->sym_info);
se->sym_info->MaxNameLen = sizeof(se->buffer) - sizeof(SYMBOL_INFO); se->sym_info->MaxNameLen = sizeof(se->buffer) - sizeof(SYMBOL_INFO);
@ -766,9 +765,8 @@ static BOOL symt_enum_locals(struct process* pcs, const char* mask,
pair.pcs = pcs; pair.pcs = pcs;
pair.requested = module_find_by_addr(pair.pcs, pc, DMT_UNKNOWN); pair.requested = module_find_by_addr(pair.pcs, pc, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE; 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) if (sym->symt.tag == SymTagFunction)
{ {
BOOL ret; BOOL ret;
@ -998,15 +996,12 @@ BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address,
{ {
struct module_pair pair; struct module_pair pair;
struct symt_ht* sym; struct symt_ht* sym;
int idx;
pair.pcs = process_find_by_handle(hProcess); pair.pcs = process_find_by_handle(hProcess);
if (!pair.pcs) return FALSE; if (!pair.pcs) return FALSE;
pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN); pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE; if (!module_get_debug(&pair)) return FALSE;
if ((idx = symt_find_nearest(pair.effective, Address)) == -1) return FALSE; if ((sym = symt_find_nearest(pair.effective, Address)) == NULL) return FALSE;
sym = pair.effective->addr_sorttab[idx];
symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol); symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol);
*Displacement = Address - Symbol->Address; *Displacement = Address - Symbol->Address;
@ -1252,7 +1247,7 @@ BOOL WINAPI SymGetLineFromAddr(HANDLE hProcess, DWORD dwAddr,
PDWORD pdwDisplacement, PIMAGEHLP_LINE Line) PDWORD pdwDisplacement, PIMAGEHLP_LINE Line)
{ {
struct module_pair pair; struct module_pair pair;
int idx; struct symt_ht* symt;
TRACE("%p %08x %p %p\n", hProcess, dwAddr, pdwDisplacement, Line); TRACE("%p %08x %p %p\n", hProcess, dwAddr, pdwDisplacement, Line);
@ -1262,11 +1257,10 @@ BOOL WINAPI SymGetLineFromAddr(HANDLE hProcess, DWORD dwAddr,
if (!pair.pcs) return FALSE; if (!pair.pcs) return FALSE;
pair.requested = module_find_by_addr(pair.pcs, dwAddr, DMT_UNKNOWN); pair.requested = module_find_by_addr(pair.pcs, dwAddr, DMT_UNKNOWN);
if (!module_get_debug(&pair)) return FALSE; 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->symt.tag != SymTagFunction) return FALSE;
if (!symt_fill_func_line_info(pair.effective, if (!symt_fill_func_line_info(pair.effective, (struct symt_function*)symt,
(struct symt_function*)pair.effective->addr_sorttab[idx],
dwAddr, Line)) return FALSE; dwAddr, Line)) return FALSE;
*pdwDisplacement = dwAddr - Line->Address; *pdwDisplacement = dwAddr - Line->Address;
return TRUE; return TRUE;