From: Eric Pouech epouech@codeweavers.com
Add method to handle the TI_ requests.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp_private.h | 8 ++ dlls/dbghelp/dwarf.c | 1 + dlls/dbghelp/module.c | 8 ++ dlls/dbghelp/msc.c | 111 +++++++++++-------------- dlls/dbghelp/pdb.c | 147 +++++++++++++++++++++++++++++++++ dlls/dbghelp/type.c | 9 +- 6 files changed, 221 insertions(+), 63 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 8589a2141d6..7e4f75f863b 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -436,6 +436,10 @@ struct module_format_vtable { /* module handling */ void (*remove)(struct module_format* modfmt); + + /* index management */ + enum method_result (*request_symref_t)(struct module_format *modfmt, symref_t ref, IMAGEHLP_SYMBOL_TYPE_INFO req, void *data); + /* stack walk */ void (*loc_compute)(const struct module_format* modfmt, const struct symt_function* func, @@ -489,6 +493,7 @@ struct module /* specific information for debug types */ struct module_format* format_info[DFI_LAST]; unsigned debug_format_bitmask; + struct module_format *ops_symref_modfmt; /* HACK for fast access to the ops table */
/* memory allocation pool */ struct pool pool; @@ -977,6 +982,8 @@ extern BOOL lineinfo_set_nameA(struct process* pcs, struct lineinfo_t* i
/* type.c */ extern void symt_init_basic(struct module* module); +extern BOOL symt_get_info_raw(struct module* module, const struct symt* type, + IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo); 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, @@ -1064,3 +1071,4 @@ struct pdb_reader; extern BOOL pdb_hack_get_main_info(struct module_format *modfmt, struct pdb_reader **pdb, unsigned *fpoext_stream); extern void pdb_reader_dispose(struct pdb_reader *pdb); extern struct pdb_reader *pdb_hack_reader_init(struct module *module, HANDLE file, const IMAGE_SECTION_HEADER *sections, unsigned num_sections); +extern symref_t cv_hack_ptr_to_symref(struct pdb_reader *pdb, unsigned typeno, struct symt *symt); diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 0a4f62cf7ff..8896e992f50 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -4297,6 +4297,7 @@ static BOOL dwarf2_unload_CU_module(dwarf2_parse_module_context_t* module_ctx) static const struct module_format_vtable dwarf2_module_format_vtable = { dwarf2_module_remove, + NULL, dwarf2_location_compute, };
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index dee356e650a..750d0d08655 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -346,6 +346,14 @@ BOOL module_load_debug(struct module* module) } else ret = module->process->loader->load_debug_info(module->process, module);
+ /* Hack for fast symdef deref... + * Note: if ever we need another backend with dedicated symref_t support, + * we could always use the 3 non-zero lower bits of symref_t to match a + * debug backend. + */ + if (module->format_info[DFI_PDB] && module->format_info[DFI_PDB]->vtable) + module->ops_symref_modfmt = module->format_info[DFI_PDB]; + if (!ret) module->module.SymType = SymNone; assert(module->module.SymType != SymDeferred); module->module.NumSyms = module->ht_symbols.num_elts; diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 5163532a41d..30160da1faf 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -148,7 +148,8 @@ struct cv_defined_module BOOL allowed; unsigned int first_type_index; unsigned int last_type_index; - struct symt** defined_types; + struct symt** defined_types; /* when old reader */ + struct pdb_reader *pdb; /* new reader: hack */ }; /* FIXME: don't make it static */ #define CV_MAX_MODULES 32 @@ -661,6 +662,19 @@ static struct symt* codeview_fetch_type(struct codeview_type_parse* ctp, return symt; }
+static symref_t codeview_fetch_symref(struct codeview_type_parse* ctp, unsigned typeno) +{ + struct symt *symt = codeview_fetch_type(ctp, typeno); + return cv_hack_ptr_to_symref(cv_current_module->pdb, typeno, symt); +} + +static symref_t codeview_get_symref(struct module *module, unsigned typeno, struct symt *symt) +{ + if (!symt) + symt = codeview_get_type(typeno, FALSE); + return cv_hack_ptr_to_symref(module->format_info[DFI_PDB]->u.pdb_info->pdb_files[0].pdb_reader, typeno, symt); +} + static UINT32 codeview_compute_hash(const char* ptr, unsigned len) { const char* last = ptr + len; @@ -964,13 +978,13 @@ static void codeview_add_udt_element(struct codeview_type_parse* ctp, { case LF_BITFIELD_V1: symt_add_udt_element(ctp->module, symt, name, - symt_ptr_to_symref(codeview_fetch_type(ctp, cv_type->bitfield_v1.type)), + codeview_fetch_symref(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, - symt_ptr_to_symref(codeview_fetch_type(ctp, cv_type->bitfield_v2.type)), + codeview_fetch_symref(ctp, cv_type->bitfield_v2.type), value, cv_type->bitfield_v2.bitoff, cv_type->bitfield_v2.nbits); return; @@ -982,7 +996,7 @@ 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, symt_ptr_to_symref(subtype), + symt_add_udt_element(ctp->module, symt, name, codeview_get_symref(ctp->module, type, subtype), value, 0, 0); } } @@ -1521,6 +1535,7 @@ static BOOL codeview_parse_type_table(struct codeview_type_parse* ctp) unsigned int i, curr_type; const union codeview_type* type;
+ cv_current_module->pdb = ctp->module->format_info[DFI_PDB]->u.pdb_info->pdb_files[0].pdb_reader; cv_current_module->first_type_index = ctp->header.first_index; cv_current_module->last_type_index = ctp->header.last_index; cv_current_module->defined_types = calloc(ctp->header.last_index - ctp->header.first_index, @@ -1816,7 +1831,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, - symt_ptr_to_symref(codeview_get_type(symtype, FALSE)), name); + codeview_get_symref(msc_dbg->module, symtype, NULL), name); return; } if (!dontcheck && !in_tls) @@ -1849,7 +1864,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, - symt_ptr_to_symref(codeview_get_type(symtype, FALSE))); + codeview_get_symref(msc_dbg->module, symtype, NULL)); } }
@@ -2184,14 +2199,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, - symt_ptr_to_symref(codeview_get_type(cvt->func_id_v3.type, FALSE)), + codeview_get_symref(msc_dbg->module, cvt->func_id_v3.type, NULL), 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, - symt_ptr_to_symref(codeview_get_type(cvt->mfunc_id_v3.type, FALSE)), + codeview_get_symref(msc_dbg->module, cvt->mfunc_id_v3.type, NULL), num_ranges); break; default: @@ -2309,7 +2324,6 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, struct symt* func_signature; int i, length; struct symt_block* block = NULL; - struct symt* symt; struct symt_compiland* compiland = NULL; struct location loc; unsigned top_frame_size = -1; @@ -2414,7 +2428,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, 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)); + codeview_get_symref(msc_dbg->module, sym->proc_v1.proctype, func_signature)); curr_func = top_func; loc.kind = loc_absolute; loc.offset = sym->proc_v1.debug_start; @@ -2433,7 +2447,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, 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)); + codeview_get_symref(msc_dbg->module, sym->proc_v2.proctype, func_signature)); curr_func = top_func; loc.kind = loc_absolute; loc.offset = sym->proc_v2.debug_start; @@ -2452,7 +2466,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, 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)); + codeview_get_symref(msc_dbg->module, sym->proc_v3.proctype, func_signature)); curr_func = top_func; loc.kind = loc_absolute; loc.offset = sym->proc_v3.debug_start; @@ -2472,7 +2486,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, - symt_ptr_to_symref(codeview_get_type(sym->stack_v1.symtype, FALSE)), + codeview_get_symref(msc_dbg->module, sym->stack_v1.symtype, NULL), terminate_string(&sym->stack_v1.p_name)); break; case S_BPREL32_ST: @@ -2483,7 +2497,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, - symt_ptr_to_symref(codeview_get_type(sym->stack_v2.symtype, FALSE)), + codeview_get_symref(msc_dbg->module, sym->stack_v2.symtype, NULL), terminate_string(&sym->stack_v2.p_name)); break; case S_BPREL32: @@ -2496,7 +2510,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, - symt_ptr_to_symref(codeview_get_type(sym->stack_v3.symtype, FALSE)), + codeview_get_symref(msc_dbg->module, sym->stack_v3.symtype, NULL), sym->stack_v3.name); break; case S_REGREL32: @@ -2509,7 +2523,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, - symt_ptr_to_symref(codeview_get_type(sym->regrel_v3.symtype, FALSE)), + codeview_get_symref(msc_dbg->module, sym->regrel_v3.symtype, NULL), sym->regrel_v3.name); break;
@@ -2519,7 +2533,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, loc.offset = 0; symt_add_func_local(msc_dbg->module, curr_func, DataIsLocal, &loc, block, - symt_ptr_to_symref(codeview_get_type(sym->register_v1.type, FALSE)), + codeview_get_symref(msc_dbg->module, sym->register_v1.type, NULL), terminate_string(&sym->register_v1.p_name)); break; case S_REGISTER_ST: @@ -2528,7 +2542,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, loc.offset = 0; symt_add_func_local(msc_dbg->module, curr_func, DataIsLocal, &loc, block, - symt_ptr_to_symref(codeview_get_type(sym->register_v2.type, FALSE)), + codeview_get_symref(msc_dbg->module, sym->register_v2.type, NULL), terminate_string(&sym->register_v2.p_name)); break; case S_REGISTER: @@ -2539,7 +2553,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, loc.offset = 0; symt_add_func_local(msc_dbg->module, curr_func, DataIsLocal, &loc, block, - symt_ptr_to_symref(codeview_get_type(sym->register_v3.type, FALSE)), + codeview_get_symref(msc_dbg->module, sym->register_v3.type, NULL), sym->register_v3.name); break;
@@ -2630,81 +2644,65 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, { int vlen; const struct p_string* name; - struct symt* se; VARIANT v;
vlen = leaf_as_variant(&v, sym->constant_v1.data); name = (const struct p_string*)&sym->constant_v1.data[vlen]; - se = codeview_get_type(sym->constant_v1.type, FALSE);
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), - symt_ptr_to_symref(se), &v); + codeview_get_symref(msc_dbg->module, sym->constant_v1.type, NULL), &v); } break; case S_CONSTANT_ST: { int vlen; const struct p_string* name; - struct symt* se; VARIANT v;
vlen = leaf_as_variant(&v, sym->constant_v2.data); name = (const struct p_string*)&sym->constant_v2.data[vlen]; - se = codeview_get_type(sym->constant_v2.type, FALSE);
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), - symt_ptr_to_symref(se), &v); + codeview_get_symref(msc_dbg->module, sym->constant_v2.type, NULL), &v); } break; case S_CONSTANT: { int vlen; const char* name; - struct symt* se; VARIANT v;
vlen = leaf_as_variant(&v, sym->constant_v3.data); name = (const char*)&sym->constant_v3.data[vlen]; - se = codeview_get_type(sym->constant_v3.type, FALSE);
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, symt_ptr_to_symref(se), &v); + symt_new_constant(msc_dbg->module, compiland, name, + codeview_get_symref(msc_dbg->module, sym->constant_v3.type, NULL), &v); } break;
case S_UDT_16t: if (sym->udt_v1.type) { - if ((symt = codeview_get_type(sym->udt_v1.type, FALSE))) - 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", - terminate_string(&sym->udt_v1.p_name), sym->udt_v1.type); + symt_new_typedef(msc_dbg->module, codeview_get_symref(msc_dbg->module, sym->udt_v1.type, NULL), + terminate_string(&sym->udt_v1.p_name)); } break; case S_UDT_ST: if (sym->udt_v2.type) { - if ((symt = codeview_get_type(sym->udt_v2.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), + symt_new_typedef(msc_dbg->module, codeview_get_symref(msc_dbg->module, sym->udt_v2.type, NULL), terminate_string(&sym->udt_v2.p_name)); - else - FIXME("S-Udt %s: couldn't find type 0x%x\n", - terminate_string(&sym->udt_v2.p_name), sym->udt_v2.type); } break; case S_UDT: if (sym->udt_v3.type) { - if ((symt = codeview_get_type(sym->udt_v3.type, FALSE))) - 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); + symt_new_typedef(msc_dbg->module, codeview_get_symref(msc_dbg->module, sym->udt_v3.type, NULL), + sym->udt_v3.name); } break; case S_LOCAL: @@ -2726,7 +2724,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, - symt_ptr_to_symref(codeview_get_type(sym->local_v3.symtype, FALSE)), + codeview_get_symref(msc_dbg->module, sym->local_v3.symtype, NULL), sym->local_v3.name); } else @@ -2981,39 +2979,27 @@ static BOOL codeview_snarf_sym_hashtable(const struct msc_debug_info* msc_dbg, c
static BOOL pdb_global_feed_types(const struct msc_debug_info* msc_dbg, const union codeview_symbol* sym) { - struct symt* symt; switch (sym->generic.id) { case S_UDT_16t: if (sym->udt_v1.type) { - if ((symt = codeview_get_type(sym->udt_v1.type, FALSE))) - symt_new_typedef(msc_dbg->module, symt_ptr_to_symref(symt), + symt_new_typedef(msc_dbg->module, codeview_get_symref(msc_dbg->module, sym->udt_v1.type, NULL), terminate_string(&sym->udt_v1.p_name)); - else - FIXME("S-Udt %s: couldn't find type 0x%x\n", - terminate_string(&sym->udt_v1.p_name), sym->udt_v1.type); } break; case S_UDT_ST: if (sym->udt_v2.type) { - if ((symt = codeview_get_type(sym->udt_v2.type, FALSE))) - 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", - terminate_string(&sym->udt_v2.p_name), sym->udt_v2.type); + symt_new_typedef(msc_dbg->module, codeview_get_symref(msc_dbg->module, sym->udt_v2.type, NULL), + terminate_string(&sym->udt_v2.p_name)); } break; case S_UDT: if (sym->udt_v3.type) { - if ((symt = codeview_get_type(sym->udt_v3.type, FALSE))) - 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); + symt_new_typedef(msc_dbg->module, codeview_get_symref(msc_dbg->module, sym->udt_v3.type, NULL), + sym->udt_v3.name); } break; default: return FALSE; @@ -3998,6 +3984,7 @@ static BOOL pdb_process_internal(const struct process *pcs, static const struct module_format_vtable old_pdb_module_format_vtable = { pdb_module_remove, + NULL, pdb_location_compute, };
diff --git a/dlls/dbghelp/pdb.c b/dlls/dbghelp/pdb.c index 6276ee41ee3..203491e3cd8 100644 --- a/dlls/dbghelp/pdb.c +++ b/dlls/dbghelp/pdb.c @@ -1149,9 +1149,156 @@ static void pdb_method_location_compute(const struct module_format *modfmt, loc->reg = loc_err_out_of_scope; }
+static symref_t encode_symref(unsigned v) +{ + return (v << 2) | 1; +} + +static inline unsigned decode_symref(symref_t ref) +{ + return ref >> 2; +} + +static struct {enum BasicType bt; unsigned char size;} supported_basic[T_MAXBASICTYPE] = +{ + /* all others are defined as 0 = btNoType */ + [T_VOID] = {btVoid, 0}, + [T_CURRENCY] = {btCurrency, 8}, + [T_CHAR] = {btInt, 1}, + [T_SHORT] = {btInt, 2}, + [T_LONG] = {btLong, 4}, + [T_QUAD] = {btInt, 8}, + [T_OCT] = {btInt, 16}, + [T_UCHAR] = {btUInt, 1}, + [T_USHORT] = {btUInt, 2}, + [T_ULONG] = {btULong, 4}, + [T_UQUAD] = {btUInt, 8}, + [T_UOCT] = {btUInt, 16}, + [T_BOOL08] = {btBool, 1}, + [T_BOOL16] = {btBool, 2}, + [T_BOOL32] = {btBool, 4}, + [T_BOOL64] = {btBool, 8}, + [T_REAL16] = {btFloat, 2}, + [T_REAL32] = {btFloat, 4}, + [T_REAL64] = {btFloat, 8}, + [T_REAL80] = {btFloat, 10}, + [T_REAL128] = {btFloat, 16}, + [T_RCHAR] = {btChar, 1}, + [T_WCHAR] = {btWChar, 2}, + [T_CHAR16] = {btChar16, 2}, + [T_CHAR32] = {btChar32, 4}, + [T_CHAR8] = {btChar8, 1}, + [T_INT2] = {btInt, 2}, + [T_UINT2] = {btUInt, 2}, + [T_INT4] = {btInt, 4}, + [T_UINT4] = {btUInt, 4}, + [T_INT8] = {btInt, 8}, + [T_UINT8] = {btUInt, 8}, + [T_HRESULT] = {btUInt, 4}, + [T_CPLX32] = {btComplex, 8}, + [T_CPLX64] = {btComplex, 16}, + [T_CPLX128] = {btComplex, 32}, +}; + +static inline BOOL is_basic_supported(unsigned basic) +{ + return basic <= T_MAXBASICTYPE && supported_basic[basic].bt != btNoType; +} + +static enum method_result pdb_reader_default_request(struct pdb_reader *pdb, IMAGEHLP_SYMBOL_TYPE_INFO req, void *data) +{ + switch (req) + { + case TI_FINDCHILDREN: + return ((TI_FINDCHILDREN_PARAMS*)data)->Count == 0 ? MR_SUCCESS : MR_FAILURE; + case TI_GET_CHILDRENCOUNT: + *((DWORD*)data) = 0; + return MR_SUCCESS; + case TI_GET_LEXICALPARENT: + *((DWORD*)data) = symt_ptr_to_index(pdb->module, &pdb->module->top->symt); + return MR_SUCCESS; + default: + FIXME("Unexpected request %x\n", req); + return MR_FAILURE; + } +} + +static enum method_result pdb_reader_basic_request(struct pdb_reader *pdb, unsigned basic, IMAGEHLP_SYMBOL_TYPE_INFO req, void *data) +{ + if (!is_basic_supported(basic & T_BASICTYPE_MASK)) + { + FIXME("Unsupported basic type %x\n", basic); + return MR_FAILURE; + } + + switch (req) + { + case TI_GET_BASETYPE: + if (basic >= T_MAXBASICTYPE) return MR_FAILURE; + *((DWORD*)data) = supported_basic[basic].bt; + break; + case TI_GET_LENGTH: + switch (basic & T_MODE_MASK) + { + case 0: *((DWORD64*)data) = supported_basic[basic].size; break; + /* pointer type */ + case T_NEARPTR_BITS: *((DWORD64*)data) = pdb->module->cpu->word_size; break; + case T_NEAR32PTR_BITS: *((DWORD64*)data) = 4; break; + case T_NEAR64PTR_BITS: *((DWORD64*)data) = 8; break; + default: return MR_FAILURE; + } + break; + case TI_GET_SYMTAG: + *((DWORD*)data) = (basic < T_MAXBASICTYPE) ? SymTagBaseType : SymTagPointerType; + break; + case TI_GET_TYPE: + case TI_GET_TYPEID: + if (basic < T_MAXBASICTYPE) return MR_FAILURE; + *((DWORD*)data) = encode_symref(basic & T_BASICTYPE_MASK); + break; + case TI_FINDCHILDREN: + case TI_GET_CHILDRENCOUNT: + case TI_GET_LEXICALPARENT: + return pdb_reader_default_request(pdb, req, data); + default: return MR_FAILURE; + } + return MR_SUCCESS; +} + +static enum method_result pdb_method_request_symref_t(struct module_format *modfmt, symref_t ref, IMAGEHLP_SYMBOL_TYPE_INFO req, void *data) +{ + struct pdb_reader *pdb; + cv_typ_t cv_typeid; + + if (!pdb_hack_get_main_info(modfmt, &pdb, NULL)) return MR_FAILURE; + if (req == TI_GET_SYMINDEX) + { + *((DWORD*)data) = ref; + return MR_SUCCESS; + } + cv_typeid = decode_symref(ref); + if (cv_typeid < T_MAXPREDEFINEDTYPE) + return pdb_reader_basic_request(pdb, cv_typeid, req, data); + return MR_NOT_FOUND; +} + +symref_t cv_hack_ptr_to_symref(struct pdb_reader *pdb, cv_typ_t cv_typeid, struct symt *symt) +{ + if (pdb) + { + if (symt_check_tag(symt, SymTagBaseType)) + { + if (cv_typeid < T_MAXPREDEFINEDTYPE) + return encode_symref(cv_typeid); + } + } + return symt_ptr_to_symref(symt); +} + static struct module_format_vtable pdb_module_format_vtable = { NULL,/*pdb_module_remove*/ + pdb_method_request_symref_t, pdb_method_location_compute, pdb_method_get_line_from_address, pdb_method_advance_line_info, diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 6d3312fa108..8d542fe8a7a 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -1120,7 +1120,14 @@ BOOL symt_get_info_from_index(struct module* module, DWORD index, 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); + if (symt_is_symref_ptr(ref)) + return symt_get_info(module, (struct symt *)ref, req, pInfo); + if (module->ops_symref_modfmt) + { + enum method_result result = module->ops_symref_modfmt->vtable->request_symref_t(module->ops_symref_modfmt, ref, req, pInfo); + if (result == MR_SUCCESS) return TRUE; + } + return FALSE; }
/******************************************************************