dwarves: Rename variable->location to ->scope
We'll use location in the DWARF sense, i.e. location lists, etc, i.e. where is this variable? In a register? The stack? etc. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
0d2511fd1d
commit
c65f2cf436
|
@ -319,7 +319,7 @@ int cu__encode_ctf(struct cu *cu, int verbose)
|
|||
struct variable *var;
|
||||
cu__for_each_variable(cu, id, pos) {
|
||||
var = tag__variable(pos);
|
||||
if (var->location != LOCATION_GLOBAL)
|
||||
if (variable__scope(var) != VSCOPE_GLOBAL)
|
||||
continue;
|
||||
struct hlist_head *head = &hash_addr[hashaddr__fn(var->ip.addr)];
|
||||
hlist_add_head(&var->tool_hnode, head);
|
||||
|
|
|
@ -551,7 +551,7 @@ static struct variable *variable__new(uint16_t type, GElf_Sym *sym,
|
|||
struct variable *var = tag__alloc(sizeof(*var));
|
||||
|
||||
if (var != NULL) {
|
||||
var->location = LOCATION_GLOBAL;
|
||||
var->scope = VSCOPE_GLOBAL;
|
||||
var->ip.addr = elf_sym__value(sym);
|
||||
var->name = sym->st_name;
|
||||
var->external = elf_sym__bind(sym) == STB_GLOBAL;
|
||||
|
|
|
@ -543,28 +543,33 @@ static struct enumerator *enumerator__new(Dwarf_Die *die, struct cu *cu)
|
|||
return enumerator;
|
||||
}
|
||||
|
||||
static enum vlocation dwarf__location(Dwarf_Die *die, uint64_t *addr)
|
||||
static enum vscope dwarf__location(Dwarf_Die *die, uint64_t *addr)
|
||||
{
|
||||
Dwarf_Op *expr;
|
||||
size_t exprlen;
|
||||
enum vlocation location = LOCATION_UNKNOWN;
|
||||
enum vscope scope = VSCOPE_UNKNOWN;
|
||||
|
||||
if (attr_location(die, &expr, &exprlen) != 0)
|
||||
location = LOCATION_OPTIMIZED;
|
||||
scope = VSCOPE_OPTIMIZED;
|
||||
else if (exprlen != 0)
|
||||
switch (expr->atom) {
|
||||
case DW_OP_addr:
|
||||
location = LOCATION_GLOBAL;
|
||||
scope = VSCOPE_GLOBAL;
|
||||
*addr = expr[0].number;
|
||||
break;
|
||||
case DW_OP_reg1 ... DW_OP_reg31:
|
||||
case DW_OP_breg0 ... DW_OP_breg31:
|
||||
location = LOCATION_REGISTER; break;
|
||||
scope = VSCOPE_REGISTER; break;
|
||||
case DW_OP_fbreg:
|
||||
location = LOCATION_LOCAL; break;
|
||||
scope = VSCOPE_LOCAL; break;
|
||||
}
|
||||
|
||||
return location;
|
||||
return scope;
|
||||
}
|
||||
|
||||
enum vscope variable__scope(const struct variable *var)
|
||||
{
|
||||
return var->scope;
|
||||
}
|
||||
|
||||
static struct variable *variable__new(Dwarf_Die *die, struct cu *cu)
|
||||
|
@ -578,10 +583,10 @@ static struct variable *variable__new(Dwarf_Die *die, struct cu *cu)
|
|||
var->external = dwarf_hasattr(die, DW_AT_external);
|
||||
/* non-defining declaration of an object */
|
||||
var->declaration = dwarf_hasattr(die, DW_AT_declaration);
|
||||
var->location = LOCATION_UNKNOWN;
|
||||
var->scope = VSCOPE_UNKNOWN;
|
||||
var->ip.addr = 0;
|
||||
if (!var->declaration && cu->has_addr_info)
|
||||
var->location = dwarf__location(die, &var->ip.addr);
|
||||
var->scope = dwarf__location(die, &var->ip.addr);
|
||||
}
|
||||
|
||||
return var;
|
||||
|
@ -1501,7 +1506,7 @@ static int die__process_function(Dwarf_Die *die, struct ftype *ftype,
|
|||
continue;
|
||||
case DW_TAG_dwarf_procedure:
|
||||
/*
|
||||
* Ignore it, just location expressions, that we have no use for (so far).
|
||||
* Ignore it, just scope expressions, that we have no use for (so far).
|
||||
*/
|
||||
continue;
|
||||
#ifdef STB_GNU_UNIQUE
|
||||
|
@ -1631,7 +1636,7 @@ static struct tag *__die__process_tag(Dwarf_Die *die, struct cu *cu,
|
|||
/* fall thru */
|
||||
case DW_TAG_dwarf_procedure:
|
||||
/*
|
||||
* Ignore it, just location expressions, that we have no use for (so far).
|
||||
* Ignore it, just scope expressions, that we have no use for (so far).
|
||||
*/
|
||||
tag = &unsupported_tag;
|
||||
break;
|
||||
|
|
16
dwarves.h
16
dwarves.h
|
@ -571,12 +571,12 @@ static inline const char *label__name(const struct label *label,
|
|||
return cu__string(cu, label->name);
|
||||
}
|
||||
|
||||
enum vlocation {
|
||||
LOCATION_UNKNOWN,
|
||||
LOCATION_LOCAL,
|
||||
LOCATION_GLOBAL,
|
||||
LOCATION_REGISTER,
|
||||
LOCATION_OPTIMIZED
|
||||
enum vscope {
|
||||
VSCOPE_UNKNOWN,
|
||||
VSCOPE_LOCAL,
|
||||
VSCOPE_GLOBAL,
|
||||
VSCOPE_REGISTER,
|
||||
VSCOPE_OPTIMIZED
|
||||
} __attribute__((packed));
|
||||
|
||||
struct variable {
|
||||
|
@ -584,7 +584,7 @@ struct variable {
|
|||
strings_t name;
|
||||
uint8_t external:1;
|
||||
uint8_t declaration:1;
|
||||
enum vlocation location;
|
||||
enum vscope scope;
|
||||
struct hlist_node tool_hnode;
|
||||
};
|
||||
|
||||
|
@ -593,6 +593,8 @@ static inline struct variable *tag__variable(const struct tag *tag)
|
|||
return (struct variable *)tag;
|
||||
}
|
||||
|
||||
enum vscope variable__scope(const struct variable *var);
|
||||
|
||||
const char *variable__name(const struct variable *var, const struct cu *cu);
|
||||
|
||||
const char *variable__type_name(const struct variable *var,
|
||||
|
|
|
@ -522,19 +522,19 @@ const char *tag__name(const struct tag *tag, const struct cu *cu,
|
|||
|
||||
static const char *variable__prefix(const struct variable *var)
|
||||
{
|
||||
switch (var->location) {
|
||||
case LOCATION_REGISTER:
|
||||
switch (variable__scope(var)) {
|
||||
case VSCOPE_REGISTER:
|
||||
return "register ";
|
||||
case LOCATION_UNKNOWN:
|
||||
case VSCOPE_UNKNOWN:
|
||||
if (var->external && var->declaration)
|
||||
return "extern ";
|
||||
break;
|
||||
case LOCATION_GLOBAL:
|
||||
case VSCOPE_GLOBAL:
|
||||
if (!var->external)
|
||||
return "static ";
|
||||
break;
|
||||
case LOCATION_LOCAL:
|
||||
case LOCATION_OPTIMIZED:
|
||||
case VSCOPE_LOCAL:
|
||||
case VSCOPE_OPTIMIZED:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue