This serie starts moving type handling into PDB backend.
In order to handle both the existing symt_{*} structures for every debug info objects and their potential counterpart inside a debug info backend, we introduce an opaque symref_t which can either hold a pointer or a value dedicated to a debug backend.
This allows: - to have generic code handling transparently a debug info object (whether it's managed as a symt_{*} object, or as a reference in backend) - during the migration phase from old to new PDB backend, to select, by type of object, whether it's handled by old or new backend, hence allowing a migration scheme by type of object.
This series mainly introduces the symref_t instead of the existing pointer to symt_{*}.
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/symbol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 784f88beb08..6913b82b836 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -740,13 +740,17 @@ static BOOL symt_fill_sym_info(struct module_pair* pair, MODULE_FORMAT_VTABLE_INDEX(loc_compute)))) { iter.modfmt->vtable->loc_compute(iter.modfmt, func, &loc); - if (loc.kind == loc_error && loc.reg == loc_err_out_of_scope) return FALSE; break; } } switch (loc.kind) { case loc_error: + if (loc.reg == loc_err_out_of_scope) + { + sym_info->Flags |= SYMFLAG_NULL; + break; + } /* for now we report error cases as a negative register number */ /* fall through */ case loc_register:
From: Eric Pouech epouech@codeweavers.com
We're going to introduce a couple more helpers in next patches, so make it more readable.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp.c | 2 +- dlls/dbghelp/dbghelp_private.h | 4 ++-- dlls/dbghelp/symbol.c | 8 +++---- dlls/dbghelp/type.c | 42 +++++++++++++++++----------------- 4 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index 5a023152ec4..73c7f1eb969 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -722,7 +722,7 @@ BOOL WINAPI SymSetScopeFromIndex(HANDLE hProcess, ULONG64 addr, DWORD index) TRACE("(%p %#I64x %lu)\n", hProcess, addr, index);
if (!module_init_pair(&pair, hProcess, addr)) return FALSE; - sym = symt_index2ptr(pair.effective, index); + sym = symt_index_to_ptr(pair.effective, index); if (!symt_check_tag(sym, SymTagFunction)) return FALSE;
pair.pcs->localscope_pc = ((struct symt_function*)sym)->ranges[0].low; /* FIXME of FuncDebugStart when it exists? */ diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index f2c74f05d24..bfa6b41af61 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -961,8 +961,8 @@ extern struct symt_hierarchy_point* symt_new_label(struct module* module, struct symt_compiland* compiland, const char* name, ULONG_PTR address); -extern struct symt* symt_index2ptr(struct module* module, DWORD id); -extern DWORD symt_ptr2index(struct module* module, const struct symt* sym); +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 struct symt_custom* symt_new_custom(struct module* module, const char* name, DWORD64 addr, DWORD size); diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 6913b82b836..01d3267808b 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -70,7 +70,7 @@ int __cdecl symt_cmp_addr(const void* p1, const void* p2) * which is exposed to the caller and index is the index of the symbol in * this array */ -DWORD symt_ptr2index(struct module* module, const struct symt* sym) +DWORD symt_ptr_to_index(struct module* module, const struct symt* sym) { struct vector* vector; DWORD offset; @@ -105,7 +105,7 @@ DWORD symt_ptr2index(struct module* module, const struct symt* sym) return len + offset; }
-struct symt* symt_index2ptr(struct module* module, DWORD id) +struct symt* symt_index_to_ptr(struct module* module, DWORD id) { struct vector* vector; if (id >= BASE_CUSTOM_SYMT) @@ -704,7 +704,7 @@ static BOOL symt_fill_sym_info(struct module_pair* pair,
if (!symt_get_info(pair->effective, sym, TI_GET_TYPE, &sym_info->TypeIndex)) sym_info->TypeIndex = 0; - sym_info->Index = symt_ptr2index(pair->effective, sym); + sym_info->Index = symt_ptr_to_index(pair->effective, sym); sym_info->Reserved[0] = sym_info->Reserved[1] = 0; if (!symt_get_info(pair->effective, sym, TI_GET_LENGTH, &size) && (!sym_info->TypeIndex || @@ -2655,7 +2655,7 @@ BOOL WINAPI SymFromIndex(HANDLE hProcess, ULONG64 BaseOfDll, DWORD index, PSYMBO hProcess, BaseOfDll, index, symbol);
if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE; - if ((sym = symt_index2ptr(pair.effective, index)) == NULL) return FALSE; + if ((sym = symt_index_to_ptr(pair.effective, index)) == NULL) return FALSE; symt_fill_sym_info(&pair, NULL, sym, symbol); return TRUE; } diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 97abb60f64d..0f3a94453a0 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -464,7 +464,7 @@ static BOOL sym_enum_types(struct module_pair *pair, const char *type_name, PSYM
if (type_name && !SymMatchStringA(type->hash_elt.name, type_name, TRUE)) continue;
- sym_info->TypeIndex = symt_ptr2index(pair->effective, &type->symt); + sym_info->TypeIndex = symt_ptr_to_index(pair->effective, &type->symt); sym_info->Index = 0; /* FIXME */ symt_get_info(pair->effective, &type->symt, TI_GET_LENGTH, &size); sym_info->Size = size; @@ -666,7 +666,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, for (i = 0; i < tifp->Count; i++) { if (!(pt = vector_at(v, tifp->Start + i))) return FALSE; - tifp->ChildId[i] = symt_ptr2index(module, *pt); + tifp->ChildId[i] = symt_ptr_to_index(module, *pt); } } break; @@ -845,25 +845,25 @@ BOOL symt_get_info(struct module* module, const struct symt* type, switch (type->tag) { case SymTagCompiland: - X(DWORD) = symt_ptr2index(module, &((const struct symt_compiland*)type)->container->symt); + X(DWORD) = symt_ptr_to_index(module, &((const struct symt_compiland*)type)->container->symt); break; case SymTagBlock: - X(DWORD) = symt_ptr2index(module, ((const struct symt_block*)type)->container); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_block*)type)->container); break; case SymTagData: - X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->container); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_data*)type)->container); break; case SymTagFunction: case SymTagInlineSite: - X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->container); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_function*)type)->container); break; case SymTagThunk: - X(DWORD) = symt_ptr2index(module, ((const struct symt_thunk*)type)->container); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_thunk*)type)->container); break; case SymTagFuncDebugStart: case SymTagFuncDebugEnd: case SymTagLabel: - X(DWORD) = symt_ptr2index(module, ((const struct symt_hierarchy_point*)type)->parent); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_hierarchy_point*)type)->parent); break; case SymTagUDT: case SymTagEnum: @@ -876,7 +876,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, case SymTagBaseClass: case SymTagPublicSymbol: case SymTagCustom: - X(DWORD) = symt_ptr2index(module, &module->top->symt); + X(DWORD) = symt_ptr_to_index(module, &module->top->symt); break; default: FIXME("Unsupported sym-tag %s for get-lexical-parent\n", @@ -981,30 +981,30 @@ BOOL symt_get_info(struct module* module, const struct symt* type, { /* hierarchical => hierarchical */ case SymTagArrayType: - X(DWORD) = symt_ptr2index(module, ((const struct symt_array*)type)->base_type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_array*)type)->base_type); break; case SymTagPointerType: - X(DWORD) = symt_ptr2index(module, ((const struct symt_pointer*)type)->pointsto); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_pointer*)type)->pointsto); break; case SymTagFunctionType: - X(DWORD) = symt_ptr2index(module, ((const struct symt_function_signature*)type)->rettype); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_function_signature*)type)->rettype); break; case SymTagTypedef: - X(DWORD) = symt_ptr2index(module, ((const struct symt_typedef*)type)->type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_typedef*)type)->type); break; /* lexical => hierarchical */ case SymTagData: - X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_data*)type)->type); break; case SymTagFunction: case SymTagInlineSite: - X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_function*)type)->type); break; case SymTagEnum: - X(DWORD) = symt_ptr2index(module, ((const struct symt_enum*)type)->base_type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_enum*)type)->base_type); break; case SymTagFunctionArgType: - X(DWORD) = symt_ptr2index(module, ((const struct symt_function_arg_type*)type)->arg_type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_function_arg_type*)type)->arg_type); break; default: FIXME("Unsupported sym-tag %s for get-type\n", @@ -1069,7 +1069,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, break; case TI_GET_ARRAYINDEXTYPEID: if (type->tag != SymTagArrayType) return FALSE; - X(DWORD) = symt_ptr2index(module, ((const struct symt_array*)type)->index_type); + X(DWORD) = symt_ptr_to_index(module, ((const struct symt_array*)type)->index_type); break;
case TI_GET_SYMINDEX: @@ -1077,7 +1077,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, * native sometimes (eg for UDT) return id of another instance * of the same UDT definition... maybe forward declaration? */ - X(DWORD) = symt_ptr2index(module, type); + X(DWORD) = symt_ptr_to_index(module, type); break;
/* FIXME: we don't support properly C++ for now */ @@ -1114,7 +1114,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, BOOL symt_get_info_from_index(struct module* module, DWORD index, IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo) { - return symt_get_info(module, symt_index2ptr(module, index), req, pInfo); + return symt_get_info(module, symt_index_to_ptr(module, index), req, pInfo); }
/****************************************************************** @@ -1145,7 +1145,7 @@ BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll, if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE; type = symt_find_type_by_name(pair.effective, SymTagNull, Name); if (!type) return FALSE; - Symbol->Index = Symbol->TypeIndex = symt_ptr2index(pair.effective, type); + Symbol->Index = Symbol->TypeIndex = symt_ptr_to_index(pair.effective, type); symbol_setname(Symbol, symt_get_name(type)); symt_get_info(pair.effective, type, TI_GET_LENGTH, &size); Symbol->Size = size;
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.@) *
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp_private.h | 6 +++--- dlls/dbghelp/dwarf.c | 6 +++--- dlls/dbghelp/msc.c | 12 ++++++------ dlls/dbghelp/type.c | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 852f883aa0b..1bb1f0e08cf 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -388,7 +388,7 @@ struct symt_typedef { struct symt symt; struct hash_table_elt hash_elt; - struct symt* type; + symref_t type; };
struct symt_udt @@ -1010,11 +1010,11 @@ extern BOOL symt_add_function_signature_parameter(struct module* module, struct symt_function_signature* sig, struct symt* param); extern struct symt_pointer* - symt_new_pointer(struct module* module, + symt_new_pointer(struct module* module, struct symt* ref_type, ULONG_PTR size); extern struct symt_typedef* - symt_new_typedef(struct module* module, struct symt* ref, + symt_new_typedef(struct module* module, symref_t ref, const char* name); extern struct symt_function* symt_find_lowest_inlined(struct symt_function* func, DWORD64 addr); diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 60aa04270b5..0a4f62cf7ff 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -715,7 +715,7 @@ static BOOL dwarf2_fill_attr(const dwarf2_parse_context_t* ctx, static struct symt *symt_get_real_type(struct symt *symt) { while (symt && symt->tag == SymTagTypedef) - symt = ((struct symt_typedef*)symt)->type; + symt = (struct symt*)(((struct symt_typedef*)symt)->type); return symt; }
@@ -1650,7 +1650,7 @@ static struct symt* dwarf2_parse_typedef(dwarf2_debug_info_t* di) */ if ((is_c_language(di->unit_ctx) || is_cpp_language(di->unit_ctx)) && !strcmp(name.u.string, "WCHAR")) ref_type = &symt_get_basic(btWChar, 2)->symt; - di->symt = &symt_new_typedef(di->unit_ctx->module_ctx->module, ref_type, name.u.string)->symt; + di->symt = &symt_new_typedef(di->unit_ctx->module_ctx->module, symt_ptr_to_symref(ref_type), name.u.string)->symt; } if (dwarf2_get_di_children(di)) FIXME("Unsupported children\n"); return di->symt; @@ -1822,7 +1822,7 @@ static struct symt* dwarf2_parse_unspecified_type(dwarf2_debug_info_t* di) basic = &symt_get_basic(btVoid, 0)->symt; if (dwarf2_find_attribute(di, DW_AT_name, &name)) /* define the missing type as a typedef to void... */ - di->symt = &symt_new_typedef(di->unit_ctx->module_ctx->module, basic, name.u.string)->symt; + di->symt = &symt_new_typedef(di->unit_ctx->module_ctx->module, symt_ptr_to_symref(basic), name.u.string)->symt; else /* or use void if it doesn't even have a name */ di->symt = basic;
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 56e1491ee7b..5163532a41d 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2679,7 +2679,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, if (sym->udt_v1.type) { if ((symt = codeview_get_type(sym->udt_v1.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt, + symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), terminate_string(&sym->udt_v1.p_name)); else FIXME("S-Udt %s: couldn't find type 0x%x\n", @@ -2690,7 +2690,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, if (sym->udt_v2.type) { if ((symt = codeview_get_type(sym->udt_v2.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt, + symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), terminate_string(&sym->udt_v2.p_name)); else FIXME("S-Udt %s: couldn't find type 0x%x\n", @@ -2701,7 +2701,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, if (sym->udt_v3.type) { if ((symt = codeview_get_type(sym->udt_v3.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt, sym->udt_v3.name); + symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), sym->udt_v3.name); else FIXME("S-Udt %s: couldn't find type 0x%x\n", debugstr_a(sym->udt_v3.name), sym->udt_v3.type); @@ -2988,7 +2988,7 @@ static BOOL pdb_global_feed_types(const struct msc_debug_info* msc_dbg, const un if (sym->udt_v1.type) { if ((symt = codeview_get_type(sym->udt_v1.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt, + symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), terminate_string(&sym->udt_v1.p_name)); else FIXME("S-Udt %s: couldn't find type 0x%x\n", @@ -2999,7 +2999,7 @@ static BOOL pdb_global_feed_types(const struct msc_debug_info* msc_dbg, const un if (sym->udt_v2.type) { if ((symt = codeview_get_type(sym->udt_v2.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt, + symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), terminate_string(&sym->udt_v2.p_name)); else FIXME("S-Udt %s: couldn't find type 0x%x\n", @@ -3010,7 +3010,7 @@ static BOOL pdb_global_feed_types(const struct msc_debug_info* msc_dbg, const un if (sym->udt_v3.type) { if ((symt = codeview_get_type(sym->udt_v3.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt, sym->udt_v3.name); + symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), sym->udt_v3.name); else FIXME("S-Udt %s: couldn't find type 0x%x\n", debugstr_a(sym->udt_v3.name), sym->udt_v3.type); diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 4fa4c8e7b00..e47a04401c1 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -430,7 +430,7 @@ struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_ty return sym; }
-struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, +struct symt_typedef* symt_new_typedef(struct module* module, symref_t ref, const char* typename) { struct symt_typedef* sym; @@ -818,7 +818,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD64) = ((const struct symt_public*)type)->size; break; case SymTagTypedef: - return symt_get_info(module, ((const struct symt_typedef*)type)->type, TI_GET_LENGTH, pInfo); + return symt_get_info_from_symref(module, ((const struct symt_typedef*)type)->type, TI_GET_LENGTH, pInfo); case SymTagThunk: X(DWORD64) = ((const struct symt_thunk*)type)->size; break; @@ -990,7 +990,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD) = symt_ptr_to_index(module, ((const struct symt_function_signature*)type)->rettype); break; case SymTagTypedef: - X(DWORD) = symt_ptr_to_index(module, ((const struct symt_typedef*)type)->type); + X(DWORD) = symt_symref_to_index(module, ((const struct symt_typedef*)type)->type); break; /* lexical => hierarchical */ case SymTagData:
From: Eric Pouech epouech@codeweavers.com
It's a ptr when lower 2 bits are unset, an opaque backend value otherwise.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp.c | 5 ++++- dlls/dbghelp/dbghelp_private.h | 8 +++++--- dlls/dbghelp/module.c | 4 ++-- dlls/dbghelp/symbol.c | 34 +++++++++++++++------------------- dlls/dbghelp/type.c | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index 73c7f1eb969..75881473c2c 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -717,12 +717,15 @@ BOOL WINAPI SymSetScopeFromAddr(HANDLE hProcess, ULONG64 addr) BOOL WINAPI SymSetScopeFromIndex(HANDLE hProcess, ULONG64 addr, DWORD index) { struct module_pair pair; + symref_t symref; struct symt* sym;
TRACE("(%p %#I64x %lu)\n", hProcess, addr, index);
if (!module_init_pair(&pair, hProcess, addr)) return FALSE; - sym = symt_index_to_ptr(pair.effective, index); + symref = symt_index_to_symref(pair.effective, index); + if (!symt_is_symref_ptr(symref)) return FALSE; + sym = (struct symt*)symref; if (!symt_check_tag(sym, SymTagFunction)) return FALSE;
pair.pcs->localscope_pc = ((struct symt_function*)sym)->ranges[0].low; /* FIXME of FuncDebugStart when it exists? */ diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 1bb1f0e08cf..8589a2141d6 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -31,6 +31,7 @@ #include "winnls.h" #include "wine/list.h" #include "wine/rbtree.h" +#include "wine/debug.h"
#include "cvconst.h"
@@ -963,11 +964,12 @@ extern struct symt_hierarchy_point* symt_new_label(struct module* module, struct symt_compiland* compiland, 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 symref_t symt_index_to_symref(struct module* module, DWORD id); +extern DWORD symt_symref_to_index(struct module* module, symref_t sym); +static inline DWORD symt_ptr_to_index(struct module *module, const struct symt *symt) {return symt_symref_to_index(module, symt_ptr_to_symref(symt));} +static inline BOOL symt_is_symref_ptr(symref_t ref) {return (ref & 3) == 0;} extern struct symt_custom* symt_new_custom(struct module* module, const char* name, DWORD64 addr, DWORD size); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 3d0c5ba7549..dee356e650a 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -197,8 +197,8 @@ struct module* module_new(struct process* pcs, const WCHAR* name, module->cpu = dbghelp_current_cpu; module->debug_format_bitmask = 0;
- vector_init(&module->vsymt, sizeof(struct symt*), 0); - vector_init(&module->vcustom_symt, sizeof(struct symt*), 0); + vector_init(&module->vsymt, sizeof(symref_t), 0); + vector_init(&module->vcustom_symt, sizeof(symref_t), 0); /* FIXME: this seems a bit too high (on a per module basis) * need some statistics about this */ diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 8bf8a5b35a6..ade18cc0a94 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -70,15 +70,15 @@ int __cdecl symt_cmp_addr(const void* p1, const void* p2) * which is exposed to the caller and index is the index of the symbol in * this array */ -DWORD symt_ptr_to_index(struct module* module, const struct symt* sym) +DWORD symt_symref_to_index(struct module* module, symref_t symref) { struct vector* vector; DWORD offset; - const struct symt** c; + symref_t *c; int len, i;
- if (!sym) return 0; - if (sym->tag == SymTagCustom) + if (!symref) return 0; + if (symt_is_symref_ptr(symref) && ((struct symt*)symref)->tag == SymTagCustom) { vector = &module->vcustom_symt; offset = BASE_CUSTOM_SYMT; @@ -89,23 +89,23 @@ DWORD symt_ptr_to_index(struct module* module, const struct symt* sy vector = &module->vsymt; offset = 1; #else - return (DWORD)sym; + return (DWORD)symref; #endif } len = vector_length(vector); /* FIXME: this is inefficient */ for (i = 0; i < len; i++) { - if (*(struct symt**)vector_at(vector, i) == sym) + if (*(symref_t*)vector_at(vector, i) == symref) return i + offset; } /* not found */ c = vector_add(vector, &module->pool); - if (c) *c = sym; + if (c) *c = symref; return len + offset; }
-struct symt* symt_index_to_ptr(struct module* module, DWORD id) +symref_t symt_index_to_symref(struct module* module, DWORD id) { struct vector* vector; if (id >= BASE_CUSTOM_SYMT) @@ -116,18 +116,13 @@ struct symt* symt_index_to_ptr(struct module* module, DWORD id) else { #ifdef _WIN64 - if (!id--) return NULL; + if (!id--) return 0; vector = &module->vsymt; #else - return (struct symt*)id; + return (symref_t)id; #endif } - 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); + return (id >= vector_length(vector)) ? 0 : *(symref_t *)vector_at(vector, id); }
static BOOL symt_grow_sorttab(struct module* module, unsigned sz) @@ -2653,14 +2648,15 @@ BOOL WINAPI SymGetLineFromNameW64(HANDLE hProcess, PCWSTR ModuleName, PCWSTR Fil BOOL WINAPI SymFromIndex(HANDLE hProcess, ULONG64 BaseOfDll, DWORD index, PSYMBOL_INFO symbol) { struct module_pair pair; - struct symt* sym; + symref_t symref;
TRACE("hProcess = %p, BaseOfDll = %I64x, index = %ld, symbol = %p\n", hProcess, BaseOfDll, index, symbol);
if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE; - if ((sym = symt_index_to_ptr(pair.effective, index)) == NULL) return FALSE; - symt_fill_sym_info(&pair, NULL, sym, symbol); + if ((symref = symt_index_to_symref(pair.effective, index)) == 0) return FALSE; + if (!symt_is_symref_ptr(symref)) return FALSE; + symt_fill_sym_info(&pair, NULL, (struct symt*)symref, symbol); return TRUE; }
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index e47a04401c1..6d3312fa108 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -1114,7 +1114,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, BOOL symt_get_info_from_index(struct module* module, DWORD index, IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo) { - return symt_get_info(module, symt_index_to_ptr(module, index), req, pInfo); + return symt_get_info_from_symref(module, symt_index_to_symref(module, index), req, pInfo); }
BOOL symt_get_info_from_symref(struct module* module, symref_t ref,