From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/coff.c | 20 +++--- dlls/dbghelp/dbghelp_private.h | 35 ++++++---- dlls/dbghelp/dwarf.c | 19 ++--- dlls/dbghelp/elf_module.c | 4 +- dlls/dbghelp/macho_module.c | 4 +- dlls/dbghelp/msc.c | 122 ++++++++++++++++++--------------- dlls/dbghelp/stabs.c | 28 ++++---- dlls/dbghelp/symbol.c | 34 +++++---- dlls/dbghelp/type.c | 16 +++-- 9 files changed, 158 insertions(+), 124 deletions(-)
diff --git a/dlls/dbghelp/coff.c b/dlls/dbghelp/coff.c index 29c75c375e1..aa7273db24e 100644 --- a/dlls/dbghelp/coff.c +++ b/dlls/dbghelp/coff.c @@ -280,12 +280,12 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg)
/* FIXME: was adding symbol to this_file ??? */ coff_add_symbol(&coff_files.files[curr_file_idx], - &symt_new_function(msc_dbg->module, - coff_files.files[curr_file_idx].compiland, + &symt_new_function(msc_dbg->module, + coff_files.files[curr_file_idx].compiland, nampnt, msc_dbg->module->module.BaseOfImage + base + coff_sym->Value, 0 /* FIXME */, - NULL /* FIXME */)->symt); + 0 /* FIXME */)->symt); continue; }
@@ -316,15 +316,15 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg) if (j < coff_files.nfiles) { coff_add_symbol(&coff_files.files[j], - &symt_new_function(msc_dbg->module, compiland, nampnt, + &symt_new_function(msc_dbg->module, compiland, nampnt, msc_dbg->module->module.BaseOfImage + base + coff_sym->Value, - 0 /* FIXME */, NULL /* FIXME */)->symt); - } - else + 0 /* FIXME */, 0 /* FIXME */)->symt); + } + else { - symt_new_function(msc_dbg->module, NULL, nampnt, + symt_new_function(msc_dbg->module, NULL, nampnt, msc_dbg->module->module.BaseOfImage + base + coff_sym->Value, - 0 /* FIXME */, NULL /* FIXME */); + 0 /* FIXME */, 0 /* FIXME */); } i += naux; continue; @@ -353,7 +353,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg) loc.reg = 0; loc.offset = msc_dbg->module->module.BaseOfImage + base + coff_sym->Value; symt_new_global_variable(msc_dbg->module, NULL, nampnt, TRUE /* FIXME */, - loc, 0 /* FIXME */, NULL /* FIXME */); + loc, 0 /* FIXME */, 0 /* FIXME */); i += naux; continue; } diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index bfa6b41af61..852f883aa0b 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -182,6 +182,8 @@ static inline BOOL symt_check_tag(const struct symt* s, enum SymTagEnum tag) return s && s->tag == tag; }
+typedef ULONG_PTR symref_t; + /* lexical tree */ struct symt_block { @@ -215,7 +217,7 @@ struct symt_data struct hash_table_elt hash_elt; /* if global symbol */ enum DataKind kind; struct symt* container; - struct symt* type; + symref_t type; union /* depends on kind */ { /* DataIs{Global, FileStatic, StaticLocal}: @@ -292,7 +294,7 @@ struct symt_function struct symt symt; /* SymTagFunction or SymTagInlineSite */ struct hash_table_elt hash_elt; /* if global symbol, inline site */ struct symt* container; /* compiland (for SymTagFunction) or function (for SymTagInlineSite) */ - struct symt* type; /* points to function_signature */ + symref_t type; /* points to function_signature */ struct vector vlines; struct vector vchildren; /* locals, params, blocks, start/end, labels, inline sites */ struct symt_function* next_inlinesite;/* linked list of inline sites in this function */ @@ -900,38 +902,38 @@ extern struct symt_public* ULONG_PTR address, unsigned size); extern struct symt_data* - symt_new_global_variable(struct module* module, + symt_new_global_variable(struct module* module, struct symt_compiland* parent, const char* name, unsigned is_static, struct location loc, ULONG_PTR size, - struct symt* type); + symref_t type); extern struct symt_function* symt_new_function(struct module* module, struct symt_compiland* parent, const char* name, ULONG_PTR addr, ULONG_PTR size, - struct symt* type); + symref_t type); extern struct symt_function* symt_new_inlinesite(struct module* module, struct symt_function* func, struct symt* parent, const char* name, - struct symt* type, + symref_t type, unsigned num_ranges); extern void symt_add_func_line(struct module* module, struct symt_function* func, unsigned source_idx, int line_num, ULONG_PTR offset); extern struct symt_data* - symt_add_func_local(struct module* module, - struct symt_function* func, + symt_add_func_local(struct module* module, + struct symt_function* func, enum DataKind dt, const struct location* loc, struct symt_block* block, - struct symt* type, const char* name); + symref_t, const char* name); extern struct symt_data* symt_add_func_constant(struct module* module, struct symt_function* func, struct symt_block* block, - struct symt* type, const char* name, VARIANT* v); + symref_t, const char* name, VARIANT* v); extern struct symt_block* symt_open_func_block(struct module* module, struct symt_function* func, @@ -955,7 +957,7 @@ extern struct symt_thunk* extern struct symt_data* symt_new_constant(struct module* module, struct symt_compiland* parent, - const char* name, struct symt* type, + const char* name, symref_t type, const VARIANT* v); extern struct symt_hierarchy_point* symt_new_label(struct module* module, @@ -963,6 +965,9 @@ extern struct symt_hierarchy_point* const char* name, ULONG_PTR address); extern struct symt* symt_index_to_ptr(struct module* module, DWORD id); extern DWORD symt_ptr_to_index(struct module* module, const struct symt* sym); +extern DWORD symt_symref_to_index(struct module* module, symref_t ref); +static inline symref_t + symt_ptr_to_symref(const struct symt *symt) {return (ULONG_PTR)symt;} extern struct symt_custom* symt_new_custom(struct module* module, const char* name, DWORD64 addr, DWORD size); @@ -974,6 +979,8 @@ extern BOOL symt_get_info(struct module* module, const struct symt* type IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo); extern BOOL symt_get_info_from_index(struct module* module, DWORD index, IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo); +extern BOOL symt_get_info_from_symref(struct module* module, symref_t type, + IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo); extern struct symt_basic* symt_get_basic(enum BasicType, unsigned size); extern struct symt_udt* @@ -981,10 +988,10 @@ extern struct symt_udt* unsigned size, enum UdtKind kind); extern BOOL symt_set_udt_size(struct module* module, struct symt_udt* type, unsigned size); -extern BOOL symt_add_udt_element(struct module* module, - struct symt_udt* udt_type, +extern BOOL symt_add_udt_element(struct module* module, + struct symt_udt* udt_type, const char* name, - struct symt* elt_type, unsigned offset, + symref_t elt_type, unsigned offset, unsigned bit_offset, unsigned bit_size); extern struct symt_enum* symt_new_enum(struct module* module, const char* typename, diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 86d41cd1970..60aa04270b5 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -1894,7 +1894,8 @@ static void dwarf2_parse_udt_member(dwarf2_debug_info_t* di, bit_offset.u.uvalue = nbytes.u.uvalue * 8 - bit_offset.u.uvalue - bit_size.u.uvalue; } else bit_offset.u.uvalue = 0; - symt_add_udt_element(di->unit_ctx->module_ctx->module, parent, name.u.string, elt_type, + symt_add_udt_element(di->unit_ctx->module_ctx->module, parent, name.u.string, + symt_ptr_to_symref(elt_type), loc.offset, bit_offset.u.uvalue, bit_size.u.uvalue);
@@ -2118,14 +2119,14 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, if (ext.u.uvalue) WARN("unexpected global inside a function\n"); symt_add_func_local(subpgm->ctx->module_ctx->module, subpgm->current_func, DataIsStaticLocal, &loc, subpgm->current_block, - param_type, dwarf2_get_cpp_name(di, name.u.string)); + symt_ptr_to_symref(param_type), dwarf2_get_cpp_name(di, name.u.string)); } else { symt_new_global_variable(subpgm->ctx->module_ctx->module, ext.u.uvalue ? NULL : subpgm->ctx->compiland, dwarf2_get_cpp_name(di, name.u.string), !ext.u.uvalue, - loc, 0, param_type); + loc, 0, symt_ptr_to_symref(param_type)); } break; default: @@ -2139,7 +2140,7 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, if (subpgm->current_func) symt_add_func_local(subpgm->ctx->module_ctx->module, subpgm->current_func, is_pmt ? DataIsParam : DataIsLocal, - &loc, subpgm->current_block, param_type, name.u.string); + &loc, subpgm->current_block, symt_ptr_to_symref(param_type), name.u.string); break; } } @@ -2157,11 +2158,11 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, debugstr_a(name.u.string), debugstr_a(subpgm->current_func->hash_elt.name)); di->symt = &symt_add_func_constant(subpgm->ctx->module_ctx->module, subpgm->current_func, subpgm->current_block, - param_type, name.u.string, &v)->symt; + symt_ptr_to_symref(param_type), name.u.string, &v)->symt; } else di->symt = &symt_new_constant(subpgm->ctx->module_ctx->module, subpgm->ctx->compiland, - name.u.string, param_type, &v)->symt; + name.u.string, symt_ptr_to_symref(param_type), &v)->symt; } else { @@ -2172,7 +2173,7 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, loc.reg = loc_err_no_location; symt_add_func_local(subpgm->ctx->module_ctx->module, subpgm->current_func, is_pmt ? DataIsParam : DataIsLocal, - &loc, subpgm->current_block, param_type, name.u.string); + &loc, subpgm->current_block, symt_ptr_to_symref(param_type), name.u.string); } else { @@ -2241,7 +2242,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, subpgm->top_func, subpgm->current_block ? &subpgm->current_block->symt : &subpgm->current_func->symt, dwarf2_get_cpp_name(di, name.u.string), - dwarf2_parse_subroutine_type(di), num_ranges); + symt_ptr_to_symref(dwarf2_parse_subroutine_type(di)), num_ranges); subpgm->current_func = inlined; subpgm->current_block = NULL;
@@ -2451,7 +2452,7 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_debug_info_t* di) subpgm.top_func = symt_new_function(di->unit_ctx->module_ctx->module, di->unit_ctx->compiland, dwarf2_get_cpp_name(di, name.u.string), addr_ranges[0].low, addr_ranges[0].high - addr_ranges[0].low, - dwarf2_parse_subroutine_type(di)); + symt_ptr_to_symref(dwarf2_parse_subroutine_type(di))); if (num_addr_ranges > 1) WARN("Function %s has multiple address ranges, only using the first one\n", debugstr_a(name.u.string)); free(addr_ranges); diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 83c4ea898e8..b62fca9fc3e 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -960,7 +960,7 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h { case ELF_STT_FUNC: symt_new_function(module, ste->compiland, ste->ht_elt.name, - addr, ste->sym.st_size, NULL); + addr, ste->sym.st_size, 0); break; case ELF_STT_OBJECT: loc.kind = loc_absolute; @@ -968,7 +968,7 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h loc.offset = addr; symt_new_global_variable(module, ste->compiland, ste->ht_elt.name, elf_is_local_symbol(ste->sym.st_info), - loc, ste->sym.st_size, NULL); + loc, ste->sym.st_size, 0); break; default: FIXME("Shouldn't happen\n"); diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 234136fa92d..b14591beb66 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -1190,7 +1190,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt if (ste->is_code) { symt_new_function(module, ste->compiland, ste->ht_elt.name, - ste->addr, 0, NULL); + ste->addr, 0, 0); } else { @@ -1200,7 +1200,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt loc.reg = 0; loc.offset = ste->addr; symt_new_global_variable(module, ste->compiland, ste->ht_elt.name, - !ste->is_global, loc, 0, NULL); + !ste->is_global, loc, 0, 0); }
ste->used = 1; diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 6c8f9b3637d..56e1491ee7b 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -964,13 +964,13 @@ static void codeview_add_udt_element(struct codeview_type_parse* ctp, { case LF_BITFIELD_V1: symt_add_udt_element(ctp->module, symt, name, - codeview_fetch_type(ctp, cv_type->bitfield_v1.type), + symt_ptr_to_symref(codeview_fetch_type(ctp, cv_type->bitfield_v1.type)), value, cv_type->bitfield_v1.bitoff, cv_type->bitfield_v1.nbits); return; case LF_BITFIELD_V2: symt_add_udt_element(ctp->module, symt, name, - codeview_fetch_type(ctp, cv_type->bitfield_v2.type), + symt_ptr_to_symref(codeview_fetch_type(ctp, cv_type->bitfield_v2.type)), value, cv_type->bitfield_v2.bitoff, cv_type->bitfield_v2.nbits); return; @@ -982,7 +982,8 @@ static void codeview_add_udt_element(struct codeview_type_parse* ctp, { DWORD64 elem_size = 0; symt_get_info(ctp->module, subtype, TI_GET_LENGTH, &elem_size); - symt_add_udt_element(ctp->module, symt, name, subtype, value, 0, 0); + symt_add_udt_element(ctp->module, symt, name, symt_ptr_to_symref(subtype), + value, 0, 0); } }
@@ -1815,7 +1816,7 @@ static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg, { if (!is_local || in_tls) WARN("Unsupported construct\n"); symt_add_func_local(msc_dbg->module, func, DataIsStaticLocal, &loc, block, - codeview_get_type(symtype, FALSE), name); + symt_ptr_to_symref(codeview_get_type(symtype, FALSE)), name); return; } if (!dontcheck && !in_tls) @@ -1848,7 +1849,7 @@ static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg, } if (is_local ^ (compiland != NULL)) FIXME("Unsupported construct\n"); symt_new_global_variable(msc_dbg->module, compiland, name, is_local, loc, 0, - codeview_get_type(symtype, FALSE)); + symt_ptr_to_symref(codeview_get_type(symtype, FALSE))); } }
@@ -2183,14 +2184,14 @@ static struct symt_function* codeview_create_inline_site(const struct msc_debug_ case LF_FUNC_ID: inlined = symt_new_inlinesite(msc_dbg->module, top_func, container, cvt->func_id_v3.name, - codeview_get_type(cvt->func_id_v3.type, FALSE), + symt_ptr_to_symref(codeview_get_type(cvt->func_id_v3.type, FALSE)), num_ranges); break; case LF_MFUNC_ID: /* FIXME we just declare a function, not a method */ inlined = symt_new_inlinesite(msc_dbg->module, top_func, container, cvt->mfunc_id_v3.name, - codeview_get_type(cvt->mfunc_id_v3.type, FALSE), + symt_ptr_to_symref(codeview_get_type(cvt->mfunc_id_v3.type, FALSE)), num_ranges); break; default: @@ -2305,6 +2306,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, { struct symt_function* top_func = NULL; struct symt_function* curr_func = NULL; + struct symt* func_signature; int i, length; struct symt_block* block = NULL; struct symt* symt; @@ -2405,47 +2407,59 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, case S_GPROC32_16t: case S_LPROC32_16t: if (top_func) FIXME("nested function\n"); - top_func = symt_new_function(msc_dbg->module, compiland, - terminate_string(&sym->proc_v1.p_name), - codeview_get_address(msc_dbg, sym->proc_v1.segment, sym->proc_v1.offset), - sym->proc_v1.proc_len, - codeview_get_type(sym->proc_v1.proctype, FALSE)); - curr_func = top_func; - loc.kind = loc_absolute; - loc.offset = sym->proc_v1.debug_start; - symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL); - loc.offset = sym->proc_v1.debug_end; - symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL); + func_signature = codeview_get_type(sym->proc_v1.proctype, FALSE); + if (!func_signature || func_signature->tag == SymTagFunctionType) + { + top_func = symt_new_function(msc_dbg->module, compiland, + terminate_string(&sym->proc_v1.p_name), + codeview_get_address(msc_dbg, sym->proc_v1.segment, sym->proc_v1.offset), + sym->proc_v1.proc_len, + symt_ptr_to_symref(func_signature)); + curr_func = top_func; + loc.kind = loc_absolute; + loc.offset = sym->proc_v1.debug_start; + symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL); + loc.offset = sym->proc_v1.debug_end; + symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL); + } break; case S_GPROC32_ST: case S_LPROC32_ST: if (top_func) FIXME("nested function\n"); - top_func = symt_new_function(msc_dbg->module, compiland, - terminate_string(&sym->proc_v2.p_name), - codeview_get_address(msc_dbg, sym->proc_v2.segment, sym->proc_v2.offset), - sym->proc_v2.proc_len, - codeview_get_type(sym->proc_v2.proctype, FALSE)); - curr_func = top_func; - loc.kind = loc_absolute; - loc.offset = sym->proc_v2.debug_start; - symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL); - loc.offset = sym->proc_v2.debug_end; - symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL); + func_signature = codeview_get_type(sym->proc_v2.proctype, FALSE); + if (!func_signature || func_signature->tag == SymTagFunctionType) + { + top_func = symt_new_function(msc_dbg->module, compiland, + terminate_string(&sym->proc_v2.p_name), + codeview_get_address(msc_dbg, sym->proc_v2.segment, sym->proc_v2.offset), + sym->proc_v2.proc_len, + symt_ptr_to_symref(func_signature)); + curr_func = top_func; + loc.kind = loc_absolute; + loc.offset = sym->proc_v2.debug_start; + symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL); + loc.offset = sym->proc_v2.debug_end; + symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL); + } break; case S_GPROC32: case S_LPROC32: if (top_func) FIXME("nested function\n"); - top_func = symt_new_function(msc_dbg->module, compiland, - sym->proc_v3.name, - codeview_get_address(msc_dbg, sym->proc_v3.segment, sym->proc_v3.offset), - sym->proc_v3.proc_len, - codeview_get_type(sym->proc_v3.proctype, FALSE)); - curr_func = top_func; - loc.kind = loc_absolute; - loc.offset = sym->proc_v3.debug_start; - symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL); - loc.offset = sym->proc_v3.debug_end; - symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL); + func_signature = codeview_get_type(sym->proc_v3.proctype, FALSE); + if (!func_signature || func_signature->tag == SymTagFunctionType) + { + top_func = symt_new_function(msc_dbg->module, compiland, + sym->proc_v3.name, + codeview_get_address(msc_dbg, sym->proc_v3.segment, sym->proc_v3.offset), + sym->proc_v3.proc_len, + symt_ptr_to_symref(func_signature)); + curr_func = top_func; + loc.kind = loc_absolute; + loc.offset = sym->proc_v3.debug_start; + symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL); + loc.offset = sym->proc_v3.debug_end; + symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL); + } break; /* * Function parameters and stack variables. @@ -2458,7 +2472,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, symt_add_func_local(msc_dbg->module, curr_func, sym->stack_v1.offset > 0 ? DataIsParam : DataIsLocal, &loc, block, - codeview_get_type(sym->stack_v1.symtype, FALSE), + symt_ptr_to_symref(codeview_get_type(sym->stack_v1.symtype, FALSE)), terminate_string(&sym->stack_v1.p_name)); break; case S_BPREL32_ST: @@ -2469,7 +2483,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, symt_add_func_local(msc_dbg->module, curr_func, sym->stack_v2.offset > 0 ? DataIsParam : DataIsLocal, &loc, block, - codeview_get_type(sym->stack_v2.symtype, FALSE), + symt_ptr_to_symref(codeview_get_type(sym->stack_v2.symtype, FALSE)), terminate_string(&sym->stack_v2.p_name)); break; case S_BPREL32: @@ -2482,7 +2496,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, symt_add_func_local(msc_dbg->module, curr_func, sym->stack_v3.offset > 0 ? DataIsParam : DataIsLocal, &loc, block, - codeview_get_type(sym->stack_v3.symtype, FALSE), + symt_ptr_to_symref(codeview_get_type(sym->stack_v3.symtype, FALSE)), sym->stack_v3.name); break; case S_REGREL32: @@ -2495,7 +2509,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, symt_add_func_local(msc_dbg->module, curr_func, sym->regrel_v3.offset >= top_frame_size ? DataIsParam : DataIsLocal, &loc, block, - codeview_get_type(sym->regrel_v3.symtype, FALSE), + symt_ptr_to_symref(codeview_get_type(sym->regrel_v3.symtype, FALSE)), sym->regrel_v3.name); break;
@@ -2504,8 +2518,8 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, loc.reg = sym->register_v1.reg; loc.offset = 0; symt_add_func_local(msc_dbg->module, curr_func, - DataIsLocal, &loc, - block, codeview_get_type(sym->register_v1.type, FALSE), + DataIsLocal, &loc, block, + symt_ptr_to_symref(codeview_get_type(sym->register_v1.type, FALSE)), terminate_string(&sym->register_v1.p_name)); break; case S_REGISTER_ST: @@ -2513,8 +2527,8 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, loc.reg = sym->register_v2.reg; loc.offset = 0; symt_add_func_local(msc_dbg->module, curr_func, - DataIsLocal, &loc, - block, codeview_get_type(sym->register_v2.type, FALSE), + DataIsLocal, &loc, block, + symt_ptr_to_symref(codeview_get_type(sym->register_v2.type, FALSE)), terminate_string(&sym->register_v2.p_name)); break; case S_REGISTER: @@ -2524,8 +2538,8 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, loc.reg = sym->register_v3.reg; loc.offset = 0; symt_add_func_local(msc_dbg->module, curr_func, - DataIsLocal, &loc, - block, codeview_get_type(sym->register_v3.type, FALSE), + DataIsLocal, &loc, block, + symt_ptr_to_symref(codeview_get_type(sym->register_v3.type, FALSE)), sym->register_v3.name); break;
@@ -2625,7 +2639,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
TRACE("S-Constant-V1 %u %s %x\n", V_INT(&v), terminate_string(name), sym->constant_v1.type); symt_new_constant(msc_dbg->module, compiland, terminate_string(name), - se, &v); + symt_ptr_to_symref(se), &v); } break; case S_CONSTANT_ST: @@ -2641,7 +2655,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
TRACE("S-Constant-V2 %u %s %x\n", V_INT(&v), terminate_string(name), sym->constant_v2.type); symt_new_constant(msc_dbg->module, compiland, terminate_string(name), - se, &v); + symt_ptr_to_symref(se), &v); } break; case S_CONSTANT: @@ -2657,7 +2671,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
TRACE("S-Constant-V3 %u %s %x\n", V_INT(&v), debugstr_a(name), sym->constant_v3.type); /* FIXME: we should add this as a constant value */ - symt_new_constant(msc_dbg->module, compiland, name, se, &v); + symt_new_constant(msc_dbg->module, compiland, name, symt_ptr_to_symref(se), &v); } break;
@@ -2712,7 +2726,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, symt_add_func_local(msc_dbg->module, curr_func, sym->local_v3.varflags.is_param ? DataIsParam : DataIsLocal, &loc, block, - codeview_get_type(sym->local_v3.symtype, FALSE), + symt_ptr_to_symref(codeview_get_type(sym->local_v3.symtype, FALSE)), sym->local_v3.name); } else diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c index 8d9b91eeb4f..efd2bb2f943 100644 --- a/dlls/dbghelp/stabs.c +++ b/dlls/dbghelp/stabs.c @@ -618,7 +618,8 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, strcpy(tmp, "__inherited_class_"); strcat(tmp, symt_get_name(adt));
- symt_add_udt_element(ptd->module, sdt, tmp, adt, ofs, 0, 0); + symt_add_udt_element(ptd->module, sdt, tmp, symt_ptr_to_symref(adt), + ofs, 0, 0); } PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); } @@ -692,7 +693,8 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &sz) == -1); PTS_ABORTIF(ptd, *ptd->ptr++ != ';');
- if (doadd) symt_add_udt_element(ptd->module, sdt, ptd->buf + idx, adt, ofs, 0, 0); + if (doadd) symt_add_udt_element(ptd->module, sdt, ptd->buf + idx, symt_ptr_to_symref(adt), + ofs, 0, 0); break; case ':': { @@ -1171,7 +1173,7 @@ static void pending_flush(struct pending_list* pending, struct module* module, case PENDING_VAR: symt_add_func_local(module, func, pending->objs[i].u.var.kind, &pending->objs[i].u.var.loc, - block, pending->objs[i].u.var.type, pending->objs[i].u.var.name); + block, symt_ptr_to_symref(pending->objs[i].u.var.type), pending->objs[i].u.var.name); break; case PENDING_LINE: if (module->type == DMT_MACHO) @@ -1363,7 +1365,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, loc.reg = 0; loc.offset = load_offset + n_value; symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */, - loc, 0, stabs_parse_type(ptr)); + loc, 0, symt_ptr_to_symref(stabs_parse_type(ptr))); break; case N_LCSYM: case N_STSYM: @@ -1378,7 +1380,7 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, loc.reg = 0; loc.offset = load_offset + n_value; symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */, - loc, 0, stabs_parse_type(ptr)); + loc, 0, symt_ptr_to_symref(stabs_parse_type(ptr))); break; case N_LBRAC: if (curr_func) @@ -1412,9 +1414,9 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, loc.offset = n_value; symt_add_func_local(module, curr_func, (int)n_value >= 0 ? DataIsParam : DataIsLocal, - &loc, NULL, param_type, symname); - symt_add_function_signature_parameter(module, - (struct symt_function_signature*)curr_func->type, + &loc, NULL, symt_ptr_to_symref(param_type), symname); + symt_add_function_signature_parameter(module, + (struct symt_function_signature*)curr_func->type, param_type); } break; @@ -1476,9 +1478,9 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, struct symt* param_type = stabs_parse_type(ptr); stab_strcpy(symname, sizeof(symname), ptr); symt_add_func_local(module, curr_func, DataIsParam, &loc, - NULL, param_type, symname); - symt_add_function_signature_parameter(module, - (struct symt_function_signature*)curr_func->type, + NULL, symt_ptr_to_symref(param_type), symname); + symt_add_function_signature_parameter(module, + (struct symt_function_signature*)curr_func->type, param_type); } else @@ -1547,9 +1549,9 @@ BOOL stabs_parse(struct module* module, ULONG_PTR load_offset, } func_type = symt_new_function_signature(module, stabs_parse_type(ptr), -1); - curr_func = symt_new_function(module, compiland, symname, + curr_func = symt_new_function(module, compiland, symname, load_offset + n_value, 0, - &func_type->symt); + symt_ptr_to_symref(&func_type->symt)); pending_flush(&pending_func, module, curr_func, NULL); } else diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 01d3267808b..8bf8a5b35a6 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -125,6 +125,11 @@ struct symt* symt_index_to_ptr(struct module* module, DWORD id) return (id >= vector_length(vector)) ? NULL : *(struct symt**)vector_at(vector, id); }
+DWORD symt_symref_to_index(struct module *module, symref_t ref) +{ + return symt_ptr_to_index(module, (struct symt*)ref); +} + static BOOL symt_grow_sorttab(struct module* module, unsigned sz) { struct symt_ht** new; @@ -288,13 +293,13 @@ struct symt_data* symt_new_global_variable(struct module* module, struct symt_compiland* compiland, const char* name, unsigned is_static, struct location loc, ULONG_PTR size, - struct symt* type) + symref_t type) { struct symt_data* sym; struct symt** p; DWORD64 tsz;
- TRACE_(dbghelp_symt)("Adding global symbol %s:%s %d@%Ix %p\n", + TRACE_(dbghelp_symt)("Adding global symbol %s:%s %d@%Ix %Ix\n", debugstr_w(module->modulename), debugstr_a(name), loc.kind, loc.offset, type); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { @@ -304,7 +309,7 @@ struct symt_data* symt_new_global_variable(struct module* module, sym->container = compiland ? &compiland->symt : &module->top->symt; sym->type = type; sym->u.var = loc; - if (type && size && symt_get_info(module, type, TI_GET_LENGTH, &tsz)) + if (type && size && symt_get_info_from_symref(module, type, TI_GET_LENGTH, &tsz)) { if (tsz != size) FIXME("Size mismatch for %s.%s between type (%I64u) and src (%Iu)\n", @@ -321,12 +326,11 @@ static struct symt_function* init_function_or_inlinesite(struct module* module, DWORD tag, struct symt* container, const char* name, - struct symt* sig_type, + symref_t sig_type, unsigned num_ranges) { struct symt_function* sym;
- assert(!sig_type || sig_type->tag == SymTagFunctionType); if ((sym = pool_alloc(&module->pool, offsetof(struct symt_function, ranges[num_ranges])))) { sym->symt.tag = tag; @@ -344,7 +348,7 @@ struct symt_function* symt_new_function(struct module* module, struct symt_compiland* compiland, const char* name, ULONG_PTR addr, ULONG_PTR size, - struct symt* sig_type) + symref_t sig_type) { struct symt_function* sym;
@@ -370,7 +374,7 @@ struct symt_function* symt_new_inlinesite(struct module* module, struct symt_function* func, struct symt* container, const char* name, - struct symt* sig_type, + symref_t sig_type, unsigned num_ranges) { struct symt_function* sym; @@ -461,17 +465,17 @@ void symt_add_func_line(struct module* module, struct symt_function* func, * Otherwise, the variable is stored on the stack: * - offset is then the offset from the frame register */ -struct symt_data* symt_add_func_local(struct module* module, - struct symt_function* func, +struct symt_data* symt_add_func_local(struct module* module, + struct symt_function* func, enum DataKind dt, const struct location* loc, - struct symt_block* block, - struct symt* type, const char* name) + struct symt_block* block, + symref_t type, const char* name) { struct symt_data* locsym; struct symt** p;
- TRACE_(dbghelp_symt)("Adding local symbol (%s:%s): %s %p\n", + TRACE_(dbghelp_symt)("Adding local symbol (%s:%s): %s %Ix\n", debugstr_w(module->modulename), debugstr_a(func->hash_elt.name), debugstr_a(name), type);
@@ -504,13 +508,13 @@ struct symt_data* symt_add_func_local(struct module* module, struct symt_data* symt_add_func_constant(struct module* module, struct symt_function* func, struct symt_block* block, - struct symt* type, const char* name, + symref_t type, const char* name, VARIANT* v) { struct symt_data* locsym; struct symt** p;
- TRACE_(dbghelp_symt)("Adding local constant (%s:%s): %s %p\n", + TRACE_(dbghelp_symt)("Adding local constant (%s:%s): %s %Ix\n", debugstr_w(module->modulename), debugstr_a(func->hash_elt.name), debugstr_a(name), type);
@@ -620,7 +624,7 @@ struct symt_thunk* symt_new_thunk(struct module* module,
struct symt_data* symt_new_constant(struct module* module, struct symt_compiland* compiland, - const char* name, struct symt* type, + const char* name, symref_t type, const VARIANT* v) { struct symt_data* sym; diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 0f3a94453a0..4fa4c8e7b00 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -280,7 +280,7 @@ BOOL symt_set_udt_size(struct module* module, struct symt_udt* udt, unsigned siz * the others (bit fields) */ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type, - const char* name, struct symt* elt_type, + const char* name, symref_t elt_type, unsigned offset, unsigned bit_offset, unsigned bit_size) { struct symt_data* m; @@ -356,7 +356,7 @@ BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type, e->hash_elt.next = NULL; e->kind = DataIsConstant; e->container = &enum_type->symt; - e->type = enum_type->base_type; + e->type = symt_ptr_to_symref(enum_type->base_type); e->u.value = *variant;
p = vector_add(&enum_type->vchildren, &module->pool); @@ -804,7 +804,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD64) = ((const struct symt_data*)type)->u.member.bit_length; break; default: - if (!symt_get_info(module, ((const struct symt_data*)type)->type, TI_GET_LENGTH, pInfo)) + if (!symt_get_info_from_symref(module, ((const struct symt_data*)type)->type, TI_GET_LENGTH, pInfo)) return FALSE; } break; @@ -994,11 +994,11 @@ BOOL symt_get_info(struct module* module, const struct symt* type, break; /* lexical => hierarchical */ case SymTagData: - X(DWORD) = symt_ptr_to_index(module, ((const struct symt_data*)type)->type); + X(DWORD) = symt_symref_to_index(module, ((const struct symt_data*)type)->type); break; case SymTagFunction: case SymTagInlineSite: - X(DWORD) = symt_ptr_to_index(module, ((const struct symt_function*)type)->type); + X(DWORD) = symt_symref_to_index(module, ((const struct symt_function*)type)->type); break; case SymTagEnum: X(DWORD) = symt_ptr_to_index(module, ((const struct symt_enum*)type)->base_type); @@ -1117,6 +1117,12 @@ BOOL symt_get_info_from_index(struct module* module, DWORD index, return symt_get_info(module, symt_index_to_ptr(module, index), req, pInfo); }
+BOOL symt_get_info_from_symref(struct module* module, symref_t ref, + IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo) +{ + return symt_get_info(module, (struct symt*)ref, req, pInfo); +} + /****************************************************************** * SymGetTypeInfo (DBGHELP.@) *