Eric Pouech : dbghelp: Extended the internal enumeration information so that we know the underlying integral type .
Alexandre Julliard
julliard at winehq.org
Thu Feb 7 07:59:29 CST 2008
Module: wine
Branch: master
Commit: 75803e9448d84626ead67993f7c0eb41aa987234
URL: http://source.winehq.org/git/wine.git/?a=commit;h=75803e9448d84626ead67993f7c0eb41aa987234
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Wed Feb 6 21:55:59 2008 +0100
dbghelp: Extended the internal enumeration information so that we know the underlying integral type.
---
dlls/dbghelp/dbghelp_private.h | 4 +++-
dlls/dbghelp/dwarf.c | 13 +++++++++++--
dlls/dbghelp/msc.c | 15 ++++++++++-----
dlls/dbghelp/stabs.c | 6 ++++--
dlls/dbghelp/type.c | 11 +++++++----
5 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 4234ec9..c81f778 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -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);
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index c2ff297..6aae397 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -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;
+
+ 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)->symt;
+ di->symt = &symt_new_enum(ctx->module, name.u.string, &basetype->symt)->symt;
if (di->abbrev->have_child) /* any interest to not have child ? */
{
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c
index 8c674bf..242fa93 100644
--- a/dlls/dbghelp/msc.c
+++ b/dlls/dbghelp/msc.c
@@ -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:
diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c
index c17dae6..cc750c6 100644
--- a/dlls/dbghelp/stabs.c
+++ b/dlls/dbghelp/stabs.c
@@ -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;
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c
index a3eeeee..7978a1c 100644
--- a/dlls/dbghelp/type.c
+++ b/dlls/dbghelp/type.c
@@ -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;
More information about the wine-cvs
mailing list