dbghelp: Wrap the symt* <=> index transformations.

This commit is contained in:
Eric Pouech 2009-12-14 22:05:46 +01:00 committed by Alexandre Julliard
parent 07c1a1ca51
commit 92b9b0940d
8 changed files with 89 additions and 69 deletions

View File

@ -395,6 +395,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg)
{ {
if (coff_files.files[j].entries != NULL) if (coff_files.files[j].entries != NULL)
{ {
symt_cmp_addr_module = msc_dbg->module;
qsort(coff_files.files[j].entries, coff_files.files[j].neps, qsort(coff_files.files[j].entries, coff_files.files[j].neps,
sizeof(struct symt*), symt_cmp_addr); sizeof(struct symt*), symt_cmp_addr);
} }
@ -419,7 +420,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg)
for (;;) for (;;)
{ {
if (l+1 >= coff_files.files[j].neps) break; if (l+1 >= coff_files.files[j].neps) break;
symt_get_info(coff_files.files[j].entries[l+1], TI_GET_ADDRESS, &addr); symt_get_info(msc_dbg->module, coff_files.files[j].entries[l+1], TI_GET_ADDRESS, &addr);
if (((msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress) < addr)) if (((msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress) < addr))
break; break;
l++; l++;
@ -432,7 +433,7 @@ BOOL coff_process_info(const struct msc_debug_info* msc_dbg)
* start of the function, so we need to subtract that offset * start of the function, so we need to subtract that offset
* first. * first.
*/ */
symt_get_info(coff_files.files[j].entries[l+1], TI_GET_ADDRESS, &addr); symt_get_info(msc_dbg->module, coff_files.files[j].entries[l+1], TI_GET_ADDRESS, &addr);
symt_add_func_line(msc_dbg->module, (struct symt_function*)coff_files.files[j].entries[l+1], symt_add_func_line(msc_dbg->module, (struct symt_function*)coff_files.files[j].entries[l+1],
coff_files.files[j].compiland->source, linepnt->Linenumber, coff_files.files[j].compiland->source, linepnt->Linenumber,
msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress - addr); msc_dbg->module->module.BaseOfImage + linepnt->Type.VirtualAddress - addr);

View File

@ -418,6 +418,16 @@ struct pdb_lookup
} u; } u;
}; };
static inline DWORD symt_ptr2index(struct module* module, const struct symt* sym)
{
return (DWORD)sym;
}
static inline struct symt* symt_index2ptr(struct module* module, DWORD id)
{
return (struct symt*)id;
}
/* dbghelp.c */ /* dbghelp.c */
extern struct process* process_find_by_handle(HANDLE hProcess); extern struct process* process_find_by_handle(HANDLE hProcess);
extern HANDLE hMsvcrt; extern HANDLE hMsvcrt;
@ -533,6 +543,7 @@ extern BOOL dwarf2_parse(struct module* module, unsigned long load_offse
/* symbol.c */ /* symbol.c */
extern const char* symt_get_name(const struct symt* sym); extern const char* symt_get_name(const struct symt* sym);
extern struct module* symt_cmp_addr_module;
extern int symt_cmp_addr(const void* p1, const void* p2); extern int symt_cmp_addr(const void* p1, const void* p2);
extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si); extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si);
extern struct symt_ht* extern struct symt_ht*
@ -606,7 +617,7 @@ extern struct symt_hierarchy_point*
/* type.c */ /* type.c */
extern void symt_init_basic(struct module* module); extern void symt_init_basic(struct module* module);
extern BOOL symt_get_info(const struct symt* type, extern BOOL symt_get_info(struct module* module, const struct symt* type,
IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo); IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo);
extern struct symt_basic* extern struct symt_basic*
symt_new_basic(struct module* module, enum BasicType, symt_new_basic(struct module* module, enum BasicType,

View File

@ -1182,7 +1182,8 @@ static void dwarf2_parse_udt_member(dwarf2_parse_context_t* ctx,
if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &nbytes)) if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &nbytes))
{ {
DWORD64 size; DWORD64 size;
nbytes.u.uvalue = symt_get_info(elt_type, TI_GET_LENGTH, &size) ? (unsigned long)size : 0; nbytes.u.uvalue = symt_get_info(ctx->module, elt_type, TI_GET_LENGTH, &size) ?
(unsigned long)size : 0;
} }
bit_offset.u.uvalue = nbytes.u.uvalue * 8 - bit_offset.u.uvalue - bit_size.u.uvalue; bit_offset.u.uvalue = nbytes.u.uvalue * 8 - bit_offset.u.uvalue - bit_size.u.uvalue;
} }

