diff options
Diffstat (limited to 'libctf/ctf-dump.c')
-rw-r--r-- | libctf/ctf-dump.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index ad43666..b6a6075 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -610,10 +610,11 @@ ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state, int functions) static int ctf_dump_var (ctf_dict_t *fp, ctf_id_t type, unsigned long offset, - size_t size _libctf_unused_, void *arg) + size_t size, void *arg) { char *str; char *typestr; + int linkage; ctf_dump_state_t *state = arg; ctf_id_t otype = type; @@ -625,17 +626,26 @@ ctf_dump_var (ctf_dict_t *fp, ctf_id_t type, /* Specialized var dumper: only dump the linkage, not the type kind or anything related. */ - if ((typestr = ctf_type_aname (fp, type)) == NULL) - { - ctf_err_warn (fp, 1, ctf_errno (fp), _("cannot format name dumping var 0x%lx"), - type); - return 0; - } + if ((linkage = ctf_type_linkage (fp, type)) < 0 + || asprintf (&typestr, "%s%s", linkage == 0 ? "static " + : (linkage == 2 ? "extern " : + (linkage == 1 ? "" : "(invalid linkage) ")), + ctf_type_name_raw (fp, type)) < 0) + goto err; str = str_append (str, typestr); - str = str_append (str, ": "); free (typestr); + if (size != 0) + { + if (asprintf (&typestr, " (datasec size: %zi)", size) < 0) + goto err; + + str = str_append (str, typestr); + str = str_append (str, ": "); + free (typestr); + } + if ((type = ctf_type_reference (fp, type)) == CTF_ERR) { ctf_err_warn (fp, 1, ctf_errno (fp), _("cannot deref dumping var 0x%lx"), @@ -656,6 +666,10 @@ ctf_dump_var (ctf_dict_t *fp, ctf_id_t type, ctf_dump_append (fp, state, str); return 0; +err: + ctf_err_warn (fp, 1, ctf_errno (fp), _("cannot print name dumping var 0x%lx"), + type); + return 0; } /* Dump all DATASECs with associated vars. */ |