dbghelp: Make symt_add_func_line() last parameter an absolute address.

It used to be an offset to the start of function, but it's actually
stored as an absolute address afterwards. This avoids unnecessary
computations.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Eric Pouech 2021-10-29 15:37:04 +02:00 committed by Alexandre Julliard
parent 0187675065
commit 1c5989465e
5 changed files with 10 additions and 16 deletions

View File

@ -421,16 +421,11 @@ DECLSPEC_HIDDEN BOOL coff_process_info(const struct msc_debug_info* msc_dbg)
{ {
if (coff_files.files[j].entries[l+1]->tag == SymTagFunction) if (coff_files.files[j].entries[l+1]->tag == SymTagFunction)
{ {
/*
* Add the line number. This is always relative to the
* start of the function, so we need to subtract that offset
* first.
*/
symt_add_func_line(msc_dbg->module, symt_add_func_line(msc_dbg->module,
(struct symt_function*)coff_files.files[j].entries[l+1], (struct symt_function*)coff_files.files[j].entries[l+1],
coff_files.files[j].compiland->source, coff_files.files[j].compiland->source,
linepnt->Linenumber, linepnt->Linenumber,
msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress - addr); msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress);
} }
break; break;
} }

View File

@ -2526,7 +2526,7 @@ static void dwarf2_set_line_number(struct module* module, ULONG_PTR address,
if (symt_check_tag(&symt->symt, SymTagFunction)) if (symt_check_tag(&symt->symt, SymTagFunction))
{ {
func = (struct symt_function*)symt; 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);
} }
} }

View File

@ -1454,8 +1454,7 @@ static void codeview_snarf_linetab(const struct msc_debug_info* msc_dbg, const B
break; break;
} }
} }
symt_add_func_line(msc_dbg->module, func, source, symt_add_func_line(msc_dbg->module, func, source, linenos[k], addr);
linenos[k], addr - func->address);
} }
} }
} }
@ -1519,7 +1518,7 @@ static void codeview_snarf_linetab2(const struct msc_debug_info* msc_dbg, const
{ {
symt_add_func_line(msc_dbg->module, func, source, symt_add_func_line(msc_dbg->module, func, source,
lines_blk->l[i].lineno ^ 0x80000000, lines_blk->l[i].lineno ^ 0x80000000,
lines_blk->l[i].offset); func->address + lines_blk->l[i].offset);
} }
break; break;
case LT2_FILES_BLOCK: /* skip */ case LT2_FILES_BLOCK: /* skip */

View File

@ -1168,7 +1168,7 @@ static void pending_flush(struct pending_list* pending, struct module* module,
if (module->type == DMT_MACHO) if (module->type == DMT_MACHO)
pending->objs[i].u.line.offset -= func->address - pending->objs[i].u.line.load_offset; pending->objs[i].u.line.offset -= func->address - pending->objs[i].u.line.load_offset;
symt_add_func_line(module, func, pending->objs[i].u.line.source_idx, symt_add_func_line(module, func, pending->objs[i].u.line.source_idx,
pending->objs[i].u.line.line_num, pending->objs[i].u.line.offset); pending->objs[i].u.line.line_num, func->address + pending->objs[i].u.line.offset);
break; break;
default: default:
ERR("Unknown pending object tag %u\n", (unsigned)pending->objs[i].tag); ERR("Unknown pending object tag %u\n", (unsigned)pending->objs[i].tag);
@ -1492,7 +1492,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset,
if (module->type == DMT_MACHO) if (module->type == DMT_MACHO)
offset -= curr_func->address - load_offset; offset -= curr_func->address - load_offset;
symt_add_func_line(module, curr_func, source_idx, symt_add_func_line(module, curr_func, source_idx,
stab_ptr->n_desc, offset); stab_ptr->n_desc, curr_func->address + offset);
} }
else pending_add_line(&pending_func, source_idx, stab_ptr->n_desc, else pending_add_line(&pending_func, source_idx, stab_ptr->n_desc,
n_value, load_offset); n_value, load_offset);

View File

@ -391,7 +391,7 @@ struct symt_inlinesite* symt_new_inlinesite(struct module* module,
} }
void symt_add_func_line(struct module* module, struct symt_function* func, void symt_add_func_line(struct module* module, struct symt_function* func,
unsigned source_idx, int line_num, ULONG_PTR offset) unsigned source_idx, int line_num, ULONG_PTR addr)
{ {
struct line_info* dli; struct line_info* dli;
unsigned vlen; unsigned vlen;
@ -401,8 +401,8 @@ void symt_add_func_line(struct module* module, struct symt_function* func,
if (func == NULL || !(dbghelp_options & SYMOPT_LOAD_LINES)) return; if (func == NULL || !(dbghelp_options & SYMOPT_LOAD_LINES)) return;
TRACE_(dbghelp_symt)("(%p)%s:%lx %s:%u\n", TRACE_(dbghelp_symt)("(%p)%s:%Ix %s:%u\n",
func, func->hash_elt.name, offset, func, func->hash_elt.name, addr,
source_get(module, source_idx), line_num); source_get(module, source_idx), line_num);
assert(func->symt.tag == SymTagFunction || func->symt.tag == SymTagInlineSite); assert(func->symt.tag == SymTagFunction || func->symt.tag == SymTagInlineSite);
@ -435,7 +435,7 @@ void symt_add_func_line(struct module* module, struct symt_function* func,
dli->is_first = 0; /* only a source file can be first */ dli->is_first = 0; /* only a source file can be first */
dli->is_last = 1; dli->is_last = 1;
dli->line_number = line_num; dli->line_number = line_num;
dli->u.address = func->address + offset; dli->u.address = addr;
} }
/****************************************************************** /******************************************************************