@@ -730,7 +730,7 @@ const char *variable__scope_str(const struct variable *var)
return "unknown";
}
-static struct variable *variable__new(Dwarf_Die *die, struct cu *cu, struct conf_load *conf)
+static struct variable *variable__new(Dwarf_Die *die, struct cu *cu, struct conf_load *conf, int top_level)
{
bool has_specification = dwarf_hasattr(die, DW_AT_specification);
struct variable *var = tag__alloc(cu, sizeof(*var));
@@ -743,6 +743,8 @@ static struct variable *variable__new(Dwarf_Die *die, struct cu *cu, struct conf
/* non-defining declaration of an object */
var->declaration = dwarf_hasattr(die, DW_AT_declaration);
var->has_specification = has_specification;
+ var->artificial = dwarf_hasattr(die, DW_AT_artificial);
+ var->top_level = top_level;
var->scope = VSCOPE_UNKNOWN;
INIT_LIST_HEAD(&var->annots);
var->ip.addr = 0;
@@ -1767,9 +1769,9 @@ static struct tag *die__create_new_label(Dwarf_Die *die,
return &label->ip.tag;
}
-static struct tag *die__create_new_variable(Dwarf_Die *die, struct cu *cu, struct conf_load *conf)
+static struct tag *die__create_new_variable(Dwarf_Die *die, struct cu *cu, struct conf_load *conf, int top_level)
{
- struct variable *var = variable__new(die, cu, conf);
+ struct variable *var = variable__new(die, cu, conf, top_level);
if (var == NULL || add_child_llvm_annotations(die, -1, conf, &var->annots))
return NULL;
@@ -2243,7 +2245,7 @@ static int die__process_function(Dwarf_Die *die, struct ftype *ftype,
tag = die__create_new_parameter(die, ftype, lexblock, cu, conf, param_idx++);
break;
case DW_TAG_variable:
- tag = die__create_new_variable(die, cu, conf);
+ tag = die__create_new_variable(die, cu, conf, 0);
if (tag == NULL)
goto out_enomem;
lexblock__add_variable(lexblock, tag__variable(tag));
@@ -2367,7 +2369,7 @@ static struct tag *__die__process_tag(Dwarf_Die *die, struct cu *cu,
case DW_TAG_union_type:
tag = die__create_new_union(die, cu, conf); break;
case DW_TAG_variable:
- tag = die__create_new_variable(die, cu, conf); break;
+ tag = die__create_new_variable(die, cu, conf, top_level); break;
case DW_TAG_constant: // First seen in a Go CU
tag = die__create_new_constant(die, cu, conf); break;
default:
@@ -848,6 +848,8 @@ struct variable {
uint8_t external:1;
uint8_t declaration:1;
uint8_t has_specification:1;
+ uint8_t artificial:1;
+ uint8_t top_level:1;
enum vscope scope;
struct location location;
struct hlist_node tool_hnode;