dwarves: the variable abstract_origin is resolved at load time too

It makes no sense to try to lookup the abstract_origin (a Dwarf_Off)
after we recode the types just after load.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2009-03-14 15:19:33 -03:00
parent 5c204b5036
commit 865e259012
3 changed files with 10 additions and 36 deletions

View File

@ -954,44 +954,14 @@ const char *tag__name(const struct tag *self, const struct cu *cu,
return bf;
}
static struct tag *variable__type(const struct variable *self,
const struct cu *cu)
{
struct tag *var;
if (self->tag.type != 0)
return cu__find_type_by_id(cu, self->tag.type);
else if (self->abstract_origin != 0) {
var = cu__find_tag_by_id(cu, self->abstract_origin);
if (var)
return variable__type(tag__variable(var), cu);
}
return NULL;
}
const char *variable__type_name(const struct variable *self,
const struct cu *cu,
char *bf, size_t len)
{
const struct tag *tag = variable__type(self, cu);
const struct tag *tag = cu__find_type_by_id(cu, self->tag.type);
return tag != NULL ? tag__name(tag, cu, bf, len) : NULL;
}
const char *variable__name(const struct variable *self, const struct cu *cu)
{
if (self->name)
return s(self->name);
if (self->abstract_origin != 0) {
struct tag *var =
cu__find_tag_by_id(cu, self->abstract_origin);
if (var != NULL)
return s(tag__variable(var)->name);
}
return NULL;
}
static const char *variable__prefix(const struct variable *var)
{
switch (var->location) {
@ -1793,7 +1763,7 @@ static size_t function__tag_fprintf(const struct tag *tag, const struct cu *cu,
printed = fprintf(fp, "%.*s", indent, tabs);
n = fprintf(fp, "%s %s;",
variable__type_name(vtag, cu, bf, sizeof(bf)),
variable__name(vtag, cu));
variable__name(vtag));
c += n;
printed += n;
break;
@ -2307,11 +2277,11 @@ static size_t variable__fprintf(const struct tag *tag, const struct cu *cu,
const struct conf_fprintf *conf, FILE *fp)
{
const struct variable *var = tag__variable(tag);
const char *name = variable__name(var, cu);
const char *name = variable__name(var);
size_t printed = 0;
if (name != NULL) {
struct tag *type = variable__type(var, cu);
struct tag *type = cu__find_type_by_id(cu, var->tag.type);
if (type != NULL) {
const char *varprefix = variable__prefix(var);

View File

@ -426,7 +426,11 @@ static inline struct variable *tag__variable(const struct tag *self)
return (struct variable *)self;
}
const char *variable__name(const struct variable *self, const struct cu *cu);
static inline const char *variable__name(const struct variable *self)
{
return strings__ptr(strings, self->name);
}
const char *variable__type_name(const struct variable *self,
const struct cu *cu, char *bf, size_t len);

View File

@ -51,7 +51,7 @@ static struct extvar *extvar__new(const struct variable *var,
gvar->next = NULL;
gvar->var = var;
gvar->cu = cu;
gvar->name = variable__name(var, cu);
gvar->name = variable__name(var);
}
return gvar;