dbghelp/dwarf: Add support for local variables with constant values.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Eric Pouech 2021-09-28 17:21:24 +02:00 committed by Alexandre Julliard
parent 0de0a80940
commit dd67b78ed3
3 changed files with 54 additions and 4 deletions

View File

@ -756,6 +756,10 @@ extern struct symt_data*
enum DataKind dt, const struct location* loc,
struct symt_block* block,
struct symt* type, const char* name) DECLSPEC_HIDDEN;
extern struct symt_data*
symt_add_func_constant(struct module* module,
struct symt_function* func, struct symt_block* block,
struct symt* type, const char* name, VARIANT* v) DECLSPEC_HIDDEN;
extern struct symt_block*
symt_open_func_block(struct module* module,
struct symt_function* func,

View File

@ -1880,8 +1880,7 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm,
else if (dwarf2_find_attribute(di, DW_AT_const_value, &value))
{
VARIANT v;
if (subpgm->func) WARN("Unsupported constant %s in function\n", debugstr_a(name.u.string));
if (is_pmt) FIXME("Unsupported constant (parameter) %s in function\n", debugstr_a(name.u.string));
switch (value.form)
{
case DW_FORM_data1:
@ -1936,8 +1935,16 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm,
debugstr_a(name.u.string), value.form);
v.n1.n2.vt = VT_EMPTY;
}
di->symt = &symt_new_constant(subpgm->ctx->module_ctx->module, subpgm->ctx->compiland,
name.u.string, param_type, &v)->symt;
if (subpgm->func)
{
if (is_pmt) FIXME("Unsupported constant (parameter) %s in function '%s'\n", debugstr_a(name.u.string), subpgm->func->hash_elt.name);
di->symt = &symt_add_func_constant(subpgm->ctx->module_ctx->module,
subpgm->func, block,
param_type, name.u.string, &v)->symt;
}
else
di->symt = &symt_new_constant(subpgm->ctx->module_ctx->module, subpgm->ctx->compiland,
name.u.string, param_type, &v)->symt;
}
else
{

View File

@ -409,6 +409,42 @@ struct symt_data* symt_add_func_local(struct module* module,
return locsym;
}
/******************************************************************
* symt_add_func_local
*
* Adds a new (local) constant to a given function
*/
struct symt_data* symt_add_func_constant(struct module* module,
struct symt_function* func,
struct symt_block* block,
struct symt* type, const char* name,
VARIANT* v)
{
struct symt_data* locsym;
struct symt** p;
TRACE_(dbghelp_symt)("Adding local constant (%s:%s): %s %p\n",
debugstr_w(module->modulename), func->hash_elt.name,
name, type);
assert(func);
assert(func->symt.tag == SymTagFunction);
locsym = pool_alloc(&module->pool, sizeof(*locsym));
locsym->symt.tag = SymTagData;
locsym->hash_elt.name = pool_strdup(&module->pool, name);
locsym->hash_elt.next = NULL;
locsym->kind = DataIsConstant;
locsym->container = block ? &block->symt : &func->symt;
locsym->type = type;
locsym->u.value = *v;
if (block)
p = vector_add(&block->vchildren, &module->pool);
else
p = vector_add(&func->vchildren, &module->pool);
*p = &locsym->symt;
return locsym;
}
struct symt_block* symt_open_func_block(struct module* module,
struct symt_function* func,
@ -653,6 +689,9 @@ static void symt_fill_sym_info(struct module_pair* pair,
break;
case DataIsConstant:
sym_info->Flags |= SYMFLAG_VALUEPRESENT;
if (data->container &&
(data->container->tag == SymTagFunction || data->container->tag == SymTagBlock))
sym_info->Flags |= SYMFLAG_LOCAL;
switch (data->u.value.n1.n2.vt)
{
case VT_I4: sym_info->Value = (ULONG)data->u.value.n1.n2.n3.lVal; break;