mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-03 01:01:44 +00:00
dbghelp: Tidy up internals for array type.
Mainly remove hackish storage of information with negative value and use a uniform min/count pair for all debug formats. Signed-off-by: Eric Pouech <eric.pouech@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4a5d95272c
commit
35c45857ae
|
@ -254,7 +254,7 @@ struct symt_array
|
|||
{
|
||||
struct symt symt;
|
||||
int start;
|
||||
int end; /* end index if > 0, or -array_len (in bytes) if < 0 */
|
||||
DWORD count;
|
||||
struct symt* base_type;
|
||||
struct symt* index_type;
|
||||
};
|
||||
|
@ -812,7 +812,7 @@ extern BOOL symt_add_enum_element(struct module* module,
|
|||
struct symt_enum* enum_type,
|
||||
const char* name, int value) DECLSPEC_HIDDEN;
|
||||
extern struct symt_array*
|
||||
symt_new_array(struct module* module, int min, int max,
|
||||
symt_new_array(struct module* module, int min, DWORD count,
|
||||
struct symt* base, struct symt* index) DECLSPEC_HIDDEN;
|
||||
extern struct symt_function_signature*
|
||||
symt_new_function_signature(struct module* module,
|
||||
|
|
|
@ -1266,7 +1266,7 @@ static struct symt* dwarf2_parse_array_type(dwarf2_parse_context_t* ctx,
|
|||
/* FIXME: int4 even on 64bit machines??? */
|
||||
idx_type = ctx->symt_cache[sc_int4];
|
||||
min.u.uvalue = 0;
|
||||
max.u.uvalue = -1;
|
||||
cnt.u.uvalue = 0;
|
||||
}
|
||||
else for (i = 0; i < vector_length(children); i++)
|
||||
{
|
||||
|
@ -1277,10 +1277,10 @@ static struct symt* dwarf2_parse_array_type(dwarf2_parse_context_t* ctx,
|
|||
idx_type = dwarf2_lookup_type(ctx, child);
|
||||
if (!dwarf2_find_attribute(ctx, child, DW_AT_lower_bound, &min))
|
||||
min.u.uvalue = 0;
|
||||
if (!dwarf2_find_attribute(ctx, child, DW_AT_upper_bound, &max))
|
||||
max.u.uvalue = 0;
|
||||
if (dwarf2_find_attribute(ctx, child, DW_AT_count, &cnt))
|
||||
max.u.uvalue = min.u.uvalue + cnt.u.uvalue;
|
||||
if (dwarf2_find_attribute(ctx, child, DW_AT_upper_bound, &max))
|
||||
cnt.u.uvalue = max.u.uvalue + 1 - min.u.uvalue;
|
||||
else if (!dwarf2_find_attribute(ctx, child, DW_AT_count, &cnt))
|
||||
cnt.u.uvalue = 0;
|
||||
break;
|
||||
default:
|
||||
FIXME("Unhandled Tag type 0x%lx at %s, for %s\n",
|
||||
|
@ -1288,7 +1288,7 @@ static struct symt* dwarf2_parse_array_type(dwarf2_parse_context_t* ctx,
|
|||
break;
|
||||
}
|
||||
}
|
||||
di->symt = &symt_new_array(ctx->module, min.u.uvalue, max.u.uvalue, ref_type, idx_type)->symt;
|
||||
di->symt = &symt_new_array(ctx->module, min.u.uvalue, cnt.u.uvalue, ref_type, idx_type)->symt;
|
||||
return di->symt;
|
||||
}
|
||||
|
||||
|
|
|
@ -671,8 +671,16 @@ static struct symt* codeview_add_type_array(struct codeview_type_parse* ctp,
|
|||
{
|
||||
struct symt* elem = codeview_fetch_type(ctp, elemtype, FALSE);
|
||||
struct symt* index = codeview_fetch_type(ctp, indextype, FALSE);
|
||||
DWORD64 elem_size;
|
||||
DWORD count = 0;
|
||||
|
||||
return &symt_new_array(ctp->module, 0, -arr_len, elem, index)->symt;
|
||||
if (symt_get_info(ctp->module, elem, TI_GET_LENGTH, &elem_size) && elem_size)
|
||||
{
|
||||
if (arr_len % (DWORD)elem_size)
|
||||
FIXME("array size should be a multiple of element size %u %u\n", arr_len, (DWORD)elem_size);
|
||||
count = arr_len / (unsigned)elem_size;
|
||||
}
|
||||
return &symt_new_array(ctp->module, 0, count, elem, index)->symt;
|
||||
}
|
||||
|
||||
static BOOL codeview_add_type_enum_field_list(struct module* module,
|
||||
|
|
|
@ -758,7 +758,7 @@ static inline int stabs_pts_read_array(struct ParseTypedefData* ptd,
|
|||
|
||||
PTS_ABORTIF(ptd, stabs_pts_read_type_def(ptd, NULL, &base_dt) == -1);
|
||||
|
||||
*adt = &symt_new_array(ptd->module, lo, hi, base_dt, range_dt)->symt;
|
||||
*adt = &symt_new_array(ptd->module, lo, hi - lo + 1, base_dt, range_dt)->symt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
struct symt_array* symt_new_array(struct module* module, int min, int max,
|
||||
struct symt_array* symt_new_array(struct module* module, int min, DWORD cnt,
|
||||
struct symt* base, struct symt* index)
|
||||
{
|
||||
struct symt_array* sym;
|
||||
|
@ -359,7 +359,7 @@ struct symt_array* symt_new_array(struct module* module, int min, int max,
|
|||
{
|
||||
sym->symt.tag = SymTagArrayType;
|
||||
sym->start = min;
|
||||
sym->end = max;
|
||||
sym->count = cnt;
|
||||
sym->base_type = base;
|
||||
sym->index_type = index;
|
||||
symt_add_type(module, &sym->symt);
|
||||
|
@ -367,21 +367,6 @@ struct symt_array* symt_new_array(struct module* module, int min, int max,
|
|||
return sym;
|
||||
}
|
||||
|
||||
static inline DWORD symt_array_count(struct module* module, const struct symt_array* array)
|
||||
{
|
||||
if (array->end < 0)
|
||||
{
|
||||
DWORD64 elem_size;
|
||||
/* 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
|
||||
*/
|
||||
if (symt_get_info(module, array->base_type, TI_GET_LENGTH, &elem_size) && elem_size)
|
||||
return -array->end / (DWORD)elem_size;
|
||||
return 0;
|
||||
}
|
||||
return array->end - array->start + 1;
|
||||
}
|
||||
|
||||
struct symt_function_signature* symt_new_function_signature(struct module* module,
|
||||
struct symt* ret_type,
|
||||
enum CV_call_e call_conv)
|
||||
|
@ -630,7 +615,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type,
|
|||
switch (type->tag)
|
||||
{
|
||||
case SymTagArrayType:
|
||||
X(DWORD) = symt_array_count(module, (const struct symt_array*)type);
|
||||
X(DWORD) = ((const struct symt_array*)type)->count;
|
||||
break;
|
||||
case SymTagFunctionType:
|
||||
/* this seems to be wrong for (future) C++ methods, where 'this' parameter
|
||||
|
@ -676,7 +661,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type,
|
|||
if (!symt_get_info(module, ((const struct symt_array*)type)->base_type,
|
||||
TI_GET_LENGTH, pInfo))
|
||||
return FALSE;
|
||||
X(DWORD64) *= symt_array_count(module, (const struct symt_array*)type);
|
||||
X(DWORD64) *= ((const struct symt_array*)type)->count;
|
||||
break;
|
||||
case SymTagPublicSymbol:
|
||||
X(DWORD64) = ((const struct symt_public*)type)->size;
|
||||
|
|
Loading…
Reference in a new issue