Dump label when "-l" is given.
authorMartin Pieuchot <mpi@openbsd.org>
Mon, 14 Mar 2016 19:05:44 +0000 (20:05 +0100)
committerMartin Pieuchot <mpi@openbsd.org>
Wed, 16 Mar 2016 08:18:15 +0000 (09:18 +0100)
ctfdump.c

index 0abc2d77995ffa065b606a09a6f5fbf344e1ee33..85bce4caaba699e0db7f09151d78fad0ed907a85 100644 (file)
--- a/ctfdump.c
+++ b/ctfdump.c
@@ -40,6 +40,7 @@
 #define DUMP_OBJECT    (1 << 0)
 #define DUMP_FUNCTION  (1 << 1)
 #define DUMP_HEADER    (1 << 2)
+#define DUMP_LABEL     (1 << 3)
 
 int             dump(const char *, uint32_t);
 int             iself(const char *, size_t);
@@ -75,6 +76,9 @@ main(int argc, char *argv[])
                case 'h':
                        flags |= DUMP_HEADER;
                        break;
+               case 'l':
+                       flags |= DUMP_LABEL;
+                       break;
                default:
                        usage();
                }
@@ -374,6 +378,20 @@ ctf_dump(const char *p, size_t size, uint32_t flags)
                printf("cth_strlen   = %d\n", cth->cth_strlen);
        }
 
+       if (flags & DUMP_LABEL) {
+               unsigned int             lbloff = cth->cth_lbloff;
+               struct ctf_lblent       *ctl;
+
+               while (lbloff < cth->cth_objtoff) {
+                       ctl = (struct ctf_lblent *)(data + lbloff);
+
+                       printf("%5u %s\n", ctl->ctl_typeidx,
+                           ctf_off2name(cth, data, dlen, ctl->ctl_label));
+
+                       lbloff += sizeof(*ctl);
+               }
+       }
+
        if (cth->cth_flags & CTF_F_COMPRESS)
                free(data);