View File

@ -669,7 +669,7 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h
ULONG64 ref_addr; ULONG64 ref_addr;
symt = symt_find_nearest(module, addr); symt = symt_find_nearest(module, addr);
if (symt && !symt_get_info(&symt->symt, TI_GET_ADDRESS, &ref_addr)) if (symt && !symt_get_info(module, &symt->symt, TI_GET_ADDRESS, &ref_addr))
ref_addr = addr; ref_addr = addr;
if (!symt || addr != ref_addr) if (!symt || addr != ref_addr)
{ {
@ -706,9 +706,9 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h
ULONG64 xaddr = 0, xsize = 0; ULONG64 xaddr = 0, xsize = 0;
DWORD kind = -1; DWORD kind = -1;
symt_get_info(&symt->symt, TI_GET_ADDRESS, &xaddr); symt_get_info(module, &symt->symt, TI_GET_ADDRESS, &xaddr);
symt_get_info(&symt->symt, TI_GET_LENGTH, &xsize); symt_get_info(module, &symt->symt, TI_GET_LENGTH, &xsize);
symt_get_info(&symt->symt, TI_GET_DATAKIND, &kind); symt_get_info(module, &symt->symt, TI_GET_DATAKIND, &kind);
/* If none of symbols has a correct size, we consider they are both markers /* If none of symbols has a correct size, we consider they are both markers
* Hence, we can silence this warning * Hence, we can silence this warning

View File

@ -667,7 +667,7 @@ static void codeview_add_udt_element(struct codeview_type_parse* ctp,
if (subtype) if (subtype)
{ {
DWORD64 elem_size = 0; DWORD64 elem_size = 0;
symt_get_info(subtype, TI_GET_LENGTH, &elem_size); symt_get_info(ctp->module, subtype, TI_GET_LENGTH, &elem_size);
symt_add_udt_element(ctp->module, symt, name, subtype, symt_add_udt_element(ctp->module, symt, name, subtype,
value << 3, (DWORD)elem_size << 3); value << 3, (DWORD)elem_size << 3);
} }

View File

@ -666,7 +666,7 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd,
* As we don't use much the size of members in structs, this may not * As we don't use much the size of members in structs, this may not
* be much of a problem * be much of a problem
*/ */
symt_get_info(adt, TI_GET_LENGTH, &size); symt_get_info(ptd->module, adt, TI_GET_LENGTH, &size);
symt_add_udt_element(ptd->module, sdt, tmp, adt, ofs, (DWORD)size * 8); symt_add_udt_element(ptd->module, sdt, tmp, adt, ofs, (DWORD)size * 8);
} }
PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); PTS_ABORTIF(ptd, *ptd->ptr++ != ';');

View File

