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;
|
struct variable *var;
|
||||||
cu__for_each_variable(cu, id, pos) {
|
cu__for_each_variable(cu, id, pos) {
|
||||||
var = tag__variable(pos);
|
var = tag__variable(pos);
|
||||||
if (var->location != LOCATION_GLOBAL)
|
if (variable__scope(var) != VSCOPE_GLOBAL)
|
||||||
continue;
|
continue;
|
||||||
struct hlist_head *head = &hash_addr[hashaddr__fn(var->ip.addr)];
|
struct hlist_head *head = &hash_addr[hashaddr__fn(var->ip.addr)];
|
||||||
hlist_add_head(&var->tool_hnode, head);
|
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));
|
struct variable *var = tag__alloc(sizeof(*var));
|
||||||
|
|
||||||
if (var != NULL) {
|
if (var != NULL) {
|
||||||
var->location = LOCATION_GLOBAL;
|
var->scope = VSCOPE_GLOBAL;
|
||||||
var->ip.addr = elf_sym__value(sym);
|
var->ip.addr = elf_sym__value(sym);
|
||||||
var->name = sym->st_name;
|
var->name = sym->st_name;
|
||||||
var->external = elf_sym__bind(sym) == STB_GLOBAL;
|
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;
|
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;
|
Dwarf_Op *expr;
|
||||||
size_t exprlen;
|
size_t exprlen;
|
||||||
enum vlocation location = LOCATION_UNKNOWN;
|
enum vscope scope = VSCOPE_UNKNOWN;
|
||||||
|
|
||||||
if (attr_location(die, &expr, &exprlen) != 0)
|
if (attr_location(die, &expr, &exprlen) != 0)
|
||||||
location = LOCATION_OPTIMIZED;
|
scope = VSCOPE_OPTIMIZED;
|
||||||
else if (exprlen != 0)
|
else if (exprlen != 0)
|
||||||
switch (expr->atom) {
|
switch (expr->atom) {
|
||||||
case DW_OP_addr:
|
case DW_OP_addr:
|
||||||
location = LOCATION_GLOBAL;
|
scope = VSCOPE_GLOBAL;
|
||||||
*addr = expr[0].number;
|
*addr = expr[0].number;
|
||||||
break;
|
break;
|
||||||
case DW_OP_reg1 ... DW_OP_reg31:
|
case DW_OP_reg1 ... DW_OP_reg31:
|
||||||
case DW_OP_breg0 ... DW_OP_breg31:
|
case DW_OP_breg0 ... DW_OP_breg31:
|
||||||
location = LOCATION_REGISTER; break;
|
scope = VSCOPE_REGISTER; break;
|
||||||
case DW_OP_fbreg:
|
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)
|
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);
|
var->external = dwarf_hasattr(die, DW_AT_external);
|
||||||
/* non-defining declaration of an object */
|
/* non-defining declaration of an object */
|
||||||
var->declaration = dwarf_hasattr(die, DW_AT_declaration);
|
var->declaration = dwarf_hasattr(die, DW_AT_declaration);
|
||||||
var->location = LOCATION_UNKNOWN;
|
var->scope = VSCOPE_UNKNOWN;
|
||||||
var->ip.addr = 0;
|
var->ip.addr = 0;
|
||||||
if (!var->declaration && cu->has_addr_info)
|
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;
|
return var;
|
||||||
|
@ -1501,7 +1506,7 @@ static int die__process_function(Dwarf_Die *die, struct ftype *ftype,
|
||||||
continue;
|
continue;
|
||||||
case DW_TAG_dwarf_procedure:
|
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;
|
continue;
|
||||||
#ifdef STB_GNU_UNIQUE
|
#ifdef STB_GNU_UNIQUE
|
||||||
|
@ -1631,7 +1636,7 @@ static struct tag *__die__process_tag(Dwarf_Die *die, struct cu *cu,
|
||||||
/* fall thru */
|
/* fall thru */
|
||||||
case DW_TAG_dwarf_procedure:
|
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;
|
tag = &unsupported_tag;
|
||||||
break;
|
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);
|
return cu__string(cu, label->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum vlocation {
|
enum vscope {
|
||||||
LOCATION_UNKNOWN,
|
VSCOPE_UNKNOWN,
|
||||||
LOCATION_LOCAL,
|
VSCOPE_LOCAL,
|
||||||
LOCATION_GLOBAL,
|
VSCOPE_GLOBAL,
|
||||||
LOCATION_REGISTER,
|
VSCOPE_REGISTER,
|
||||||
LOCATION_OPTIMIZED
|
VSCOPE_OPTIMIZED
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct variable {
|
struct variable {
|
||||||
|
@ -584,7 +584,7 @@ struct variable {
|
||||||
strings_t name;
|
strings_t name;
|
||||||
uint8_t external:1;
|
uint8_t external:1;
|
||||||
uint8_t declaration:1;
|
uint8_t declaration:1;
|
||||||
enum vlocation location;
|
enum vscope scope;
|
||||||
struct hlist_node tool_hnode;
|
struct hlist_node tool_hnode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -593,6 +593,8 @@ static inline struct variable *tag__variable(const struct tag *tag)
|
||||||
return (struct variable *)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__name(const struct variable *var, const struct cu *cu);
|
||||||
|
|
||||||
const char *variable__type_name(const struct variable *var,
|
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)
|
static const char *variable__prefix(const struct variable *var)
|
||||||
{
|
{
|
||||||
switch (var->location) {
|
switch (variable__scope(var)) {
|
||||||
case LOCATION_REGISTER:
|
case VSCOPE_REGISTER:
|
||||||
return "register ";
|
return "register ";
|
||||||
case LOCATION_UNKNOWN:
|
case VSCOPE_UNKNOWN:
|
||||||
if (var->external && var->declaration)
|
if (var->external && var->declaration)
|
||||||
return "extern ";
|
return "extern ";
|
||||||
break;
|
break;
|
||||||
case LOCATION_GLOBAL:
|
case VSCOPE_GLOBAL:
|
||||||
if (!var->external)
|
if (!var->external)
|
||||||
return "static ";
|
return "static ";
|
||||||
break;
|
break;
|
||||||
case LOCATION_LOCAL:
|
case VSCOPE_LOCAL:
|
||||||
case LOCATION_OPTIMIZED:
|
case VSCOPE_OPTIMIZED:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue