summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dwarf-extract-struct.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/dwarf-extract-struct.c b/dwarf-extract-struct.c
index dfd373b..57e7bbd 100644
--- a/dwarf-extract-struct.c
+++ b/dwarf-extract-struct.c
@@ -430,6 +430,7 @@ static void print_field(Dwarf_Debug dbg, Dwarf_Die die, const char *field_name,
int offset = 0;
char type_buf[1024];
char array_buf[128] = "";
+ char pointer_buf[128] = "";
int rc;
rc = dwarf_get_offset(dbg, die, &offset, &err);
@@ -482,24 +483,26 @@ static void print_field(Dwarf_Debug dbg, Dwarf_Die die, const char *field_name,
exit(7);
}
- if (type_tag == DW_TAG_pointer_type) {
+ while (type_tag == DW_TAG_pointer_type) {
+ pointer_buf[pointer++] = '*';
+
rc = deref_type(dbg, type_die, &next,
&type_tag, &err);
/* No entry here means void* */
- if (rc != DW_DLV_NO_ENTRY) {
- if (rc != DW_DLV_OK) {
- fprintf(stderr,
- "Could not deref type for %s: %s\n",
- field_name, dwarf_errmsg(err));
- exit(7);
- }
+ if (rc == DW_DLV_NO_ENTRY)
+ break;
- dwarf_dealloc(dbg, type_die, DW_DLA_DIE);
- type_die = next;
+ if (rc != DW_DLV_OK) {
+ fprintf(stderr,
+ "Could not deref type for %s: %s\n",
+ field_name, dwarf_errmsg(err));
+ exit(7);
}
- pointer++;
+ dwarf_dealloc(dbg, type_die, DW_DLA_DIE);
+ type_die = next;
}
+
if (type_tag == DW_TAG_array_type) {
int next_offset, size;
@@ -592,13 +595,13 @@ static void print_field(Dwarf_Debug dbg, Dwarf_Die die, const char *field_name,
if (type_tag == DW_TAG_structure_type) {
snprintf(type_buf, 1024, "struct %s %s",
- type_name, pointer ? "*" : "");
+ type_name, pointer_buf);
} else if (type_tag == DW_TAG_base_type
|| type_tag == DW_TAG_typedef) {
snprintf(type_buf, 1024, "%s %s", type_name,
- pointer ? "*" : "");
+ pointer_buf);
} else if (type_tag == DW_TAG_pointer_type) {
- snprintf(type_buf, 1024, "void *");
+ snprintf(type_buf, 1024, "void %s", pointer_buf);
} else {
const char *tag_name;