[LIB]: Add support for DW_TAG_reference_type

One more C++ feature supported:

[acme@newtoy examples]$ pahole qsettings.o QConfFileSettingsPrivate
/* io/qsettings_p.h:233 */
struct QConfFileSettingsPrivate {
        struct QSettingsPrivate (null);               /*     0    76 */
        /* --- cacheline 2 boundary (64 bytes) was 12 bytes ago --- */
        class QConfFile *       confFiles[4];         /*    76    16 */
        enum Format             format;               /*    92     4 */
        /* --- cacheline 3 boundary (96 bytes) --- */
        bool                    (*readFunc)(class QIODevice &, class QMap<QString,QVariant> &); /*    96     4 */
        bool                    (*writeFunc)(class QIODevice &, const class QMap<QString,QVariant>  &); /*   100     4 */
        struct QString          extension;            /*   104     4 */
        >>>ERROR: type for caseSensitivity not found!
}; /* size: 112, cachelines: 4 */
   /* padding: 5 */
   /* last cacheline: 16 bytes */

/* BRAIN FART ALERT! 112 != 108 + 0(holes), diff = 4 */

[acme@newtoy examples]$

Now to see the problem with caseSensitivity type, probably was defined inside
some DW_TAG_namespace, that is not yet supported.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2007-01-12 11:06:59 -02:00
parent 81f16372eb
commit a1f5422656
1 changed files with 33 additions and 15 deletions

View File

@ -426,6 +426,7 @@ static const char *tag__prefix(const struct cu *cu, const uint32_t tag)
"struct ";
case DW_TAG_union_type: return "union ";
case DW_TAG_pointer_type: return " *";
case DW_TAG_reference_type: return " &";
}
return "";
@ -689,7 +690,8 @@ size_t tag__size(const struct tag *self, const struct cu *cu)
size_t size;
switch (self->tag) {
case DW_TAG_pointer_type: return cu->addr_size;
case DW_TAG_pointer_type:
case DW_TAG_reference_type: return cu->addr_size;
case DW_TAG_base_type: return tag__base_type(self)->size;
case DW_TAG_enumeration_type: return tag__type(self)->size;
}
@ -712,6 +714,29 @@ size_t tag__size(const struct tag *self, const struct cu *cu)
return size;
}
static const char *tag__ptr_name(const struct tag *self, const struct cu *cu,
char *bf, size_t len, char ptr_char)
{
if (self->type == 0) /* No type == void */
snprintf(bf, len, "void %c", ptr_char);
else {
const struct tag *type = cu__find_tag_by_id(cu, self->type);
if (type == NULL) {
tag__type_not_found(self, cu);
snprintf(bf, len,
"<ERROR: type not found!> %c", ptr_char);
} else {
char tmpbf[128];
snprintf(bf, len, "%s %c",
tag__name(type, cu,
tmpbf, sizeof(tmpbf)), ptr_char);
}
}
return bf;
}
const char *tag__name(const struct tag *self, const struct cu *cu,
char *bf, size_t len)
{
@ -724,20 +749,11 @@ const char *tag__name(const struct tag *self, const struct cu *cu,
strncpy(bf, tag__base_type(self)->name, len);
else if (self->tag == DW_TAG_subprogram)
strncpy(bf, function__name(tag__function(self), cu), len);
else if (self->tag == DW_TAG_pointer_type) {
if (self->type == 0) /* No type == void */
strncpy(bf, "void *", len);
else {
type = cu__find_tag_by_id(cu, self->type);
if (type == NULL) {
tag__type_not_found(self, cu);
strncpy(bf, "<ERROR>", len);
} else
snprintf(bf, len, "%s *",
tag__name(type, cu,
tmpbf, sizeof(tmpbf)));
}
} else if (self->tag == DW_TAG_volatile_type ||
else if (self->tag == DW_TAG_pointer_type)
return tag__ptr_name(self, cu, bf, len, '*');
else if (self->tag == DW_TAG_reference_type)
return tag__ptr_name(self, cu, bf, len, '&');
else if (self->tag == DW_TAG_volatile_type ||
self->tag == DW_TAG_const_type) {
type = cu__find_tag_by_id(cu, self->type);
if (type == NULL && self->type != 0) {
@ -2275,6 +2291,7 @@ static void __die__process_tag(Dwarf_Die *die, struct cu *cu, const char *fn)
new_tag = die__create_new_base_type(die); break;
case DW_TAG_const_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
case DW_TAG_volatile_type:
new_tag = die__create_new_tag(die); break;
case DW_TAG_enumeration_type:
@ -2556,6 +2573,7 @@ static int cus__emit_tag_definitions(struct cus *self, struct cu *cu,
return 0;
next_indirection:
if (type->tag == DW_TAG_pointer_type ||
type->tag == DW_TAG_reference_type ||
type->tag == DW_TAG_array_type ||
type->tag == DW_TAG_const_type ||
type->tag == DW_TAG_volatile_type) {