@ -48,22 +48,24 @@ static inline int cmp_addr(ULONG64 a1, ULONG64 a2)
return 0; return 0;
} }
static inline int cmp_sorttab_addr(const struct module* module, int idx, ULONG64 addr) static inline int cmp_sorttab_addr(struct module* module, int idx, ULONG64 addr)
{ {
ULONG64 ref; ULONG64 ref;
symt_get_info(&module->addr_sorttab[idx]->symt, TI_GET_ADDRESS, &ref); symt_get_info(module, &module->addr_sorttab[idx]->symt, TI_GET_ADDRESS, &ref);
return cmp_addr(ref, addr); return cmp_addr(ref, addr);
} }
struct module* symt_cmp_addr_module = NULL;
int symt_cmp_addr(const void* p1, const void* p2) int symt_cmp_addr(const void* p1, const void* p2)
{ {
const struct symt* sym1 = *(const struct symt* const *)p1; const struct symt* sym1 = *(const struct symt* const *)p1;
const struct symt* sym2 = *(const struct symt* const *)p2; const struct symt* sym2 = *(const struct symt* const *)p2;
ULONG64 a1, a2; ULONG64 a1, a2;
symt_get_info(sym1, TI_GET_ADDRESS, &a1); symt_get_info(symt_cmp_addr_module, sym1, TI_GET_ADDRESS, &a1);
symt_get_info(sym2, TI_GET_ADDRESS, &a2); symt_get_info(symt_cmp_addr_module, sym2, TI_GET_ADDRESS, &a2);
return cmp_addr(a1, a2); return cmp_addr(a1, a2);
} }
@ -98,7 +100,7 @@ static void symt_add_module_ht(struct module* module, struct symt_ht* ht)
/* Don't store in sorttab a symbol without address, they are of /* Don't store in sorttab a symbol without address, they are of
* no use here (e.g. constant values) * no use here (e.g. constant values)
*/ */
if (symt_get_info(&ht->symt, TI_GET_ADDRESS, &addr) && if (symt_get_info(module, &ht->symt, TI_GET_ADDRESS, &addr) &&
symt_grow_sorttab(module, module->num_symbols + 1)) symt_grow_sorttab(module, module->num_symbols + 1))
{ {
module->addr_sorttab[module->num_symbols++] = ht; module->addr_sorttab[module->num_symbols++] = ht;
@ -321,7 +323,7 @@ struct symt_data* symt_new_global_variable(struct module* module,
sym->container = compiland ? &compiland->symt : NULL; sym->container = compiland ? &compiland->symt : NULL;
sym->type = type; sym->type = type;
sym->u.var.offset = addr; sym->u.var.offset = addr;
if (type && size && symt_get_info(type, TI_GET_LENGTH, &tsz)) if (type && size && symt_get_info(module, type, TI_GET_LENGTH, &tsz))
{ {
if (tsz != size) if (tsz != size)
FIXME("Size mismatch for %s.%s between type (%s) and src (%lu)\n", FIXME("Size mismatch for %s.%s between type (%s) and src (%lu)\n",
@ -627,20 +629,21 @@ struct symt_hierarchy_point* symt_new_label(struct module* module,
} }
/* expect sym_info->MaxNameLen to be set before being called */ /* expect sym_info->MaxNameLen to be set before being called */
static void symt_fill_sym_info(const struct module_pair* pair, static void symt_fill_sym_info(struct module_pair* pair,
const struct symt_function* func, const struct symt_function* func,
const struct symt* sym, SYMBOL_INFO* sym_info) const struct symt* sym, SYMBOL_INFO* sym_info)
{ {
const char* name; const char* name;
DWORD64 size; DWORD64 size;
if (!symt_get_info(sym, TI_GET_TYPE, &sym_info->TypeIndex)) if (!symt_get_info(pair->effective, sym, TI_GET_TYPE, &sym_info->TypeIndex))
sym_info->TypeIndex = 0; sym_info->TypeIndex = 0;
sym_info->info = (DWORD)sym; sym_info->info = symt_ptr2index(pair->effective, sym);
sym_info->Reserved[0] = sym_info->Reserved[1] = 0; sym_info->Reserved[0] = sym_info->Reserved[1] = 0;
if (!symt_get_info(sym, TI_GET_LENGTH, &size) && if (!symt_get_info(pair->effective, sym, TI_GET_LENGTH, &size) &&
(!sym_info->TypeIndex || (!sym_info->TypeIndex ||
!symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size))) !symt_get_info(pair->effective, symt_index2ptr(pair->effective, sym_info->TypeIndex),
TI_GET_LENGTH, &size)))
size = 0; size = 0;
sym_info->Size = (DWORD)size; sym_info->Size = (DWORD)size;
sym_info->ModBase = pair->requested->module.BaseOfImage; sym_info->ModBase = pair->requested->module.BaseOfImage;
@ -689,7 +692,7 @@ static void symt_fill_sym_info(const struct module_pair* pair,
break; break;
case DataIsGlobal: case DataIsGlobal:
case DataIsFileStatic: case DataIsFileStatic:
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address); symt_get_info(pair->effective, sym, TI_GET_ADDRESS, &sym_info->Address);
sym_info->Register = 0; sym_info->Register = 0;
break; break;
case DataIsConstant: case DataIsConstant:
@ -717,18 +720,18 @@ static void symt_fill_sym_info(const struct module_pair* pair,
break; break;
case SymTagPublicSymbol: case SymTagPublicSymbol:
sym_info->Flags |= SYMFLAG_EXPORT; sym_info->Flags |= SYMFLAG_EXPORT;
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address); symt_get_info(pair->effective, sym, TI_GET_ADDRESS, &sym_info->Address);
break; break;
case SymTagFunction: case SymTagFunction:
sym_info->Flags |= SYMFLAG_FUNCTION; sym_info->Flags |= SYMFLAG_FUNCTION;
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address); symt_get_info(pair->effective, sym, TI_GET_ADDRESS, &sym_info->Address);
break; break;
case SymTagThunk: case SymTagThunk:
sym_info->Flags |= SYMFLAG_THUNK; sym_info->Flags |= SYMFLAG_THUNK;
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address); symt_get_info(pair->effective, sym, TI_GET_ADDRESS, &sym_info->Address);
break; break;
default: default:
symt_get_info(sym, TI_GET_ADDRESS, &sym_info->Address); symt_get_info(pair->effective, sym, TI_GET_ADDRESS, &sym_info->Address);
sym_info->Register = 0; sym_info->Register = 0;
break; break;
} }
@ -762,7 +765,7 @@ struct sym_enum
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
}; };
static BOOL send_symbol(const struct sym_enum* se, const struct module_pair* pair, static BOOL send_symbol(const struct sym_enum* se, struct module_pair* pair,
const struct symt_function* func, const struct symt* sym) const struct symt_function* func, const struct symt* sym)
{ {
symt_fill_sym_info(pair, func, sym, se->sym_info); symt_fill_sym_info(pair, func, sym, se->sym_info);
@ -772,7 +775,7 @@ static BOOL send_symbol(const struct sym_enum* se, const struct module_pair* pai
return !se->cb(se->sym_info, se->sym_info->Size, se->user); return !se->cb(se->sym_info, se->sym_info->Size, se->user);
} }
static BOOL symt_enum_module(const struct module_pair* pair, const regex_t* regex, static BOOL symt_enum_module(struct module_pair* pair, const regex_t* regex,
const struct sym_enum* se) const struct sym_enum* se)
{ {
void* ptr; void* ptr;
@ -793,13 +796,13 @@ static BOOL symt_enum_module(const struct module_pair* pair, const regex_t* rege
return FALSE; return FALSE;
} }
static inline unsigned where_to_insert(const struct module* module, unsigned high, const struct symt_ht* elt) static inline unsigned where_to_insert(struct module* module, unsigned high, const struct symt_ht* elt)
{ {
unsigned low = 0, mid = high / 2; unsigned low = 0, mid = high / 2;
ULONG64 addr; ULONG64 addr;
if (!high) return 0; if (!high) return 0;
symt_get_info(&elt->symt, TI_GET_ADDRESS, &addr); symt_get_info(module, &elt->symt, TI_GET_ADDRESS, &addr);
do do
{ {
switch (cmp_sorttab_addr(module, mid, addr)) switch (cmp_sorttab_addr(module, mid, addr))
@ -831,6 +834,7 @@ static BOOL resort_symbols(struct module* module)
delta = module->num_symbols - module->num_sorttab; delta = module->num_symbols - module->num_sorttab;
memcpy(tmp, &module->addr_sorttab[module->num_sorttab], delta * sizeof(struct symt_ht*)); memcpy(tmp, &module->addr_sorttab[module->num_sorttab], delta * sizeof(struct symt_ht*));
symt_cmp_addr_module = module;
qsort(tmp, delta, sizeof(struct symt_ht*), symt_cmp_addr); qsort(tmp, delta, sizeof(struct symt_ht*), symt_cmp_addr);
for (i = delta - 1; i >= 0; i--) for (i = delta - 1; i >= 0; i--)
@ -844,20 +848,23 @@ static BOOL resort_symbols(struct module* module)
} }
} }
else else
{
symt_cmp_addr_module = module;
qsort(module->addr_sorttab, module->num_symbols, sizeof(struct symt_ht*), symt_cmp_addr); qsort(module->addr_sorttab, module->num_symbols, sizeof(struct symt_ht*), symt_cmp_addr);
}
module->num_sorttab = module->num_symbols; module->num_sorttab = module->num_symbols;
return module->sortlist_valid = TRUE; return module->sortlist_valid = TRUE;
} }
static void symt_get_length(const struct symt* symt, ULONG64* size) static void symt_get_length(struct module* module, const struct symt* symt, ULONG64* size)
{ {
DWORD type_index; DWORD type_index;
if (symt_get_info(symt, TI_GET_LENGTH, size) && *size) if (symt_get_info(module, symt, TI_GET_LENGTH, size) && *size)
return; return;
if (symt_get_info(symt, TI_GET_TYPE, &type_index) && if (symt_get_info(module, symt, TI_GET_TYPE, &type_index) &&
symt_get_info((struct symt*)type_index, TI_GET_LENGTH, size)) return; symt_get_info(module, symt_index2ptr(module, type_index), TI_GET_LENGTH, size)) return;
*size = 0x1000; /* arbitrary value */ *size = 0x1000; /* arbitrary value */
} }
@ -878,12 +885,12 @@ struct symt_ht* symt_find_nearest(struct module* module, DWORD addr)
low = 0; low = 0;
high = module->num_sorttab; high = module->num_sorttab;
symt_get_info(&module->addr_sorttab[0]->symt, TI_GET_ADDRESS, &ref_addr); symt_get_info(module, &module->addr_sorttab[0]->symt, TI_GET_ADDRESS, &ref_addr);
if (addr < ref_addr) return NULL; if (addr < ref_addr) return NULL;
if (high) if (high)
{ {
symt_get_info(&module->addr_sorttab[high - 1]->symt, TI_GET_ADDRESS, &ref_addr); symt_get_info(module, &module->addr_sorttab[high - 1]->symt, TI_GET_ADDRESS, &ref_addr);
symt_get_length(&module->addr_sorttab[high - 1]->symt, &ref_size); symt_get_length(module, &module->addr_sorttab[high - 1]->symt, &ref_size);
if (addr >= ref_addr + ref_size) return NULL; if (addr >= ref_addr + ref_size) return NULL;
} }
@ -904,7 +911,7 @@ struct symt_ht* symt_find_nearest(struct module* module, DWORD addr)
*/ */
if (module->addr_sorttab[low]->symt.tag == SymTagPublicSymbol) if (module->addr_sorttab[low]->symt.tag == SymTagPublicSymbol)
{ {
symt_get_info(&module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr); symt_get_info(module, &module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr);
if (low > 0 && if (low > 0 &&
module->addr_sorttab[low - 1]->symt.tag != SymTagPublicSymbol && module->addr_sorttab[low - 1]->symt.tag != SymTagPublicSymbol &&
!cmp_sorttab_addr(module, low - 1, ref_addr)) !cmp_sorttab_addr(module, low - 1, ref_addr))
@ -915,9 +922,9 @@ struct symt_ht* symt_find_nearest(struct module* module, DWORD addr)
low++; low++;
} }
/* finally check that we fit into the found symbol */ /* finally check that we fit into the found symbol */
symt_get_info(&module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr); symt_get_info(module, &module->addr_sorttab[low]->symt, TI_GET_ADDRESS, &ref_addr);
if (addr < ref_addr) return NULL; if (addr < ref_addr) return NULL;
symt_get_length(&module->addr_sorttab[low]->symt, &ref_size); symt_get_length(module, &module->addr_sorttab[low]->symt, &ref_size);
if (addr >= ref_addr + ref_size) return NULL; if (addr >= ref_addr + ref_size) return NULL;
return module->addr_sorttab[low]; return module->addr_sorttab[low];

View File

@ -304,7 +304,7 @@ struct symt_array* symt_new_array(struct module* module, int min, int max,
return sym; return sym;
} }
static inline DWORD symt_array_count(const struct symt_array* array) static inline DWORD symt_array_count(struct module* module, const struct symt_array* array)
{ {
if (array->end < 0) if (array->end < 0)
{ {
@ -312,7 +312,7 @@ static inline DWORD symt_array_count(const struct symt_array* array)
/* One could want to also set the array->end field in array, but we won't do it /* One could want to also set the array->end field in array, but we won't do it
* as long as all the get_type() helpers use const objects * as long as all the get_type() helpers use const objects
*/ */
if (symt_get_info(array->base_type, TI_GET_LENGTH, &elem_size) && elem_size) if (symt_get_info(module, array->base_type, TI_GET_LENGTH, &elem_size) && elem_size)
return -array->end / (DWORD)elem_size; return -array->end / (DWORD)elem_size;
return 0; return 0;
} }
@ -415,9 +415,9 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll,
for (i=0; i<vector_length(&pair.effective->vtypes); i++) for (i=0; i<vector_length(&pair.effective->vtypes); i++)
{ {
type = *(struct symt**)vector_at(&pair.effective->vtypes, i); type = *(struct symt**)vector_at(&pair.effective->vtypes, i);
sym_info->TypeIndex = (DWORD)type; sym_info->TypeIndex = symt_ptr2index(pair.effective, type);
sym_info->info = 0; /* FIXME */ sym_info->info = 0; /* FIXME */
symt_get_info(type, TI_GET_LENGTH, &size); symt_get_info(pair.effective, type, TI_GET_LENGTH, &size);
sym_info->Size = size; sym_info->Size = size;
sym_info->ModBase = pair.requested->module.BaseOfImage; sym_info->ModBase = pair.requested->module.BaseOfImage;
sym_info->Flags = 0; /* FIXME */ sym_info->Flags = 0; /* FIXME */
@ -477,8 +477,8 @@ BOOL WINAPI SymEnumTypesW(HANDLE hProcess, ULONG64 BaseOfDll,
* *
* Retrieves information about a symt (either symbol or type) * Retrieves information about a symt (either symbol or type)
*/ */
BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req, BOOL symt_get_info(struct module* module, const struct symt* type,
void* pInfo) IMAGEHLP_SYMBOL_TYPE_INFO req, void* pInfo)
{ {
unsigned len; unsigned len;
@ -510,7 +510,7 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
for (i = 0; i < tifp->Count; i++) for (i = 0; i < tifp->Count; i++)
{ {
if (!(pt = vector_at(v, tifp->Start + i))) return FALSE; if (!(pt = vector_at(v, tifp->Start + i))) return FALSE;
tifp->ChildId[i] = (DWORD)*pt; tifp->ChildId[i] = symt_ptr2index(module, *pt);
} }
} }
break; break;
@ -537,7 +537,7 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
case SymTagFuncDebugStart: case SymTagFuncDebugStart:
case SymTagFuncDebugEnd: case SymTagFuncDebugEnd:
case SymTagLabel: case SymTagLabel:
if (!symt_get_info(((const struct symt_hierarchy_point*)type)->parent, if (!symt_get_info(module, ((const struct symt_hierarchy_point*)type)->parent,
req, pInfo)) req, pInfo))
return FALSE; return FALSE;
X(ULONG64) += ((const struct symt_hierarchy_point*)type)->loc.offset; X(ULONG64) += ((const struct symt_hierarchy_point*)type)->loc.offset;
@ -612,7 +612,7 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
switch (type->tag) switch (type->tag)
{ {
case SymTagArrayType: case SymTagArrayType:
X(DWORD) = symt_array_count((const struct symt_array*)type); X(DWORD) = symt_array_count(module, (const struct symt_array*)type);
break; break;
case SymTagFunctionType: case SymTagFunctionType:
/* this seems to be wrong for (future) C++ methods, where 'this' parameter /* this seems to be wrong for (future) C++ methods, where 'this' parameter
@ -653,17 +653,17 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
return FALSE; return FALSE;
X(DWORD64) = ((const struct symt_data*)type)->u.member.length; X(DWORD64) = ((const struct symt_data*)type)->u.member.length;
break; break;
case SymTagArrayType: case SymTagArrayType:
if (!symt_get_info(((const struct symt_array*)type)->base_type, if (!symt_get_info(module, ((const struct symt_array*)type)->base_type,
TI_GET_LENGTH, pInfo)) TI_GET_LENGTH, pInfo))
return FALSE; return FALSE;
X(DWORD64) *= symt_array_count((const struct symt_array*)type); X(DWORD64) *= symt_array_count(module, (const struct symt_array*)type);
break; break;
case SymTagPublicSymbol: case SymTagPublicSymbol:
X(DWORD64) = ((const struct symt_public*)type)->size; X(DWORD64) = ((const struct symt_public*)type)->size;
break; break;
case SymTagTypedef: case SymTagTypedef:
return symt_get_info(((const struct symt_typedef*)type)->type, TI_GET_LENGTH, pInfo); return symt_get_info(module, ((const struct symt_typedef*)type)->type, TI_GET_LENGTH, pInfo);
case SymTagThunk: case SymTagThunk:
X(DWORD64) = ((const struct symt_thunk*)type)->size; X(DWORD64) = ((const struct symt_thunk*)type)->size;
break; break;
@ -683,19 +683,19 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
switch (type->tag) switch (type->tag)
{ {
case SymTagBlock: case SymTagBlock:
X(DWORD) = (DWORD)((const struct symt_block*)type)->container; X(DWORD) = symt_ptr2index(module, ((const struct symt_block*)type)->container);
break; break;
case SymTagData: case SymTagData:
X(DWORD) = (DWORD)((const struct symt_data*)type)->container; X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->container);
break; break;
case SymTagFunction: case SymTagFunction:
X(DWORD) = (DWORD)((const struct symt_function*)type)->container; X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->container);
break; break;
case SymTagThunk: case SymTagThunk:
X(DWORD) = (DWORD)((const struct symt_thunk*)type)->container; X(DWORD) = symt_ptr2index(module, ((const struct symt_thunk*)type)->container);
break; break;
case SymTagFunctionArgType: case SymTagFunctionArgType:
X(DWORD) = (DWORD)((const struct symt_function_arg_type*)type)->container; X(DWORD) = symt_ptr2index(module, ((const struct symt_function_arg_type*)type)->container);
break; break;
default: default:
FIXME("Unsupported sym-tag %s for get-lexical-parent\n", FIXME("Unsupported sym-tag %s for get-lexical-parent\n",
@ -763,29 +763,29 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
{ {
/* hierarchical => hierarchical */ /* hierarchical => hierarchical */
case SymTagArrayType: case SymTagArrayType:
X(DWORD) = (DWORD)((const struct symt_array*)type)->base_type; X(DWORD) = symt_ptr2index(module, ((const struct symt_array*)type)->base_type);
break; break;
case SymTagPointerType: case SymTagPointerType:
X(DWORD) = (DWORD)((const struct symt_pointer*)type)->pointsto; X(DWORD) = symt_ptr2index(module, ((const struct symt_pointer*)type)->pointsto);
break; break;
case SymTagFunctionType: case SymTagFunctionType:
X(DWORD) = (DWORD)((const struct symt_function_signature*)type)->rettype; X(DWORD) = symt_ptr2index(module, ((const struct symt_function_signature*)type)->rettype);
break; break;
case SymTagTypedef: case SymTagTypedef:
X(DWORD) = (DWORD)((const struct symt_typedef*)type)->type; X(DWORD) = symt_ptr2index(module, ((const struct symt_typedef*)type)->type);
break; break;
/* lexical => hierarchical */ /* lexical => hierarchical */
case SymTagData: case SymTagData:
X(DWORD) = (DWORD)((const struct symt_data*)type)->type; X(DWORD) = symt_ptr2index(module, ((const struct symt_data*)type)->type);
break; break;
case SymTagFunction: case SymTagFunction:
X(DWORD) = (DWORD)((const struct symt_function*)type)->type; X(DWORD) = symt_ptr2index(module, ((const struct symt_function*)type)->type);
break; break;
case SymTagEnum: case SymTagEnum:
X(DWORD) = (DWORD)((const struct symt_enum*)type)->base_type; X(DWORD) = symt_ptr2index(module, ((const struct symt_enum*)type)->base_type);
break; break;
case SymTagFunctionArgType: case SymTagFunctionArgType:
X(DWORD) = (DWORD)((const struct symt_function_arg_type*)type)->arg_type; X(DWORD) = symt_ptr2index(module, ((const struct symt_function_arg_type*)type)->arg_type);
break; break;
default: default:
FIXME("Unsupported sym-tag %s for get-type\n", FIXME("Unsupported sym-tag %s for get-type\n",
@ -819,7 +819,7 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
break; break;
case TI_GET_ARRAYINDEXTYPEID: case TI_GET_ARRAYINDEXTYPEID:
if (type->tag != SymTagArrayType) return FALSE; if (type->tag != SymTagArrayType) return FALSE;
X(DWORD) = (DWORD)((const struct symt_array*)type)->index_type; X(DWORD) = symt_ptr2index(module, ((const struct symt_array*)type)->index_type);
break; break;
case TI_GET_CLASSPARENTID: case TI_GET_CLASSPARENTID:
@ -867,7 +867,7 @@ BOOL WINAPI SymGetTypeInfo(HANDLE hProcess, DWORD64 ModBase,
return FALSE; return FALSE;
} }
return symt_get_info((struct symt*)TypeId, GetType, pInfo); return symt_get_info(pair.effective, symt_index2ptr(pair.effective, TypeId), GetType, pInfo);
} }
/****************************************************************** /******************************************************************
@ -886,7 +886,7 @@ BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll,
if (!module_get_debug(&pair)) return FALSE; if (!module_get_debug(&pair)) return FALSE;
type = symt_find_type_by_name(pair.effective, SymTagNull, Name); type = symt_find_type_by_name(pair.effective, SymTagNull, Name);
if (!type) return FALSE; if (!type) return FALSE;
Symbol->TypeIndex = (DWORD)type; Symbol->TypeIndex = symt_ptr2index(pair.effective, type);
return TRUE; return TRUE;
} }