From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/dbghelp/dbghelp.c | 2 +- dlls/dbghelp/dbghelp_private.h | 8 +++++-- dlls/dbghelp/dwarf.c | 4 ++-- dlls/dbghelp/elf_module.c | 27 ++++++++++++----------- dlls/dbghelp/macho_module.c | 11 +++++----- dlls/dbghelp/msc.c | 40 +++++++++++++++++----------------- dlls/dbghelp/stabs.c | 20 ++++++++--------- dlls/dbghelp/symbol.c | 6 ++--- dlls/dbghelp/type.c | 6 ++--- 9 files changed, 65 insertions(+), 59 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index 3ad8d179c65..3fd40fbb21e 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -694,7 +694,7 @@ BOOL WINAPI SymSetScopeFromIndex(HANDLE hProcess, ULONG64 addr, DWORD index) sym = symt_index2ptr(pair.effective, index); if (!symt_check_tag(sym, SymTagFunction)) return FALSE;
- pair.pcs->localscope_pc = ((struct symt_function*)sym)->address; /* FIXME of FuncDebugStart when it exists? */ + pair.pcs->localscope_pc = ((struct symt_function*)sym)->ranges[0].low; /* FIXME of FuncDebugStart when it exists? */ pair.pcs->localscope_symt = sym;
return TRUE; diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index b574dbc7462..a8e862076bc 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -120,6 +120,11 @@ struct addr_range DWORD64 high; /* absolute address of first byte after the range */ };
+static inline DWORD64 addr_range_size(const struct addr_range* ar) +{ + return ar->high - ar->low; +} + /* tests whether ar2 is inside ar1 */ static inline BOOL addr_range_inside(const struct addr_range* ar1, const struct addr_range* ar2) { @@ -281,13 +286,12 @@ struct symt_function { struct symt symt; /* SymTagFunction (or SymTagInlineSite when embedded in symt_inlinesite) */ struct hash_table_elt hash_elt; /* if global symbol */ - ULONG_PTR address; struct symt* container; /* compiland */ struct symt* type; /* points to function_signature */ - ULONG_PTR size; struct vector vlines; struct vector vchildren; /* locals, params, blocks, start/end, labels, inline sites */ struct symt_inlinesite* next_inlinesite;/* linked list of inline sites in this function */ + struct addr_range ranges[1]; };
/* a symt_inlinesite* can be casted to a symt_function* to access all function bits */ diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index dd8606634ee..80be7aa5814 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -2093,7 +2093,7 @@ static void dwarf2_parse_subprogram_label(dwarf2_subprogram_t* subpgm, if (dwarf2_find_attribute(di, DW_AT_low_pc, &low_pc)) { loc.kind = loc_absolute; - loc.offset = subpgm->ctx->module_ctx->load_offset + low_pc.u.uvalue - subpgm->top_func->address; + loc.offset = subpgm->ctx->module_ctx->load_offset + low_pc.u.uvalue - subpgm->top_func->ranges[0].low; symt_add_function_point(subpgm->ctx->module_ctx->module, subpgm->top_func, SymTagLabel, &loc, name.u.string); } @@ -2150,7 +2150,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, inlined->num_ranges = 0; } /* temporary: update address field */ - inlined->func.address = inlined->ranges[0].low; + inlined->func.ranges[0].low = inlined->ranges[0].low;
children = dwarf2_get_di_children(di); if (children) for (i = 0; i < vector_length(children); i++) diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 306fecc1272..bc063bf1466 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -841,6 +841,7 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table struct symt_ht* sym; const struct elf_sym* symp; struct elf_module_info* elf_info = module->format_info[DFI_ELF]->u.elf_info; + DWORD64 size;
hash_table_iter_init(&module->ht_symbols, &hti, NULL); while ((ptr = hash_table_iter_up(&hti))) @@ -849,8 +850,8 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table switch (sym->symt.tag) { case SymTagFunction: - if (((struct symt_function*)sym)->address != elf_info->elf_addr && - ((struct symt_function*)sym)->size) + size = addr_range_size(&((struct symt_function*)sym)->ranges[0]); + if (((struct symt_function*)sym)->ranges[0].low != elf_info->elf_addr && size) { break; } @@ -858,19 +859,19 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table ((struct symt_function*)sym)->container); if (symp) { - if (((struct symt_function*)sym)->address != elf_info->elf_addr && - ((struct symt_function*)sym)->address != elf_info->elf_addr + symp->st_value) - FIXME("Changing address for %p/%s!%s from %08Ix to %I64x\n", + if (((struct symt_function*)sym)->ranges[0].low != elf_info->elf_addr && + ((struct symt_function*)sym)->ranges[0].low != elf_info->elf_addr + symp->st_value) + FIXME("Changing address for %p/%s!%s from %I64x to %I64x\n", sym, debugstr_w(module->modulename), sym->hash_elt.name, - ((struct symt_function*)sym)->address, + ((struct symt_function*)sym)->ranges[0].low, elf_info->elf_addr + symp->st_value); - if (((struct symt_function*)sym)->size && ((struct symt_function*)sym)->size != symp->st_size) - FIXME("Changing size for %p/%s!%s from %08Ix to %08x\n", + if (size && size != symp->st_size) + FIXME("Changing size for %p/%s!%s from %I64x to %I64x\n", sym, debugstr_w(module->modulename), sym->hash_elt.name, - ((struct symt_function*)sym)->size, (unsigned int)symp->st_size); + size, symp->st_size);
- ((struct symt_function*)sym)->address = elf_info->elf_addr + symp->st_value; - ((struct symt_function*)sym)->size = symp->st_size; + ((struct symt_function*)sym)->ranges[0].low = elf_info->elf_addr + symp->st_value; + ((struct symt_function*)sym)->ranges[0].high = elf_info->elf_addr + symp->st_value + symp->st_size; } else FIXME("Couldn't find %s!%s\n", debugstr_w(module->modulename), sym->hash_elt.name); @@ -889,9 +890,9 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table { if (((struct symt_data*)sym)->u.var.offset != elf_info->elf_addr && ((struct symt_data*)sym)->u.var.offset != elf_info->elf_addr + symp->st_value) - FIXME("Changing address for %p/%s!%s from %08Ix to %I64x\n", + FIXME("Changing address for %p/%s!%s from %I64x to %I64x\n", sym, debugstr_w(module->modulename), sym->hash_elt.name, - ((struct symt_function*)sym)->address, + ((struct symt_function*)sym)->ranges[0].low, elf_info->elf_addr + symp->st_value); ((struct symt_data*)sym)->u.var.offset = elf_info->elf_addr + symp->st_value; ((struct symt_data*)sym)->kind = elf_is_local_symbol(symp->st_info) ? diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 16fa0f815a9..4852f5beaa4 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -1063,15 +1063,16 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt { case SymTagFunction: func = (struct symt_function*)sym; - if (func->address == module->format_info[DFI_MACHO]->u.macho_info->load_addr) + if (func->ranges[0].low == module->format_info[DFI_MACHO]->u.macho_info->load_addr) { - TRACE("Adjusting function %p/%s!%s from 0x%08Ix to 0x%08Ix\n", func, + TRACE("Adjusting function %p/%s!%s from %#I64x to %#Ix\n", func, debugstr_w(module->modulename), sym->hash_elt.name, - func->address, ste->addr); - func->address = ste->addr; + func->ranges[0].low, ste->addr); + func->ranges[0].high += ste->addr - func->ranges[0].low; + func->ranges[0].low = ste->addr; adjusted = TRUE; } - if (func->address == ste->addr) + if (func->ranges[0].low == ste->addr) ste->used = 1; break; case SymTagData: diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 228b7019d4e..7bbc5d6bbd7 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -1614,7 +1614,7 @@ static void codeview_snarf_linetab(const struct msc_debug_info* msc_dbg, const B /* unfortunately, we can have several functions in the same block, if there's no * gap between them... find the new function if needed */ - if (!func || addr >= func->address + func->size) + if (!func || addr >= func->ranges[0].high) { func = (struct symt_function*)symt_find_symbol_at(msc_dbg->module, addr); /* FIXME: at least labels support line numbers */ @@ -1927,8 +1927,8 @@ static unsigned codeview_transform_defrange(const struct msc_debug_info* msc_dbg break; case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE: locinfo->offset = symrange->defrange_frameptr_relfullscope_v3.offFramePointer; - locinfo->start = curr_func->address; - locinfo->rangelen = curr_func->size; + locinfo->start = curr_func->ranges[0].low; + locinfo->rangelen = addr_range_size(&curr_func->ranges[0]); break; case S_DEFRANGE_REGISTER_REL: locinfo->reg = symrange->defrange_registerrel_v3.baseReg; @@ -2192,11 +2192,11 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu break; case BA_OP_ChangeCodeOffset: offset += cvba.arg1; - inline_site_update_last_range(inlined, index, top_func->address + offset); + inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset); if (srcok) - symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset); - inlined->ranges[index ].low = top_func->address + offset; - inlined->ranges[index++].high = top_func->address + offset; + symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->ranges[0].low + offset); + inlined->ranges[index ].low = top_func->ranges[0].low + offset; + inlined->ranges[index++].high = top_func->ranges[0].low + offset; break; case BA_OP_ChangeCodeLength: /* this op doesn't seem widely used... */ @@ -2213,19 +2213,19 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu case BA_OP_ChangeCodeOffsetAndLineOffset: line += binannot_getsigned(cvba.arg2); offset += cvba.arg1; - inline_site_update_last_range(inlined, index, top_func->address + offset); + inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset); if (srcok) - symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset); - inlined->ranges[index ].low = top_func->address + offset; - inlined->ranges[index++].high = top_func->address + offset; + symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->ranges[0].low + offset); + inlined->ranges[index ].low = top_func->ranges[0].low + offset; + inlined->ranges[index++].high = top_func->ranges[0].low + offset; break; case BA_OP_ChangeCodeLengthAndCodeOffset: offset += cvba.arg2; - inline_site_update_last_range(inlined, index, top_func->address + offset); + inline_site_update_last_range(inlined, index, top_func->ranges[0].low + offset); if (srcok) - symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset); - inlined->ranges[index ].low = top_func->address + offset; - inlined->ranges[index++].high = top_func->address + offset + cvba.arg1; + symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->ranges[0].low + offset); + inlined->ranges[index ].low = top_func->ranges[0].low + offset; + inlined->ranges[index++].high = top_func->ranges[0].low + offset + cvba.arg1; break; default: WARN("Unsupported op %d\n", cvba.opcode); @@ -2241,7 +2241,7 @@ static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debu inlined->func.hash_elt.name, top_func->hash_elt.name); /* temporary: update address field */ - inlined->func.address = inlined->ranges[0].low; + inlined->func.ranges[0].low = inlined->ranges[0].low; } return inlined; } @@ -2534,7 +2534,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, if (curr_func) { loc.kind = loc_absolute; - loc.offset = codeview_get_address(msc_dbg, sym->label_v1.segment, sym->label_v1.offset) - curr_func->address; + loc.offset = codeview_get_address(msc_dbg, sym->label_v1.segment, sym->label_v1.offset) - curr_func->ranges[0].low; symt_add_function_point(msc_dbg->module, curr_func, SymTagLabel, &loc, terminate_string(&sym->label_v1.p_name)); } @@ -2546,7 +2546,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, if (curr_func) { loc.kind = loc_absolute; - loc.offset = codeview_get_address(msc_dbg, sym->label_v3.segment, sym->label_v3.offset) - curr_func->address; + loc.offset = codeview_get_address(msc_dbg, sym->label_v3.segment, sym->label_v3.offset) - curr_func->ranges[0].low; symt_add_function_point(msc_dbg->module, curr_func, SymTagLabel, &loc, sym->label_v3.name); } @@ -2798,8 +2798,8 @@ static BOOL codeview_is_inside(const struct cv_local_info* locinfo, const struct /* ip must be in local_info range, but not in any of its gaps */ if (ip < locinfo->start || ip >= locinfo->start + locinfo->rangelen) return FALSE; for (i = 0; i < locinfo->ngaps; ++i) - if (func->address + locinfo->gaps[i].gapStartOffset <= ip && - ip < func->address + locinfo->gaps[i].gapStartOffset + locinfo->gaps[i].cbRange) + if (func->ranges[0].low + locinfo->gaps[i].gapStartOffset <= ip && + ip < func->ranges[0].low + locinfo->gaps[i].gapStartOffset + locinfo->gaps[i].cbRange) return FALSE; return TRUE; } diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c index 5969780fe35..f21f7e15d0b 100644 --- a/dlls/dbghelp/stabs.c +++ b/dlls/dbghelp/stabs.c @@ -1166,9 +1166,9 @@ static void pending_flush(struct pending_list* pending, struct module* module, break; case PENDING_LINE: 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->ranges[0].low - pending->objs[i].u.line.load_offset; symt_add_func_line(module, func, pending->objs[i].u.line.source_idx, - pending->objs[i].u.line.line_num, func->address + pending->objs[i].u.line.offset); + pending->objs[i].u.line.line_num, func->ranges[0].low + pending->objs[i].u.line.offset); break; default: ERR("Unknown pending object tag %u\n", (unsigned)pending->objs[i].tag); @@ -1199,15 +1199,15 @@ static void stabs_finalize_function(struct module* module, struct symt_function* * Not 100% bullet proof, but better than nothing */ il.SizeOfStruct = sizeof(il); - if (SymGetLineFromAddr64(module->process->handle, func->address, &disp, &il) && + if (SymGetLineFromAddr64(module->process->handle, func->ranges[0].low, &disp, &il) && SymGetLineNext64(module->process->handle, &il)) { loc.kind = loc_absolute; - loc.offset = il.Address - func->address; + loc.offset = il.Address - func->ranges[0].low; symt_add_function_point(module, func, SymTagFuncDebugStart, &loc, NULL); } - if (size) func->size = size; + if (size) func->ranges[0].high = func->ranges[0].low + size; }
static inline void stabbuf_append(char **buf, unsigned *buf_size, const char *str) @@ -1375,7 +1375,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, if (curr_func) { block = symt_open_func_block(module, curr_func, block, 1); - block->ranges[0].low = curr_func->address + n_value; + block->ranges[0].low = curr_func->ranges[0].low + n_value; block->ranges[0].high = 0; /* will be set by N_RBRAC */ pending_flush(&pending_block, module, curr_func, block); } @@ -1383,7 +1383,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, case N_RBRAC: if (curr_func) { - block->ranges[0].high = curr_func->address + n_value; + block->ranges[0].high = curr_func->ranges[0].low + n_value; block = symt_close_func_block(module, curr_func, block); } break; @@ -1493,9 +1493,9 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, { ULONG_PTR offset = n_value; if (module->type == DMT_MACHO) - offset -= curr_func->address - load_offset; + offset -= curr_func->ranges[0].low - load_offset; symt_add_func_line(module, curr_func, source_idx, - stab_ptr->n_desc, curr_func->address + offset); + stab_ptr->n_desc, curr_func->ranges[0].low + offset); } else pending_add_line(&pending_func, source_idx, stab_ptr->n_desc, n_value, load_offset); @@ -1531,7 +1531,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, */ stabs_finalize_function(module, curr_func, n_value ? - (load_offset + n_value - curr_func->address) : 0); + (load_offset + n_value - curr_func->ranges[0].low) : 0); } func_type = symt_new_function_signature(module, stabs_parse_type(ptr), -1); diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 614bf40f0a3..e0763d2f842 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -326,9 +326,9 @@ static void init_function_or_inlinesite(struct symt_function* sym, sym->symt.tag = tag; sym->hash_elt.name = pool_strdup(&module->pool, name); sym->container = container; - sym->address = addr; + sym->ranges[0].low = addr; + sym->ranges[0].high = addr + size; sym->type = sig_type; - sym->size = size; vector_init(&sym->vlines, sizeof(struct line_info), 64); vector_init(&sym->vchildren, sizeof(struct symt*), 8); } @@ -2685,7 +2685,7 @@ BOOL WINAPI SymFromInlineContext(HANDLE hProcess, DWORD64 addr, ULONG inline_ctx if (inlined) { symt_fill_sym_info(&pair, NULL, &inlined->func.symt, si); - if (disp) *disp = addr - inlined->func.address; + if (disp) *disp = addr - inlined->func.ranges[0].low; return TRUE; } /* fall through */ diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index ad2b304eebe..f847656beb7 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -153,10 +153,10 @@ BOOL symt_get_address(const struct symt* type, ULONG64* addr) *addr = ((const struct symt_block*)type)->ranges[0].low; break; case SymTagFunction: - *addr = ((const struct symt_function*)type)->address; + *addr = ((const struct symt_function*)type)->ranges[0].low; break; case SymTagInlineSite: - *addr = ((const struct symt_inlinesite*)type)->func.address; + *addr = ((const struct symt_inlinesite*)type)->func.ranges[0].low; break; case SymTagPublicSymbol: *addr = ((const struct symt_public*)type)->address; @@ -816,7 +816,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD64) = ((const struct symt_basic*)type)->size; break; case SymTagFunction: - X(DWORD64) = ((const struct symt_function*)type)->size; + X(DWORD64) = addr_range_size(&((const struct symt_function*)type)->ranges[0]); break; case SymTagBlock: /* When there are several ranges available, we can only return one contiguous chunk of memory.