dbghelp: In find_nearest, now return the symbol instead of its index in module->sorttable.
This commit is contained in:
parent
08712bc3a9
commit
4806320b48
|
@ -485,7 +485,8 @@ extern BOOL dwarf2_parse(struct module* module, unsigned long load_offse
|
|||
/* 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);
|
||||
|
|
|
@ -1700,15 +1700,15 @@ static void dwarf2_set_line_number(struct module* module, unsigned long address,
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -543,7 +543,7 @@ static int elf_new_wine_thunks(struct module* module, struct hash_table* ht_symt
|
|||
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 module* module, struct hash_table* ht_symt
|
|||
{
|
||||
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 module* module, struct hash_table* ht_symt
|
|||
*/
|
||||
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 module* module, struct hash_table* ht_symt
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ struct symt_public* symt_new_public(struct module* module,
|
|||
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* 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* module, DWORD addr)
|
|||
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* module, DWORD addr)
|
|||
}
|
||||
/* 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 process* pcs, const char* mask,
|
|||
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 process* pcs, const char* mask,
|
|||
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, DWORD64 Address,
|
|||
{
|
||||
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 hProcess, DWORD dwAddr,
|
|||
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 hProcess, DWORD dwAddr,
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue