dbghelp: Extended the internal enumeration information so that we know the underlying integral type.

This commit is contained in:
Eric Pouech 2008-02-06 21:55:59 +01:00 committed by Alexandre Julliard
parent 752a260402
commit 75803e9448
5 changed files with 35 additions and 14 deletions

View File

@ -256,6 +256,7 @@ struct symt_basic
struct symt_enum
{
struct symt symt;
struct symt* base_type;
const char* name;
struct vector vchildren;
};
@ -591,7 +592,8 @@ extern BOOL symt_add_udt_element(struct module* module,
struct symt* elt_type, unsigned offset,
unsigned size);
extern struct symt_enum*
symt_new_enum(struct module* module, const char* typename);
symt_new_enum(struct module* module, const char* typename,
struct symt* basetype);
extern BOOL symt_add_enum_element(struct module* module,
struct symt_enum* enum_type,
const char* name, int value);

View File

@ -1216,15 +1216,24 @@ static struct symt* dwarf2_parse_enumeration_type(dwarf2_parse_context_t* ctx,
{
struct attribute name;
struct attribute size;
struct symt_basic* basetype;
if (di->symt) return di->symt;
TRACE("%s, for %s\n", dwarf2_debug_ctx(ctx), dwarf2_debug_di(di));
if (!dwarf2_find_attribute(ctx, di, DW_AT_name, &name)) name.u.string = NULL;
if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 0;
if (!dwarf2_find_attribute(ctx, di, DW_AT_byte_size, &size)) size.u.uvalue = 4;
di->symt = &symt_new_enum(ctx->module, name.u.string)->symt;
switch (size.u.uvalue) /* FIXME: that's wrong */
{
case 1: basetype = symt_new_basic(ctx->module, btInt, "char", 1); break;
case 2: basetype = symt_new_basic(ctx->module, btInt, "short", 2); break;
default:
case 4: basetype = symt_new_basic(ctx->module, btInt, "int", 4); break;
}
di->symt = &symt_new_enum(ctx->module, name.u.string, &basetype->symt)->symt;
if (di->abbrev->have_child) /* any interest to not have child ? */
{

View File

@ -758,7 +758,8 @@ static int codeview_add_type_struct_field_list(struct codeview_type_parse* ctp,
static struct symt* codeview_add_type_enum(struct codeview_type_parse* ctp,
struct symt* existing,
const char* name,
unsigned fieldlistno)
unsigned fieldlistno,
unsigned basetype)
{
struct symt_enum* symt;
@ -769,7 +770,8 @@ static struct symt* codeview_add_type_enum(struct codeview_type_parse* ctp,
}
else
{
symt = symt_new_enum(ctp->module, name);
symt = symt_new_enum(ctp->module, name,
codeview_fetch_type(ctp, basetype, FALSE));
if (fieldlistno)
{
const union codeview_reftype* fieldlist;
@ -1008,18 +1010,21 @@ static struct symt* codeview_parse_one_type(struct codeview_type_parse* ctp,
case LF_ENUM_V1:
symt = codeview_add_type_enum(ctp, existing,
terminate_string(&type->enumeration_v1.p_name),
type->enumeration_v1.fieldlist);
type->enumeration_v1.fieldlist,
type->enumeration_v1.type);
break;
case LF_ENUM_V2:
symt = codeview_add_type_enum(ctp, existing,
terminate_string(&type->enumeration_v2.p_name),
type->enumeration_v2.fieldlist);
type->enumeration_v2.fieldlist,
type->enumeration_v2.type);
break;
case LF_ENUM_V3:
symt = codeview_add_type_enum(ctp, existing, type->enumeration_v3.name,
type->enumeration_v3.fieldlist);
type->enumeration_v3.fieldlist,
type->enumeration_v3.type);
break;
case LF_PROCEDURE_V1:

View File

@ -856,7 +856,8 @@ static int stabs_pts_read_type_def(struct ParseTypedefData* ptd, const char* typ
new_dt = &symt_new_function_signature(ptd->module, ref_dt, -1)->symt;
break;
case 'e':
new_dt = &symt_new_enum(ptd->module, typename)->symt;
stabs_get_basic(ptd, 1 /* int */, &ref_dt);
new_dt = &symt_new_enum(ptd->module, typename, ref_dt)->symt;
PTS_ABORTIF(ptd, stabs_pts_read_enum(ptd, (struct symt_enum*)new_dt) == -1);
break;
case 's':
@ -910,7 +911,8 @@ static int stabs_pts_read_type_def(struct ParseTypedefData* ptd, const char* typ
switch (tmp)
{
case 'e':
new_dt = &symt_new_enum(ptd->module, ptd->buf + idx)->symt;
stabs_get_basic(ptd, 1 /* int */, &ref_dt);
new_dt = &symt_new_enum(ptd->module, ptd->buf + idx, ref_dt)->symt;
break;
case 's':
new_dt = &symt_new_udt(ptd->module, ptd->buf + idx, 0, UdtStruct)->symt;

View File

@ -243,7 +243,8 @@ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type,
return TRUE;
}
struct symt_enum* symt_new_enum(struct module* module, const char* typename)
struct symt_enum* symt_new_enum(struct module* module, const char* typename,
struct symt* basetype)
{
struct symt_enum* sym;
@ -251,6 +252,7 @@ struct symt_enum* symt_new_enum(struct module* module, const char* typename)
{
sym->symt.tag = SymTagEnum;
sym->name = (typename) ? pool_strdup(&module->pool, typename) : NULL;
sym->base_type = basetype;
vector_init(&sym->vchildren, sizeof(struct symt*), 8);
}
return sym;
@ -271,8 +273,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;
/* CV defines the underlying type for the enumeration */
e->type = &symt_new_basic(module, btInt, "int", 4)->symt;
e->type = enum_type->base_type;
e->u.value.n1.n2.vt = VT_I4;
e->u.value.n1.n2.n3.lVal = value;
@ -764,7 +765,9 @@ BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
case SymTagFunction:
X(DWORD) = (DWORD)((const struct symt_function*)type)->type;
break;
/* FIXME: should also work for enums */
case SymTagEnum:
X(DWORD) = (DWORD)((const struct symt_enum*)type)->base_type;
break;
case SymTagFunctionArgType:
X(DWORD) = (DWORD)((const struct symt_function_arg_type*)type)->arg_type;
break;