dbghelp: Added type for array index.
- added type for array index - correctly parsing array index type in stabs, Dwarf2 and MSC formats - fixed SyGetTypeInfo accordingly
This commit is contained in:
parent
f7441f9e1a
commit
34636b026b
|
@ -197,7 +197,8 @@ struct symt_array
|
|||
struct symt symt;
|
||||
int start;
|
||||
int end;
|
||||
struct symt* basetype;
|
||||
struct symt* base_type;
|
||||
struct symt* index_type;
|
||||
};
|
||||
|
||||
struct symt_basic
|
||||
|
@ -475,7 +476,7 @@ extern BOOL symt_add_enum_element(struct module* module,
|
|||
const char* name, int value);
|
||||
extern struct symt_array*
|
||||
symt_new_array(struct module* module, int min, int max,
|
||||
struct symt* base);
|
||||
struct symt* base, struct symt* index);
|
||||
extern struct symt_function_signature*
|
||||
symt_new_function_signature(struct module* module,
|
||||
struct symt* ret_type,
|
||||
|
|
|
@ -1050,6 +1050,7 @@ static void dwarf2_parse_array_subrange_type(struct module* module, dwarf2_abbre
|
|||
}
|
||||
parent->start = min;
|
||||
parent->end = max;
|
||||
parent->index_type = idx_type;
|
||||
|
||||
TRACE("found min:%u max:%u\n", min, max);
|
||||
|
||||
|
@ -1087,7 +1088,8 @@ static struct symt_array* dwarf2_parse_array_type(struct module* module, dwarf2_
|
|||
}
|
||||
}
|
||||
|
||||
symt = symt_new_array(module, min, max, ref_type);
|
||||
/* FIXME: ugly as hell */
|
||||
symt = symt_new_array(module, min, max, ref_type, NULL);
|
||||
|
||||
if (entry->have_child) { /** any interest to not have child ? */
|
||||
++ctx->level;
|
||||
|
|
|
@ -388,10 +388,12 @@ static int codeview_add_type_pointer(struct module* module, unsigned int typeno,
|
|||
|
||||
static int codeview_add_type_array(struct module* module,
|
||||
unsigned int typeno, const char* name,
|
||||
unsigned int elemtype, unsigned int arr_len)
|
||||
unsigned int elemtype, unsigned int indextype,
|
||||
unsigned int arr_len)
|
||||
{
|
||||
struct symt* symt;
|
||||
struct symt* elem = codeview_get_type(elemtype, FALSE);
|
||||
struct symt* index = codeview_get_type(indextype, FALSE);
|
||||
DWORD arr_max = 0;
|
||||
|
||||
if (elem)
|
||||
|
@ -400,7 +402,7 @@ static int codeview_add_type_array(struct module* module,
|
|||
symt_get_info(elem, TI_GET_LENGTH, &elem_size);
|
||||
if (elem_size) arr_max = arr_len / (DWORD)elem_size;
|
||||
}
|
||||
symt = &symt_new_array(module, 0, arr_max, elem)->symt;
|
||||
symt = &symt_new_array(module, 0, arr_max, elem, index)->symt;
|
||||
return codeview_add_type(typeno, symt);
|
||||
}
|
||||
|
||||
|
@ -792,21 +794,21 @@ static int codeview_parse_type_table(struct module* module, const BYTE* table,
|
|||
p_name = (const struct p_string*)((const unsigned char*)&type->array_v1.arrlen + leaf_len);
|
||||
|
||||
retv = codeview_add_type_array(module, curr_type, terminate_string(p_name),
|
||||
type->array_v1.elemtype, value);
|
||||
type->array_v1.elemtype, type->array_v1.idxtype, value);
|
||||
break;
|
||||
case LF_ARRAY_V2:
|
||||
leaf_len = numeric_leaf(&value, &type->array_v2.arrlen);
|
||||
p_name = (const struct p_string*)((const unsigned char*)&type->array_v2.arrlen + leaf_len);
|
||||
|
||||
retv = codeview_add_type_array(module, curr_type, terminate_string(p_name),
|
||||
type->array_v2.elemtype, value);
|
||||
type->array_v2.elemtype, type->array_v2.idxtype, value);
|
||||
break;
|
||||
case LF_ARRAY_V3:
|
||||
leaf_len = numeric_leaf(&value, &type->array_v3.arrlen);
|
||||
c_name = (const char*)&type->array_v3.arrlen + leaf_len;
|
||||
|
||||
retv = codeview_add_type_array(module, curr_type, c_name,
|
||||
type->array_v3.elemtype, value);
|
||||
type->array_v3.elemtype, type->array_v3.idxtype, value);
|
||||
break;
|
||||
|
||||
case LF_BITFIELD_V1:
|
||||
|
|
|
@ -765,22 +765,23 @@ static inline int stabs_pts_read_array(struct ParseTypedefData* ptd,
|
|||
struct symt** adt)
|
||||
{
|
||||
long lo, hi;
|
||||
struct symt* rdt;
|
||||
struct symt* range_dt;
|
||||
struct symt* base_dt;
|
||||
|
||||
/* ar<typeinfo_nodef>;<int>;<int>;<typeinfo> */
|
||||
|
||||
PTS_ABORTIF(ptd, *ptd->ptr++ != 'r');
|
||||
/* FIXME: range type is lost, always assume int */
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_type_def(ptd, NULL, &rdt) == -1);
|
||||
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_type_def(ptd, NULL, &range_dt) == -1);
|
||||
PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); /* ';' */
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &lo) == -1);
|
||||
PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); /* ';' */
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &hi) == -1);
|
||||
PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); /* ';' */
|
||||
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_type_def(ptd, NULL, &rdt) == -1);
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_type_def(ptd, NULL, &base_dt) == -1);
|
||||
|
||||
*adt = &symt_new_array(ptd->module, lo, hi, rdt)->symt;
|
||||
*adt = &symt_new_array(ptd->module, lo, hi, base_dt, range_dt)->symt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type,
|
|||
}
|
||||
|
||||
struct symt_array* symt_new_array(struct module* module, int min, int max,
|
||||
struct symt* base)
|
||||
struct symt* base, struct symt* index)
|
||||
{
|
||||
struct symt_array* sym;
|
||||
|
||||
|
@ -291,7 +291,8 @@ struct symt_array* symt_new_array(struct module* module, int min, int max,
|
|||
sym->symt.tag = SymTagArrayType;
|
||||
sym->start = min;
|
||||
sym->end = max;
|
||||
sym->basetype = base;
|
||||
sym->base_type = base;
|
||||
sym->index_type = index;
|
||||
symt_add_type(module, &sym->symt);
|
||||
}
|
||||
return sym;
|
||||
|
@ -597,7 +598,7 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
|
|||
X(DWORD64) = ((const struct symt_data*)type)->u.s.length;
|
||||
break;
|
||||
case SymTagArrayType:
|
||||
if (!symt_get_info(((const struct symt_array*)type)->basetype,
|
||||
if (!symt_get_info(((const struct symt_array*)type)->base_type,
|
||||
TI_GET_LENGTH, pInfo))
|
||||
return FALSE;
|
||||
X(DWORD64) *= ((const struct symt_array*)type)->end -
|
||||
|
@ -702,7 +703,7 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
|
|||
{
|
||||
/* hierarchical => hierarchical */
|
||||
case SymTagArrayType:
|
||||
X(DWORD) = (DWORD)((const struct symt_array*)type)->basetype;
|
||||
X(DWORD) = (DWORD)((const struct symt_array*)type)->base_type;
|
||||
break;
|
||||
case SymTagPointerType:
|
||||
X(DWORD) = (DWORD)((const struct symt_pointer*)type)->pointsto;
|
||||
|
@ -753,11 +754,14 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
|
|||
}
|
||||
else X(DWORD) = ((const struct symt_function_signature*)type)->call_conv;
|
||||
break;
|
||||
case TI_GET_ARRAYINDEXTYPEID:
|
||||
if (type->tag != SymTagArrayType) return FALSE;
|
||||
X(DWORD) = (DWORD)((const struct symt_array*)type)->index_type;
|
||||
break;
|
||||
|
||||
#undef X
|
||||
|
||||
case TI_GET_ADDRESSOFFSET:
|
||||
case TI_GET_ARRAYINDEXTYPEID:
|
||||
case TI_GET_CLASSPARENTID:
|
||||
case TI_GET_SYMINDEX:
|
||||
case TI_GET_THISADJUST:
|
||||
|
|
Loading…
Reference in New Issue