[CLASSES]: Make tag_name return "class" if object file is C++

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2006-12-07 17:21:52 -02:00
parent cb883f6a8f
commit 41f58c52ca
2 changed files with 11 additions and 6 deletions

View File

@ -203,11 +203,13 @@ static void cu__add_variable(struct cu *self, struct variable *variable)
list_add_tail(&variable->cu_node, &self->variables);
}
static const char *tag_name(const unsigned int tag)
static const char *tag_name(const struct cu *cu, const unsigned int tag)
{
switch (tag) {
case DW_TAG_enumeration_type: return "enum ";
case DW_TAG_structure_type: return "struct ";
case DW_TAG_structure_type:
return cu->language == DW_LANG_C_plus_plus ? "class " :
"struct ";
case DW_TAG_union_type: return "union ";
case DW_TAG_pointer_type: return " *";
}
@ -369,7 +371,7 @@ static const char *class__name(struct class *self, char *bf, size_t len)
if (ptr_class != NULL)
return class__name(ptr_class, bf, len);
} else
snprintf(bf, len, "%s%s", tag_name(self->tag.tag),
snprintf(bf, len, "%s%s", tag_name(self->cu, self->tag.tag),
self->name ?: "");
return bf;
}
@ -1042,7 +1044,8 @@ void class__print(struct class *self)
class__print_struct(self);
break;
default:
printf("%s%s;\n", tag_name(self->tag.tag), self->name ?: "");
printf("%s%s;\n", tag_name(self->cu, self->tag.tag),
self->name ?: "");
break;
}
putchar('\n');
@ -1475,9 +1478,10 @@ static void cu__process_die(Dwarf *dwarf, Dwarf_Die *die, struct cu *cu)
if (tag == DW_TAG_invalid)
return;
/* Tags we trow away */
if (tag == DW_TAG_compile_unit)
if (tag == DW_TAG_compile_unit) {
cu->language = attr_numeric(die, DW_AT_language);
goto children;
}
cu_offset = dwarf_cuoffset(die);
name = attr_string(die, DW_AT_name, &attr_name);

View File

@ -26,6 +26,7 @@ struct cu {
struct list_head functions;
struct list_head variables;
const char *name;
unsigned short language;
unsigned int id;
unsigned long nr_inline_expansions;
unsigned long size_inline_expansions;