libctf, ld: dump enums: generally improve dump formatting
authorNick Alcock <nick.alcock@oracle.com>
Tue, 5 Jan 2021 13:25:56 +0000 (13:25 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 5 Jan 2021 14:53:39 +0000 (14:53 +0000)
This commit adds dumping of enumerands in this general form:

    0x3: (kind 8) enum eleven_els (size 0x4) (aligned at 0x4)
         ELEVEN_ONE: 10
         ELEVEN_TWO: 11
         ELEVEN_THREE: -256
         ELEVEN_FOUR: -255
         ELEVEN_FIVE: -254
         ...
         ELEVEN_SEVEN: -252
         ELEVEN_EIGHT: -251
         ELEVEN_NINE: -250
         ELEVEN_TEN: -249
         ELEVEN_ELEVEN: -248

The first and last enumerands in the enumerated type are printed so that
you can tell if they've been cut off at one end or the other.  (For now,
there is no way to control how many enumerands are printed.)

The dump output in general is improved, from this sort of thing a few
days ago:

     4c: char [0x0:0x8] (size 0x1)
        [0x0] (ID 0x4c) (kind 1) char:8 (aligned at 0x1, format 0x3, offset:bits 0x0:0x8)
     4d: char * (size 0x8) -> 4c: char [0x0:0x8] (size 0x1)
        [0x0] (ID 0x4d) (kind 3) char * (aligned at 0x8)
[...]
     5a: struct _IO_FILE (size 0xd8)
        [0x0] (ID 0x5a) (kind 6) struct _IO_FILE (aligned at 0x4)
            [0x0] (ID 0x3) (kind 1) int _flags:32 (aligned at 0x4, format 0x1, offset:bits 0x0:0x20)
            [0x40] (ID 0x4d) (kind 3) char * _IO_read_ptr (aligned at 0x8)
            [0x80] (ID 0x4d) (kind 3) char * _IO_read_end (aligned at 0x8)
            [0xc0] (ID 0x4d) (kind 3) char * _IO_read_base (aligned at 0x8)
     5b: __FILE (size 0xd8) -> 5a: struct _IO_FILE (size 0xd8)
        [0x0] (ID 0x5b) (kind 10) __FILE (aligned at 0x4)
            [0x0] (ID 0x3) (kind 1) int _flags:32 (aligned at 0x4, format 0x1, offset:bits 0x0:0x20)
            [0x40] (ID 0x4d) (kind 3) char * _IO_read_ptr (aligned at 0x8)
            [0x80] (ID 0x4d) (kind 3) char * _IO_read_end (aligned at 0x8)
            [0xc0] (ID 0x4d) (kind 3) char * _IO_read_base (aligned at 0x8)
[...]
     406: struct coff_link_hash_entry (size 0x60)
        [0x0] (ID 0x406) (kind 6) struct coff_link_hash_entry (aligned at 0x8)
            [0x0] (ID 0x2b3) (kind 6) struct bfd_link_hash_entry root (aligned at 0x8)
                [0x0] (ID 0x1d6) (kind 6) struct bfd_hash_entry root (aligned at 0x8)
                    [0x0] (ID 0x1d7) (kind 3) struct bfd_hash_entry * next (aligned at 0x8)
                    [0x40] (ID 0x61) (kind 3) const char * string (aligned at 0x8)
                    [0x80] (ID 0x1) (kind 1) long unsigned int hash:64 (aligned at 0x8, format 0x0, offset:bits 0x0:0x40)
                [0xc0] (ID 0x397) (kind 8) enum bfd_link_hash_type  type:8 (aligned at 0x1, format 0x0, offset:bits 0x0:0x8)
                [0xc8] (ID 0x1c7) (kind 1) unsigned int  non_ir_ref_regular:1 (aligned at 0x1, format 0x0, offset:bits 0x8:0x1)
                [0xc9] (ID 0x1c8) (kind 1) unsigned int  non_ir_ref_dynamic:1 (aligned at 0x1, format 0x0, offset:bits 0x9:0x1)
                [0xca] (ID 0x1c9) (kind 1) unsigned int  linker_def:1 (aligned at 0x1, format 0x0, offset:bits 0xa:0x1)
                [0xcb] (ID 0x1ca) (kind 1) unsigned int  ldscript_def:1 (aligned at 0x1, format 0x0, offset:bits 0xb:0x1)
                [0xcc] (ID 0x1cb) (kind 1) unsigned int  rel_from_abs:1 (aligned at 0x1, format 0x0, offset:bits 0xc:0x1)

... to this:

    0x4c: (kind 1) char (format 0x3) (size 0x1) (aligned at 0x1)
    0x4d: (kind 3) char * (size 0x8) (aligned at 0x8) -> 0x4c: (kind 1) char (format 0x3) (size 0x1) (aligned at 0x1)
    0x5a: (kind 6) struct _IO_FILE (size 0xd8) (aligned at 0x4)
          [0x0] _flags: ID 0x3: (kind 1) int (format 0x1) (size 0x4) (aligned at 0x4)
          [0x40] _IO_read_ptr: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
          [0x80] _IO_read_end: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
          [0xc0] _IO_read_base: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
          [0x100] _IO_write_base: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
    0x5b: (kind 10) __FILE (size 0xd8) (aligned at 0x4) -> 0x5a: (kind 6) struct _IO_FILE (size 0xd8) (aligned at 0x4)
[...]
    0x406: (kind 6) struct coff_link_hash_entry (size 0x60) (aligned at 0x8)
           [0x0] root: ID 0x2b3: (kind 6) struct bfd_link_hash_entry (size 0x38) (aligned at 0x8)
               [0x0] root: ID 0x1d6: (kind 6) struct bfd_hash_entry (size 0x18) (aligned at 0x8)
                   [0x0] next: ID 0x1d7: (kind 3) struct bfd_hash_entry * (size 0x8) (aligned at 0x8)
                   [0x40] string: ID 0x61: (kind 3) const char * (size 0x8) (aligned at 0x8)
                   [0x80] hash: ID 0x1: (kind 1) long unsigned int (format 0x0) (size 0x8) (aligned at 0x8)
               [0xc0] type: ID 0x397: (kind 8) enum bfd_link_hash_type (format 0x7f2e) (size 0x1) (aligned at 0x1)
               [0xc8] non_ir_ref_regular: ID 0x1c7: (kind 1) unsigned int:1 [slice 0x8:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
               [0xc9] non_ir_ref_dynamic: ID 0x1c8: (kind 1) unsigned int:1 [slice 0x9:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
               [0xca] linker_def: ID 0x1c9: (kind 1) unsigned int:1 [slice 0xa:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
               [0xcb] ldscript_def: ID 0x1ca: (kind 1) unsigned int:1 [slice 0xb:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
               [0xcc] rel_from_abs: ID 0x1cb: (kind 1) unsigned int:1 [slice 0xc:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
[...]

In particular, indented subsections are only present for actual structs
and unions, not forwards to them, and the structure itself doesn't add a
spurious level of indentation; structure field names are easier to spot
(at the cost of not making them look so much like C field declarations
any more, but they weren't always shown in valid decl syntax even before
this change) the size, type kind, and alignment are shown for all types
for which they are meaningful; bitfield info is only shown for actual
bitfields within structures and not ordinary integral fields; and type
IDs are never omitted.  Type printing is in general much more consistent
and there is much less duplicated code in the type dumper.

There is one user-visible effect outside the dumper: ctf_type_(a)name
was erroneously emitting a trailing space on the name of slice types,
even though a slice of an int and an int with the corresponding encoding
represent the same type and should have the same print form.  This
trailing space is now gone.

ld/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/ld-ctf/array.d: Adjust for dumper changes.
* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Likewise.
* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/cycle-1.d: Likewise.
* testsuite/ld-ctf/cycle-2.A.d: Likewise.
* testsuite/ld-ctf/cycle-2.B.d: Likewise.
* testsuite/ld-ctf/cycle-2.C.d: Likewise.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
* testsuite/ld-ctf/diag-cuname.d: Likewise.
* testsuite/ld-ctf/diag-parlabel.d: Likewise.
* testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Likewise.
* testsuite/ld-ctf/forward.d: Likewise.
* testsuite/ld-ctf/function.d: Likewise.
* testsuite/ld-ctf/slice.d: Likewise.
* testsuite/ld-ctf/super-sub-cycles.d: Likewise.
* testsuite/ld-ctf/enums.c: New test.
* testsuite/ld-ctf/enums.d: New test.

libctf/ChangeLog
2021-01-05  Nick Alcock  <nick.alcock@oracle.com>

* ctf-decl.c (ctf_decl_push): Exclude slices from the decl stack.
* ctf-types.c (ctf_type_aname): No longer deal with slices here.
* ctf-dump.c (ctf_dump_membstate_t) <cdm_toplevel_indent>: Constify.
(CTF_FT_REFS): New.
(CTF_FT_BITFIELD): Likewise.
(CTF_FT_ID): Likewise.
(ctf_dump_member): Do not do indentation here. Migrate the
type-printing parts of this into...
(ctf_dump_format_type): ... here, to be shared by all type printers.
Get the errno value for non-representable types right.  Do not print
bitfield info for non-bitfields.  Improve the format and indentation
of other type output.  Shuffle spacing around to make all indentation
either 'width of column' or 4 chars.
(ctf_dump_label): Pass CTF_FT_REFS to ctf_dump_format_type.
(ctf_dump_objts): Likewise.  Spacing shuffle.
(ctf_dump_var): Likewise.
(type_hex_digits): Migrate down in the file, to above its new user.
(ctf_dump_type): Indent here instead.  Pass CTF_FT_REFS to
ctf_dump_format_type. Don't trim off excess linefeeds now we no
longer generate them.  Dump enumerated types.

36 files changed:
ld/ChangeLog
ld/testsuite/ld-ctf/array.d
ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d
ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d
ld/testsuite/ld-ctf/conflicting-cycle-1.parent.d
ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d
ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d
ld/testsuite/ld-ctf/conflicting-cycle-2.parent.d
ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d
ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d
ld/testsuite/ld-ctf/conflicting-cycle-3.parent.d
ld/testsuite/ld-ctf/conflicting-enums.d
ld/testsuite/ld-ctf/conflicting-typedefs.d
ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d
ld/testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d
ld/testsuite/ld-ctf/cross-tu-into-cycle.d
ld/testsuite/ld-ctf/cross-tu-noncyclic.d
ld/testsuite/ld-ctf/cycle-1.d
ld/testsuite/ld-ctf/cycle-2.A.d
ld/testsuite/ld-ctf/cycle-2.B.d
ld/testsuite/ld-ctf/cycle-2.C.d
ld/testsuite/ld-ctf/data-func-conflicted.d
ld/testsuite/ld-ctf/diag-cttname-null.d
ld/testsuite/ld-ctf/diag-cuname.d
ld/testsuite/ld-ctf/diag-parlabel.d
ld/testsuite/ld-ctf/diag-wrong-magic-number-mixed.d
ld/testsuite/ld-ctf/enums.c [new file with mode: 0644]
ld/testsuite/ld-ctf/enums.d [new file with mode: 0644]
ld/testsuite/ld-ctf/forward.d
ld/testsuite/ld-ctf/function.d
ld/testsuite/ld-ctf/slice.d
ld/testsuite/ld-ctf/super-sub-cycles.d
libctf/ChangeLog
libctf/ctf-decl.c
libctf/ctf-dump.c
libctf/ctf-types.c

index 1497fc40e702a9acbfc93b19e90c148130a1d718..213aed02ecb91965ef2ea407182380a4950efb26 100644 (file)
@@ -1,3 +1,37 @@
+2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
+
+       * testsuite/ld-ctf/array.d: Adjust for dumper changes.
+       * testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
+       * testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
+       * testsuite/ld-ctf/conflicting-enums.d: Likewise.
+       * testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
+       * testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
+       * testsuite/ld-ctf/cycle-1.d: Likewise.
+       * testsuite/ld-ctf/cycle-2.A.d: Likewise.
+       * testsuite/ld-ctf/cycle-2.B.d: Likewise.
+       * testsuite/ld-ctf/cycle-2.C.d: Likewise.
+       * testsuite/ld-ctf/data-func-conflicted.d: Likewise.
+       * testsuite/ld-ctf/diag-cttname-null.d: Likewise.
+       * testsuite/ld-ctf/diag-cuname.d: Likewise.
+       * testsuite/ld-ctf/diag-parlabel.d: Likewise.
+       * testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Likewise.
+       * testsuite/ld-ctf/forward.d: Likewise.
+       * testsuite/ld-ctf/function.d: Likewise.
+       * testsuite/ld-ctf/slice.d: Likewise.
+       * testsuite/ld-ctf/super-sub-cycles.d: Likewise.
+       * testsuite/ld-ctf/enums.c: New test.
+       * testsuite/ld-ctf/enums.d: New test.
+
 2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
 
        * testsuite/ld-ctf/conflicting-cycle-1.parent.d: Adjust for dumper
index 6c3915a7cf8f97a44e4b501ab6ff3a38424f6494..16375620c03c796e6d0a077e3bf7e51750552e51 100644 (file)
@@ -20,8 +20,8 @@ Contents of CTF section .ctf:
   Labels:
 
   Data objects:
-    digits -> 0x[0-9a-f]*: int \[10\] .*
-    digits_names -> 0x[0-9a-f]*: char \*\[10\] .*
+    digits -> 0x[0-9a-f]*: \(kind 4\) int \[10\] .*
+    digits_names -> 0x[0-9a-f]*: \(kind 4\) char \*\[10\] .*
 
   Function objects:
 
@@ -29,7 +29,7 @@ Contents of CTF section .ctf:
 
   Types:
 #...
-     0x[0-9a-f]*: .*\[10\] .*
+    0x[0-9a-f]*: \(kind 4\) .*\[10\] \(size .*
 #...
-     0x[0-9a-f]*: .*\[10\] .*
+    0x[0-9a-f]*: \(kind 4\) .*\[10\] \(size .*
 #...
index 99b0564bad7c439287fe071909d13da0b04bc3c2..27273c5386fb4e36dc2e55228b0ded439c21d518 100644 (file)
@@ -30,12 +30,11 @@ CTF archive member: .*/B.c:
   Function objects:
 
   Variables:
-    b ->  0x80000001: struct B \(size 0x[0-9]*\)
+    b -> 0x80000001: \(kind 6\) struct B \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Types:
-     0x8[0-9a-f]*: struct B .*
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct B \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* c \(.*
+    0x8[0-9a-f]*: \(kind 6\) struct B .*
+        *\[0x0\] c: ID 0x[0-9a-f]*: \(kind 3\) struct C \* \(.*
 
   Strings:
 #...
index 32bc5c24f0522b99f39bf695f1f82a7800a7477c..28a92f4a73edd8744a31d6ed130e4d193ee09ff3 100644 (file)
@@ -30,13 +30,12 @@ CTF archive member: .*/B-2.c:
   Function objects:
 
   Variables:
-    b ->  0x80000001: struct B \(.*
+    b -> 0x80000001: \(kind 6\) struct B \(.*
 
   Types:
-     0x8[0-9a-f]*: struct B \(.*
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct B \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* c \(.*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 1\) int wombat:32 \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
+    0x8[0-9a-f]*: \(kind 6\) struct B \(.*
+        *\[0x0\] c: ID 0x[0-9a-f]*: \(kind 3\) struct C \* \(.*
+        *\[0x[0-9a-f]*\] wombat: ID 0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
 #...
index 5da66fda14c99371b59720ee68c1c7ef785776c8..a9755e88db76e69310ff8ee0f6481b97b3d8a29f 100644 (file)
@@ -29,8 +29,7 @@ Contents of CTF section .ctf:
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct B
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct B
+    0x[0-9a-f]*: \(kind 9\) struct B
 #...
 CTF archive member: .*:
 #...
index 5e5fade0af8104a95cdc9ce5a5dae66ec11bda59..33ed6e843ce1c06953675bd08f2e5e2041a79c26 100644 (file)
@@ -29,12 +29,11 @@ CTF archive member: .*/A.c:
   Function objects:
 
   Variables:
-    a ->  0x80000001: struct A \(size 0x[0-9a-f]*\)
+    a -> 0x80000001: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Types:
-     0x8[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct A \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(aligned at 0x[0-9a-f]*\)
+    0x8[0-9a-f]*: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
     0x0: 
index ff6785cfde216c7059ef523ef27b857bf3d9ab3c..a98b66c267e750f4303c9847ca26fdd2c1404d1a 100644 (file)
@@ -29,13 +29,12 @@ CTF archive member: .*/A-2.c:
   Function objects:
 
   Variables:
-    a ->  0x80000001: struct A \(size 0x[0-9a-f]*\)
+    a -> 0x80000001: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Types:
-     0x8[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct A \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(aligned at 0x[0-9a-f]*\)
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 1\) int wombat:32 \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
+    0x8[0-9a-f]*: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x[0-9a-f]*\] wombat: ID 0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
     0x0: 
index d111ef7b9946d7d03c26f4025564a862c30bff81..87ec41d69e4fbfb1c5468e4dd12964390a5e85ce 100644 (file)
@@ -28,13 +28,12 @@ Contents of CTF section .ctf:
   Function objects:
 
   Variables:
-    cycle_1 ->  0x[0-9a-f]*: struct cycle_1 \* \(size 0x[0-9a-f]*\) -> 0x[0-9a-f]*: struct cycle_1 \(size 0x[0-9a-f]*\)
+    cycle_1 -> 0x[0-9a-f]*: \(kind 3\) struct cycle_1 \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]*: \(kind 6\) struct cycle_1 \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Types:
 #...
-     0x[0-9a-f]*: struct cycle_1 \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct cycle_1 \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(aligned at 0x[0-9a-f]*\)
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(aligned at 0x[0-9a-f]*\)
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct cycle_1 \* next \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 6\) struct cycle_1 \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x[0-9a-f]*\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x[0-9a-f]*\] next: ID 0x[0-9a-f]*: \(kind 3\) struct cycle_1 \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
index df61153db2a8dd72dcba61de8ffead67056aefcd..ac750a776dbe110dd1cfc712d2475830b6b741cc 100644 (file)
@@ -28,12 +28,11 @@ CTF archive member: .*/C.c:
   Function objects:
 
   Variables:
-    c ->  0x80000001: struct C \(size 0x[0-9a-f]*\)
+    c -> 0x80000001: \(kind 6\) struct C \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Types:
-     0x8[0-9a-f]*: struct C \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct C \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(aligned at 0x[0-9a-f]*\)
+    0x80000001: \(kind 6\) struct C \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
     0x0: 
index e1cfd0cf771492d4dcb9b6bf9906c05862bf0739..603432f05ad0f90f82f825d253094606c5751bc7 100644 (file)
@@ -28,13 +28,12 @@ CTF archive member: .*/C-2.c:
   Function objects:
 
   Variables:
-    c ->  0x80000001: struct C \(size 0x[0-9a-f]*\)
+    c -> 0x80000001: \(kind 6\) struct C \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Types:
-     0x8[0-9a-f]*: struct C \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct C \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(aligned at 0x[0-9a-f]*\)
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 1\) int wombat:[0-9]* \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
+    0x80000001: \(kind 6\) struct C \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+                \[0x0\] a: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+                \[0x[0-9a-f]*\] wombat: ID 0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
     0x0: 
index 11d2a048618d4aec17b14ad7f8e50f36a505da9e..24f080004cdd59580ff027c5d824cc321730eb7b 100644 (file)
@@ -30,8 +30,7 @@ Contents of CTF section .ctf:
 
   Types:
 #...
-     0x[0-9a-f]*: int \[0x0:0x[0-9a-f]*\] \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int:[0-9]* \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
   Strings:
     0x0: 
index b93d8124f36a2e6b99336222b146d7f770e441cd..f90aaef44b1e6020bcdedbb204fc8015d24bca7a 100644 (file)
@@ -20,16 +20,28 @@ Contents of CTF section .ctf:
 CTF archive member: .*enum.*\.c:
 #...
   Types:
-     0x8[0-9a-f]*: enum day_of_the_week \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 8\) enum day_of_the_week \(aligned at 0x[0-9a-f]*\)
+    0x80000001: \(kind 8\) enum day_of_the_week \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+                Sunday: 0
+                Monday: 1
+                Tuesday: 2
+                Wednesday: 3
+                Thursday: 4
+                Friday: 5
+                Saturday: 6
 
   Strings:
 #...
 CTF archive member: .*enum.*\.c:
 #...
   Types:
-     0x8[0-9a-f]*: enum day_of_the_week \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 8\) enum day_of_the_week \(aligned at 0x[0-9a-f]*\)
+    0x80000001: \(kind 8\) enum day_of_the_week \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+                Monday: 0
+                Tuesday: 1
+                Wednesday: 2
+                Thursday: 3
+                Friday: 4
+                Saturday: 5
+                Sunday: 6
 
   Strings:
 #...
index 309e4535d7fa147b0cdd7a5e4649afc428e36b3b..72082ba553b26b090ed0ef3ec3827a0369900a27 100644 (file)
@@ -14,20 +14,16 @@ Contents of CTF section .ctf:
     Version: 4 \(CTF_VERSION_3\)
 #...
   Types:
-     0x1: .*int .*
-          .*
-     0x[0-9]:.*int .*
-          .*
-     0x[0-9]: word .*
-           *\[0x0\] \(ID 0x[0-9]\) \(kind 10\) word \(aligned at 0x[48]\)
+    0x1: .*int .*
+    0x[0-9]:.*int .*
+    0x[0-9]: \(kind 10\) word .* -> 0x[0-9]: \(kind 1\) .*int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
 #...
 CTF archive member: .*typedef.*\.c:
 #...
   Types:
-     0x80000001: word .*
-           *\[0x0\] \(ID 0x80000001\) \(kind 10\) word \(aligned at 0x[48]\)
+    0x80000001: \(kind 10\) word .* -> 0x[0-9]: \(kind 1\) .*int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 
   Strings:
 #...
index eff295edd308612f010aac9e478da1d740879d57..eaf8e79c8adfe24d68c8207ad52b80d8fd6ba6db 100644 (file)
@@ -14,20 +14,15 @@ Contents of CTF section \.ctf:
 #...
   Types:
 #...
-     0x[0-9a-f]*: long int \[0x0:0x[0-9a-f]*\] \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int:[0-9]* \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 1\) long int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
-     0x[0-9a-f]*: struct B .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B .*
+    0x[0-9a-f]*: \(kind 6\) struct B .*
 #...
-     0x[0-9a-f]*: int \[0x0:0x[0-9a-f]*\] \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int:[0-9]* \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
-     0x[0-9a-f]*: struct A
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct A
+    0x[0-9a-f]*: \(kind 9\) struct A
 #...
-     0x[0-9a-f]*: struct C .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct C .*
+    0x[0-9a-f]*: \(kind 6\) struct C .*
 #...
 
   Strings:
@@ -36,10 +31,9 @@ Contents of CTF section \.ctf:
 CTF archive member: .*/ld/testsuite/ld-ctf/cross-tu-cyclic-1\.c:
 #...
   Types:
-     0x80.*[0-9a-f]*: struct A .*
-           *\[0x0\] \(ID 0x80.*\) \(kind 6\) struct A .*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int a:.*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* foo .*
+    0x80[0-9a-f]*: \(kind 6\) struct A .*
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 1\) long int .*
+        *\[0x[0-9a-f]*\] foo: ID 0x[0-9a-f]*\: \(kind 3\) struct B \* .*
 
   Strings:
 #...
@@ -47,11 +41,10 @@ CTF archive member: .*/ld/testsuite/ld-ctf/cross-tu-cyclic-1\.c:
 CTF archive member: .*/ld/testsuite/ld-ctf/cross-tu-cyclic-2\.c:
 #...
   Types:
-     0x80.*[0-9a-f]*: struct A .*
-           *\[0x0\] \(ID 0x80.*\) \(kind 6\) struct A .*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int a:.*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* foo .*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* bar .*
+    0x80[0-9a-f]*: \(kind 6\) struct A .*
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 1\) long int .*
+        *\[0x[0-9a-f]*\] foo: ID 0x[0-9a-f]*: \(kind 3\) struct B \* .*
+        *\[0x[0-9a-f]*\] bar: ID 0x[0-9a-f]*: \(kind 3\) struct C \* .*
 
   Strings:
 #...
index 9b0d738434a36d84749a081ecd3a4a19b511365c..1a714846d329b9a199791d0824c383e0214f5155 100644 (file)
@@ -29,22 +29,16 @@ Contents of CTF section .ctf:
 
   Types:
 #...
-     0x[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]\) \(kind 6\) struct A \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int a:[0-9]* \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* foo \(aligned at 0x[0-9a-f]*\)
-     0x[0-9a-f]*: long int .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int:[0-9].*
-     0x[0-9a-f]*: struct B \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B \(aligned at 0x[0-9a-f]*\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int foo:[0-9]* \(aligned at 0x[0-9a-f]*, format 0x1, offset:bits 0x0:0x[0-9a-f]*\)
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* bar \(aligned at 0x[0-9a-f]*\)
-     0x[0-9a-f]*: struct B \* \(size 0x[0-9a-f]*\) -> 0x[0-9a-f]*: struct B \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* \(aligned at 0x[0-9a-f]*\)
-     0x[0-9a-f]*: struct A \* \(size 0x[0-9a-f]*\) -> 0x[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* \(aligned at 0x[0-9a-f]*\)
-     0x[0-9a-f]*: int .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int:.*
+    0x[0-9a-f]*: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 1\) long int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x[0-9a-f]*\] foo: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 1\) long int .*
+    0x[0-9a-f]*: \(kind 6\) struct B \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] foo: ID 0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x[0-9a-f]*\] bar: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]*: \(kind 6\) struct B \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 3\) struct A \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]*: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 1\) int .*
 
   Strings:
 #...
index a21fedc8126eedff5cad91cce9bcf80238cb4bf3..7f3aebc54b7271695654ab81b1e75ee03d2c9ffc 100644 (file)
@@ -27,20 +27,16 @@ Contents of CTF section .ctf:
   Function objects:
 
   Variables:
-    a ->  .*
-    conflicty ->  .*
+    a -> .*
+    conflicty -> .*
 
   Types:
-     0x[0-9a-f]*: struct A .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A .*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* foo .*
-     0x[0-9a-f]*: struct B .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B .*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* next .*
-     0x[0-9a-f]*: struct B \* .*
-           *\[0x0\] .*
-     0x[0-9a-f]*: struct A \* .*
-           *\[0x0\] .*
+    0x[0-9a-f]*: \(kind 6\) struct A .*
+        *\[0x0\] foo: ID 0x[0-9a-f]*: \(kind 3\) struct B \* .*
+    0x[0-9a-f]*: \(kind 6\) struct B .*
+        *\[0x0\] next: ID 0x[0-9a-f]*: \(kind 3\) struct B \* .*
+    0x[0-9a-f]*: \(kind 3\) struct B \* .*
+    0x[0-9a-f]*: \(kind 3\) struct A \* .*
 
   Strings:
 #...
@@ -56,7 +52,7 @@ CTF archive member: .*/ld/testsuite/ld-ctf/cross-tu-cyclic-[34].c:
   Function objects:
 
   Variables:
-    conflicty ->  .*
+    conflicty -> .*
 
   Types:
 
index d96e5d20ee84f822d078c61959bb9cc0c6faaadd..e8fc7a49aa54c6ec63ad3f2f0c0acc8eca57b18b 100644 (file)
@@ -29,18 +29,14 @@ Contents of CTF section .ctf:
 
   Types:
 #...
-     0x[0-9a-f]*: struct A .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A .*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int a:[0-9]* .*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* foo .*
+    0x[0-9a-f]*: \(kind 6\) struct A .*
+       *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 1\) long int .*
+       *\[0x[0-9a-f]*\] foo: ID 0x[0-9a-f]*: \(kind 3\) struct B \* .*
 #...
-     0x[0-9a-f]*: struct B .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B .*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int foo:[0-9]* .*
+    0x[0-9a-f]*: \(kind 6\) struct B .*
+       *\[0x0\] foo: ID 0x[0-9a-f]*: \(kind 1\) int .*
 #...
-     0x[0-9a-f]*: struct B \* \(size 0x[0-9a-f]*\) -> 0x[0-9a-f]*: struct B .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* .*
+    0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]*: \(kind 6\) struct B .*
 #...
-     0x[0-9a-f]*: struct A \* \(size 0x[0-9a-f]*\) -> 0x[0-9a-f]*: struct A .*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* .*
+    0x[0-9a-f]*: \(kind 3\) struct A \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]*: \(kind 6\) struct A .*
 #...
index 578709349faba29ece3e76792ff9f73e7a1df7fc..e64608e757112e59f6eb1cf4c4b5d986f6e1e219 100644 (file)
@@ -28,9 +28,8 @@ Contents of CTF section .ctf:
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct cycle_1 \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct cycle_1 \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(.*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct cycle_1 \* next \(.*
+    0x[0-9a-f]*: \(kind 6\) struct cycle_1 \(.*
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(.*
+        *\[0x[0-9a-f]*\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
+        *\[0x[0-9a-f]*\] next: ID 0x[0-9a-f]*: \(kind 3\) struct cycle_1 \* \(.*
 #...
index ddb5381e93cf5b5b2ae1f97696dd7cd7a39e5ad5..39d48c14c4ba6da61b493bb400a75d258aab0f86 100644 (file)
@@ -25,13 +25,12 @@ Contents of CTF section .ctf:
 
   Variables:
 #...
-    a ->  0x[0-9a-f]*: struct A \(.*
+    a -> 0x[0-9a-f]*: \(kind 6\) struct A \(.*
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct A \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
+    0x[0-9a-f]*: \(kind 6\) struct A \(.*
+        *\[0x0\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
 #...
   Strings:
     0x0: 
index 1d1cdc5377db20533cd072cd303b22be33b414be..4babd97bffe58aaebb36262c3453865d6bb5e7cf 100644 (file)
@@ -25,13 +25,12 @@ Contents of CTF section .ctf:
 
   Variables:
 #...
-    b ->  0x[0-9a-f]*: struct B \(.*
+    b -> 0x[0-9a-f]*: \(kind 6\) struct B \(.*
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct B \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* c \(.*
+    0x[0-9a-f]*: \(kind 6\) struct B \(.*
+        *\[0x0\] c: ID 0x[0-9a-f]*: \(kind 3\) struct C \* \(.*
 #...
   Strings:
     0x0: 
index 4d8f14513dd936858e8c3942f69a353a71dba763..757483ca7e2db267620f9cbf5455950ae881eb80 100644 (file)
@@ -25,13 +25,12 @@ Contents of CTF section .ctf:
 
   Variables:
 #...
-    c ->  0x[0-9a-f]*: struct C \(.*
+    c -> 0x[0-9a-f]*: \(kind 6\) struct C \(.*
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct C \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct C \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(.*
+    0x[0-9a-f]*: \(kind 6\) struct C \(.*
+        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(.*
 #...
   Strings:
     0x0: 
index e51bb763af125fcd4609d7c8068420ac75ae9a24..6b1e9145a025dd96ff8aad1beb07914ffbdc02c8 100644 (file)
@@ -20,16 +20,16 @@ Contents of CTF section \.ctf:
     String section:    .*
 #...
   Data objects:
-    bar -> 0x[0-9a-f]*: struct var_3 \(size 0x[0-9a-f]*\)
-    var_1 -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_666 -> 0x[0-9a-f]*: foo_t \* \(size 0x[0-9a-f]*\) -> .*
+    bar -> 0x[0-9a-f]*: \(kind 6\) struct var_3 \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    var_1 -> 0x[0-9a-f]*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_666 -> 0x[0-9a-f]*: \(kind 3\) foo_t \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
 
   Function objects:
-    func_[0-9]* -> 0x[0-9a-f]*: void \*\(\*\) \(const char \*restrict, int \(\*\)\(\*\) \(const char \*\)\)
+    func_[0-9]* -> 0x[0-9a-f]*: \(kind 5\) void \*\(\*\) \(const char \*restrict, int \(\*\)\(\*\) \(const char \*\)\) \(aligned at 0x[0-9a-f]*\)
 #...
   Types:
 #...
-   .*: struct var_3 .*
+    .*: \(kind 6\) struct var_3 .*
 #...
 CTF archive member: .*/data-func-1\.c:
 
@@ -46,18 +46,19 @@ CTF archive member: .*/data-func-1\.c:
   Labels:
 
   Data objects:
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
-    var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
+    var_[0-9]* -> 0x80000001*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
 #...
   Function objects:
 
   Variables:
 
   Types:
-     0x80000001: foo_t .* -> .* int .*
+    0x80000001: \(kind 10\) foo_t .* -> .* int .*
 #...
index 86a7fd12da6f0e9312fcd77ae755fc241b2135f1..d1ca0b10c15548ab6a197cd841c56b540ed64bb0 100644 (file)
@@ -13,11 +13,10 @@ Contents of CTF section .ctf:
     Version: 4 \(CTF_VERSION_3\)
 #...
   Data objects:
-    a -> 0x[0-9a-f]*: struct  \(size 0x[0-9a-f]*\)
+    a -> 0x[0-9a-f]*: \(kind 6\) struct  \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct  \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct  \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
+    0x[0-9a-f]*: \(kind 6\) struct  \(.*
+        *\[0x0\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
 #...
index 20624fd8b7b94ea02811cd497deebac4841fc824..e4d49267a2a55ee20f676d83bea5c7bb49076243 100644 (file)
@@ -21,7 +21,7 @@ Contents of CTF section .ctf:
   Labels:
 
   Data objects:
-    a -> 0x[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
+    a -> 0x[0-9a-f]*: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
   Function objects:
 
@@ -29,9 +29,8 @@ Contents of CTF section .ctf:
 
   Types:
 #...
-     0x[0-9a-f]*: struct A \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
+    0x[0-9a-f]*: \(kind 6\) struct A \(.*
+        *\[0x0\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
 #...
   Strings:
     0x0: 
index 5ad58706b0e996f16a586e12065a86e1b9901652..bba161cf3093a4d974eb76b0518f3d0a2adaeadf 100644 (file)
@@ -20,7 +20,7 @@ Contents of CTF section .ctf:
   Labels:
 
   Data objects:
-    a -> 0x[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
+    a -> 0x[0-9a-f]*: \(kind 6\) struct A \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
   Function objects:
 
@@ -28,9 +28,8 @@ Contents of CTF section .ctf:
 
   Types:
 #...
-     0x[0-9a-f]*: struct A \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
+    0x[0-9a-f]*: \(kind 6\) struct A \(.*
+        *\[0x0\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
 #...
   Strings:
     0x0: 
index 8fc1cc883da37704b14707b261fb011cc328e5d4..668fa15bf49e26a79a6fc6cb1b225d6e2d81b185 100644 (file)
@@ -29,9 +29,9 @@ Contents of CTF section .ctf:
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct B \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* c \(.*
+    0x[0-9a-f]*: struct B \(.*
+          *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B \(.*
+              *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* c \(.*
 #...
   Strings:
     0x0: 
diff --git a/ld/testsuite/ld-ctf/enums.c b/ld/testsuite/ld-ctf/enums.c
new file mode 100644 (file)
index 0000000..b7c5587
--- /dev/null
@@ -0,0 +1,3 @@
+enum nine_els { NINE_ONE, NINE_TWO, NINE_THREE = 256, NINE_FOUR, NINE_FIVE, NINE_SIX, NINE_SEVEN, NINE_EIGHT, NINE_NINE } nine;
+enum ten_els { TEN_ONE = 10, TEN_TWO, TEN_THREE = -256, TEN_FOUR, TEN_FIVE, TEN_SIX, TEN_SEVEN, TEN_EIGHT, TEN_NINE, TEN_TEN } ten;
+enum eleven_els { ELEVEN_ONE = 10, ELEVEN_TWO, ELEVEN_THREE = -256, ELEVEN_FOUR, ELEVEN_FIVE, ELEVEN_SIX, ELEVEN_SEVEN, ELEVEN_EIGHT, ELEVEN_NINE, ELEVEN_TEN, ELEVEN_ELEVEN } eleven;
diff --git a/ld/testsuite/ld-ctf/enums.d b/ld/testsuite/ld-ctf/enums.d
new file mode 100644 (file)
index 0000000..f1cf70d
--- /dev/null
@@ -0,0 +1,54 @@
+#as:
+#source: enums.c
+#objdump: --ctf=.ctf
+#ld: -shared
+#name: Enumerated types
+
+.*: +file format .*
+
+Contents of CTF section .ctf:
+
+  Header:
+    Magic number: 0xdff2
+    Version: 4 \(CTF_VERSION_3\)
+#...
+    Compilation unit name: .*enums.c
+#...
+    Type section:      .*\(0x114 bytes\)
+#...
+  Types:
+    0x1: \(kind 8\) enum nine_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+         NINE_ONE: 0
+         NINE_TWO: 1
+         NINE_THREE: 256
+         NINE_FOUR: 257
+         NINE_FIVE: 258
+         NINE_SIX: 259
+         NINE_SEVEN: 260
+         NINE_EIGHT: 261
+         NINE_NINE: 262
+    0x2: \(kind 8\) enum ten_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+         TEN_ONE: 10
+         TEN_TWO: 11
+         TEN_THREE: -256
+         TEN_FOUR: -255
+         TEN_FIVE: -254
+         TEN_SIX: -253
+         TEN_SEVEN: -252
+         TEN_EIGHT: -251
+         TEN_NINE: -250
+         TEN_TEN: -249
+    0x3: \(kind 8\) enum eleven_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+         ELEVEN_ONE: 10
+         ELEVEN_TWO: 11
+         ELEVEN_THREE: -256
+         ELEVEN_FOUR: -255
+         ELEVEN_FIVE: -254
+         \.\.\.
+         ELEVEN_SEVEN: -252
+         ELEVEN_EIGHT: -251
+         ELEVEN_NINE: -250
+         ELEVEN_TEN: -249
+         ELEVEN_ELEVEN: -248
+
+#...
index 9ff0dd2ba73e7e72b518cbbe83d52058671e25d1..bb929612125a8a3b15e744647f4549bcf6d34d6e 100644 (file)
@@ -16,8 +16,6 @@ Contents of CTF section .ctf:
 #...
   Types:
 
-     0x[0-9a-f]: struct foo
-          *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct foo
-     0x[0-9a-f]: struct foo \* \(size 0x[0-9a-f]*\) -> 0x[0-9a-f]: struct foo
-          *\[0x0\] \(ID 0x[0-9a-f]\) \(kind 3\) struct foo \* \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]: \(kind 9\) struct foo
+    0x[0-9a-f]: \(kind 3\) struct foo \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]: \(kind 9\) struct foo
 #...
index 9bf26a48928e4a3089ebd7c82146db8bf0e43d05..1584bdbedfd6df9cefca1179bf6c42c5093ee663 100644 (file)
@@ -18,10 +18,9 @@ Contents of CTF section .ctf:
     String section:    .*
 #...
   Function objects:
-    foo -> 0x[0-9a-f]*: int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\)
+    foo -> 0x[0-9a-f]*: \(kind 5\) int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\) \(aligned at 0x[0-9a-f]*\)
 #...
   Types:
 #...
-     0x[0-9a-f]*: int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 5\) int \(\*\) \(char, int[0-9]*, float, void \*, void \(\*\)\(\*\) \(int\)\) \(aligned at 0x[0-9a-f]*\)
+    0x[0-9a-f]*: \(kind 5\) int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\) \(aligned at 0x[0-9a-f]*\)
 #...
index 3967a2db537a42f1487723fc53604f19848c776c..d1167828f475767dd13bdc6e1df08782c47d8c03 100644 (file)
@@ -19,14 +19,14 @@ Contents of CTF section .ctf:
     String section:    .*
 #...
   Data objects:
-    slices -> 0x[0-9a-f]*: struct slices \(size 0x[0-9a-f]*\)
+    slices -> 0x[0-9a-f]*: \(kind 6\) struct slices \(size 0x[0-9a-f]*\) \(aligned at 0x1*\)
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct slices \(size 0x[0-9a-f]*\)
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct slices \(aligned at 0x1\)
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int  one:1 \(aligned at 0x1, format 0x1, offset:bits 0x0:0x1\)
-               *\[0x1\] \(ID 0x[0-9a-f]*\) \(kind 1\) int  two:2 \(aligned at 0x1, format 0x1, offset:bits 0x1:0x2\)
-               *\[0x3\] \(ID 0x[0-9a-f]*\) \(kind 1\) int  six:6 \(aligned at 0x1, format 0x1, offset:bits 0x3:0x6\)
-               *\[0x9\] \(ID 0x[0-9a-f]*\) \(kind 1\) int  ten:10 \(aligned at 0x2, format 0x1, offset:bits 0x9:0xa\)
+    0x[0-9a-f]*: \(kind 6\) struct slices \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+        *\[0x0\] one: ID 0x[0-9a-f]*: \(kind 1\) int:1 \[slice 0x0:0x1\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+        *\[0x1\] two: ID 0x[0-9a-f]*: \(kind 1\) int:2 \[slice 0x1:0x2\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+        *\[0x3\] six: ID 0x[0-9a-f]*: \(kind 1\) int:6 \[slice 0x3:0x6\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+        *\[0x9\] ten: ID 0x[0-9a-f]*: \(kind 1\) int:10 \[slice 0x9:0xa\] \(format 0x1\) \(size 0x2\) \(aligned at 0x2\)
+
 #...
index 65a43a4de9ca653c6d68f6e0d76692ba73641784..67fa358bc542c9aadbcb5b001b97fb8d67bed238 100644 (file)
@@ -18,18 +18,17 @@ Contents of CTF section .ctf:
 #...
   Types:
 #...
-     0x[0-9a-f]*: struct A \(.*
-           *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.*
-               *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B b \(.*
-                   *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct C c \(.*
-                       *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(.*
-                       *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct D d \(.*
-                           *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
-                   *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct D d \(.*
-                       *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.*
-               *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct X x \(.*
-                   *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct Y y \(.*
-                       *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct Z z \(.*
-                           *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct Y \* y \(.*
-                           *\[0x[0-9a-f]*\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct D \* d \(.*
+    0x[0-9a-f]: \(kind 6\) struct A \(.*
+         \[0x0\] b: ID 0x[0-9a-f]*: \(kind 6\) struct B \(.*
+             \[0x0\] c: ID 0x[0-9a-f]*: \(kind 6\) struct C \(.*
+                 \[0x0\] a: ID 0x[0-9a-f]*: \(kind 3\) struct A \* \(.*
+                 \[0x[0-9a-f]*\] d: ID 0x[0-9a-f]*: \(kind 6\) struct D \(.*
+                     \[0x[0-9a-f]*\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
+             \[0x[0-9a-f]*\] d: ID 0x[0-9a-f]*: \(kind 6\) struct D \(.*
+                 \[0x[0-9a-f]*\] b: ID 0x[0-9a-f]*: \(kind 3\) struct B \* \(.*
+         \[0x[0-9a-f]*\] x: ID 0x[0-9a-f]*: \(kind 6\) struct X \(.*
+             \[0x[0-9a-f]*\] y: ID 0x[0-9a-f]*: \(kind 6\) struct Y \(.*
+                 \[0x[0-9a-f]*\] z: ID 0x[0-9a-f]*: \(kind 6\) struct Z \(.*
+                     \[0x[0-9a-f]*\] y: ID 0x[0-9a-f]*: \(kind 3\) struct Y \* \(.*
+                     \[0x[0-9a-f]*\] d: ID 0x[0-9a-f]*: \(kind 3\) struct D \* \(.*
 #...
index b9142541063d4a617128bde7a441fd3540f0de90..8ba75f32e1f44c13da36a450da9893ca87348fa8 100644 (file)
@@ -1,3 +1,26 @@
+2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-decl.c (ctf_decl_push): Exclude slices from the decl stack.
+       * ctf-types.c (ctf_type_aname): No longer deal with slices here.
+       * ctf-dump.c (ctf_dump_membstate_t) <cdm_toplevel_indent>: Constify.
+       (CTF_FT_REFS): New.
+       (CTF_FT_BITFIELD): Likewise.
+       (CTF_FT_ID): Likewise.
+       (ctf_dump_member): Do not do indentation here. Migrate the
+       type-printing parts of this into...
+       (ctf_dump_format_type): ... here, to be shared by all type printers.
+       Get the errno value for non-representable types right.  Do not print
+       bitfield info for non-bitfields.  Improve the format and indentation
+       of other type output.  Shuffle spacing around to make all indentation
+       either 'width of column' or 4 chars.
+       (ctf_dump_label): Pass CTF_FT_REFS to ctf_dump_format_type.
+       (ctf_dump_objts): Likewise.  Spacing shuffle.
+       (ctf_dump_var): Likewise.
+       (type_hex_digits): Migrate down in the file, to above its new user.
+       (ctf_dump_type): Indent here instead.  Pass CTF_FT_REFS to
+       ctf_dump_format_type. Don't trim off excess linefeeds now we no
+       longer generate them.  Dump enumerated types.
+
 2021-01-05  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-types.c (ctf_type_resolve): Improve comment.
index 232ff5d71c04b26afff1c2d00a97def47a21730d..269eca42a729f88f0f18023b8cff86764f3a3851 100644 (file)
@@ -117,9 +117,10 @@ ctf_decl_push (ctf_decl_t *cd, ctf_dict_t *fp, ctf_id_t type)
       break;
 
     case CTF_K_SLICE:
+      /* Slices themselves have no print representation and should not appear in
+        the decl stack.  */
       ctf_decl_push (cd, fp, ctf_type_reference (fp, type));
-      prec = CTF_PREC_BASE;
-      break;
+      return;
 
     case CTF_K_VOLATILE:
     case CTF_K_CONST:
index abed48310f6c70c2a7ac28853655e92fa698198a..758d28d76d58a816292b5aafc35b97c15fc08bbc 100644 (file)
@@ -47,7 +47,7 @@ typedef struct ctf_dump_membstate
 {
   char **cdm_str;
   ctf_dict_t *cdm_fp;
-  char *cdm_toplevel_indent;
+  const char *cdm_toplevel_indent;
 } ctf_dump_membstate_t;
 
 static int
@@ -80,8 +80,12 @@ ctf_dump_free (ctf_dump_state_t *state)
     }
 }
 
-/* Return a dump for a single type, without member info: but do show the
-   type's references.  */
+/* Return a dump for a single type, without member info: but do optionally show
+   the type's references.  */
+
+#define CTF_FT_REFS     0x2    /* Print referenced types.  */
+#define CTF_FT_BITFIELD 0x4    /* Print :BITS if a bitfield.  */
+#define CTF_FT_ID       0x8    /* Print "ID: " in front of type IDs.  */
 
 static char *
 ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
@@ -89,14 +93,16 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
   ctf_id_t new_id;
   char *str = NULL, *bit = NULL, *buf = NULL;
 
+  ctf_set_errno (fp, 0);
   new_id = id;
   do
     {
-      ctf_encoding_t enc;
+      ctf_encoding_t ep;
       ctf_arinfo_t ar;
       int kind, unsliced_kind;
       const char *nonroot_leader = "";
       const char *nonroot_trailer = "";
+      const char *idstr = "";
 
       id = new_id;
       if (flag == CTF_ADD_NONROOT)
@@ -110,15 +116,18 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
        {
          if (id == 0 || ctf_errno (fp) == ECTF_NONREPRESENTABLE)
            {
+             ctf_set_errno (fp, ECTF_NONREPRESENTABLE);
              str = str_append (str, " (type not represented in CTF)");
-             ctf_set_errno (fp, ECTF_NOTREF);
-             break;
+             return str;
            }
 
          goto err;
        }
 
-      if (asprintf (&bit, " %s0x%lx: ", nonroot_leader, id) < 0)
+      if (flag & CTF_FT_ID)
+       idstr = "ID ";
+      if (asprintf (&bit, "%s%s0x%lx: (kind %i) ", nonroot_leader, idstr,
+                   id, ctf_type_kind (fp, id)) < 0)
        goto oom;
       str = str_append (str, bit);
       free (bit);
@@ -129,37 +138,74 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
 
       free (buf);
       buf = NULL;
+
       unsliced_kind = ctf_type_kind_unsliced (fp, id);
       kind = ctf_type_kind (fp, id);
 
-      /* Slices get a different print representation.  */
-      if (unsliced_kind == CTF_K_SLICE)
+      if (ctf_type_encoding (fp, id, &ep) == 0)
        {
-         ctf_type_encoding (fp, id, &enc);
-         if (asprintf (&bit, " [slice 0x%x:0x%x]",
-                       enc.cte_offset, enc.cte_bits) < 0)
+         if (ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
+             && flag & CTF_FT_BITFIELD)
+           {
+             if (asprintf (&bit, ":%i", ep.cte_bits) < 0)
+               goto oom;
+             str = str_append (str, bit);
+             free (bit);
+             bit = NULL;
+           }
+
+         if (ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
+             || ep.cte_offset != 0)
+           {
+             const char *slice = "";
+
+             if (unsliced_kind == CTF_K_SLICE)
+               slice = "slice ";
+
+             if (asprintf (&bit, " [%s0x%x:0x%x]",
+                           slice, ep.cte_offset, ep.cte_bits) < 0)
+               goto oom;
+             str = str_append (str, bit);
+             free (bit);
+             bit = NULL;
+           }
+
+         if (asprintf (&bit, " (format 0x%x)", ep.cte_format) < 0)
            goto oom;
+         str = str_append (str, bit);
+         free (bit);
+         bit = NULL;
        }
-      else if (kind == CTF_K_INTEGER)
+
+      if (kind != CTF_K_FUNCTION && kind != CTF_K_FORWARD)
        {
-         ctf_type_encoding (fp, id, &enc);
-         if (asprintf (&bit, " [0x%x:0x%x]",
-                       enc.cte_offset, enc.cte_bits) < 0)
+         if (asprintf (&bit, " (size 0x%lx)",
+                       (unsigned long) ctf_type_size (fp, id)) < 0)
            goto oom;
+
+         str = str_append (str, bit);
+         free (bit);
+         bit = NULL;
        }
-      str = str_append (str, bit);
-      free (bit);
-      bit = NULL;
 
-      if (kind != CTF_K_FUNCTION && kind != CTF_K_FORWARD)
-       if (asprintf (&bit, " (size 0x%lx)%s",
-                     (unsigned long) ctf_type_size (fp, id),
-                     nonroot_trailer) < 0)
-         goto oom;
+      if (kind != CTF_K_FORWARD)
+       {
+         if (asprintf (&bit, " (aligned at 0x%lx)",
+                       (unsigned long) ctf_type_align (fp, id)) < 0)
+           goto oom;
 
-      str = str_append (str, bit);
-      free (bit);
-      bit = NULL;
+         str = str_append (str, bit);
+         free (bit);
+         bit = NULL;
+       }
+
+      if (nonroot_trailer[0] != 0)
+       str = str_append (str, nonroot_trailer);
+
+      /* Just exit after one iteration if we are not showing the types this type
+        references.  */
+      if (!(flag & CTF_FT_REFS))
+       return str;
 
       /* Keep going as long as this type references another.  We consider arrays
         to "reference" their element type. */
@@ -173,7 +219,7 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
       else
        new_id = ctf_type_reference (fp, id);
       if (new_id != CTF_ERR)
-       str = str_append (str, " ->");
+       str = str_append (str, " -> ");
     } while (new_id != CTF_ERR);
 
   if (ctf_errno (fp) != ECTF_NOTREF)
@@ -363,7 +409,7 @@ ctf_dump_label (const char *name, const ctf_lblinfo_t *info,
     return (ctf_set_errno (state->cds_fp, errno));
 
   if ((typestr = ctf_dump_format_type (state->cds_fp, info->ctb_type,
-                                      CTF_ADD_ROOT)) == NULL)
+                                      CTF_ADD_ROOT | CTF_FT_REFS)) == NULL)
     {
       free (str);
       return 0;                                /* Swallow the error.  */
@@ -400,14 +446,14 @@ ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state, int functions)
         has a leading one.   */
       if (name)
        {
-         if (asprintf (&str, "%s ->", name) < 0)
+         if (asprintf (&str, "%s -> ", name) < 0)
            goto oom;
        }
       else
        str = xstrdup ("");
 
       if ((typestr = ctf_dump_format_type (state->cds_fp, id,
-                                          CTF_ADD_ROOT)) == NULL)
+                                          CTF_ADD_ROOT | CTF_FT_REFS)) == NULL)
        {
          ctf_dump_append (state, str);
          continue;                             /* Swallow the error.  */
@@ -438,7 +484,7 @@ ctf_dump_var (const char *name, ctf_id_t type, void *arg)
     return (ctf_set_errno (state->cds_fp, errno));
 
   if ((typestr = ctf_dump_format_type (state->cds_fp, type,
-                                      CTF_ADD_ROOT)) == NULL)
+                                      CTF_ADD_ROOT | CTF_FT_REFS)) == NULL)
     {
       free (str);
       return 0;                        /* Swallow the error.  */
@@ -451,22 +497,7 @@ ctf_dump_var (const char *name, ctf_id_t type, void *arg)
   return 0;
 }
 
-/* Report the number of digits in the hexadecimal representation of a type
-   ID.  */
-
-static int
-type_hex_digits (ctf_id_t id)
-{
-  int i = 0;
-
-  if (id == 0)
-    return 1;
-
-  for (; id > 0; id >>= 4, i++);
-  return i;
-}
-
-/* Dump a single member into the string in the membstate.  */
+/* Dump a single struct/union member into the string in the membstate.  */
 static int
 ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset,
                 int depth, void *arg)
@@ -474,72 +505,23 @@ ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset,
   ctf_dump_membstate_t *state = arg;
   char *typestr = NULL;
   char *bit = NULL;
-  ctf_encoding_t ep;
-  int has_encoding = 0;
-  int opened_paren = 0;
-
-  /* Align neatly.  */
 
+  /* The struct/union itself has already been printed.  */
   if (depth == 0)
-    {
-      if (asprintf (&state->cdm_toplevel_indent, "     %*s",
-                   type_hex_digits (id), "") < 0)
-       goto oom;
-    }
+    return 0;
 
-  if (asprintf (&bit, "%s%*s", state->cdm_toplevel_indent, depth * 4, "") < 0)
+  if (asprintf (&bit, "%s%*s", state->cdm_toplevel_indent, (depth-1)*4, "") < 0)
     goto oom;
   *state->cdm_str = str_append (*state->cdm_str, bit);
   free (bit);
 
-  if ((typestr = ctf_type_aname (state->cdm_fp, id)) == NULL)
-    {
-      if (id == 0 || ctf_errno (state->cdm_fp) == ECTF_NONREPRESENTABLE)
-       {
-         if (asprintf (&bit, "[0x%lx] (type not represented in CTF)",
-                       offset) < 0)
-           goto oom;
-
-         *state->cdm_str = str_append (*state->cdm_str, bit);
-         free (typestr);
-         free (bit);
-         return 0;
-       }
+  if ((typestr = ctf_dump_format_type (state->cdm_fp, id,
+                                      CTF_ADD_ROOT | CTF_FT_BITFIELD
+                                      | CTF_FT_ID)) == NULL)
+    return -1;                         /* errno is set for us.  */
 
-      return -1;                               /* errno is set for us.  */
-    }
-
-  if (ctf_type_encoding (state->cdm_fp, id, &ep) == 0)
-    {
-      has_encoding = 1;
-      ctf_type_encoding (state->cdm_fp, id, &ep);
-
-      if (asprintf (&bit, "[0x%lx] (ID 0x%lx) (kind %i) %s%s%s:%i "
-                   "(aligned at 0x%lx", offset, id,
-                   ctf_type_kind (state->cdm_fp, id), typestr,
-                   (name[0] != 0 && typestr[0] != 0) ? " " : "", name,
-                   ep.cte_bits, (unsigned long) ctf_type_align (state->cdm_fp,
-                                                                id)) < 0)
-       goto oom;
-      opened_paren = 1;
-    }
-  else if (ctf_type_kind (state->cdm_fp, id) != CTF_K_FORWARD)
-    {
-      if (asprintf (&bit, "[0x%lx] (ID 0x%lx) (kind %i) %s%s%s "
-                   "(aligned at 0x%lx", offset, id,
-                   ctf_type_kind (state->cdm_fp, id), typestr,
-                   (name[0] != 0 && typestr[0] != 0) ? " " : "", name,
-                   (unsigned long) ctf_type_align (state->cdm_fp, id)) < 0)
-       goto oom;
-      opened_paren = 1;
-    }
-  else /* Forwards have no alignment.  */
-    {
-      if (asprintf (&bit, "[0x%lx] (ID 0x%lx) (kind %i) %s%s%s\n", offset, id,
-                   ctf_type_kind (state->cdm_fp, id), typestr,
-                   (name[0] != 0 && typestr[0] != 0) ? " " : "", name) < 0)
-       goto oom;
-    }
+  if (asprintf (&bit, "[0x%lx] %s: %s\n", offset, name, typestr) < 0)
+    goto oom;
 
   *state->cdm_str = str_append (*state->cdm_str, bit);
   free (typestr);
@@ -547,18 +529,6 @@ ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset,
   typestr = NULL;
   bit = NULL;
 
-  if (has_encoding)
-    {
-      if (asprintf (&bit, ", format 0x%x, offset:bits 0x%x:0x%x", ep.cte_format,
-                   ep.cte_offset, ep.cte_bits) < 0)
-       goto oom;
-      *state->cdm_str = str_append (*state->cdm_str, bit);
-      free (bit);
-      bit = NULL;
-    }
-
-  if (opened_paren)
-    *state->cdm_str = str_append (*state->cdm_str, ")\n");
   return 0;
 
  oom:
@@ -567,44 +537,112 @@ ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset,
   return (ctf_set_errno (state->cdm_fp, errno));
 }
 
+/* Report the number of digits in the hexadecimal representation of a type
+   ID.  */
+
+static int
+type_hex_digits (ctf_id_t id)
+{
+  int i = 0;
+
+  if (id == 0)
+    return 1;
+
+  for (; id > 0; id >>= 4, i++);
+  return i;
+}
+
 /* Dump a single type into the cds_items.  */
 static int
 ctf_dump_type (ctf_id_t id, int flag, void *arg)
 {
   char *str;
+  char *indent;
+  int err = 0;
   ctf_dump_state_t *state = arg;
   ctf_dump_membstate_t membstate = { &str, state->cds_fp, NULL };
-  size_t len;
 
-  if ((str = ctf_dump_format_type (state->cds_fp, id, flag)) == NULL)
-    goto err;
+  /* Indent neatly.  */
+  if (asprintf (&indent, "    %*s", type_hex_digits (id), "") < 0)
+    return (ctf_set_errno (state->cds_fp, ENOMEM));
 
+  /* Dump the type itself.  */
+  if ((str = ctf_dump_format_type (state->cds_fp, id,
+                                  flag | CTF_FT_REFS)) == NULL)
+    goto err;
   str = str_append (str, "\n");
-  if ((ctf_type_visit (state->cds_fp, id, ctf_dump_member, &membstate)) < 0)
+
+  membstate.cdm_toplevel_indent = indent;
+
+  /* Member dumping for structs, unions...  */
+  if (ctf_type_kind (state->cds_fp, id) == CTF_K_STRUCT
+      || ctf_type_kind (state->cds_fp, id) == CTF_K_UNION)
     {
-      if (id == 0 || ctf_errno (state->cds_fp) == ECTF_NONREPRESENTABLE)
+      if ((ctf_type_visit (state->cds_fp, id, ctf_dump_member, &membstate)) < 0)
        {
-         ctf_dump_append (state, str);
-         return 0;
+         if (id == 0 || ctf_errno (state->cds_fp) == ECTF_NONREPRESENTABLE)
+           {
+             ctf_dump_append (state, str);
+             return 0;
+           }
+         ctf_err_warn (state->cds_fp, 1, ctf_errno (state->cds_fp),
+                       _("cannot visit members dumping type 0x%lx"), id);
+         goto err;
        }
-      ctf_err_warn (state->cds_fp, 1, ctf_errno (state->cds_fp),
-                   _("cannot visit members dumping type 0x%lx"), id);
-      goto err;
     }
-  free (membstate.cdm_toplevel_indent);
 
-  /* Trim off the last linefeed added by ctf_dump_member().  */
-  len = strlen (str);
-  if (str[len-1] == '\n')
-    str[len-1] = '\0';
+  /* ... and enums, for which we dump the first and last few members and skip
+     the ones in the middle.  */
+  if (ctf_type_kind (state->cds_fp, id) == CTF_K_ENUM)
+    {
+      int enum_count = ctf_member_count (state->cds_fp, id);
+      ctf_next_t *it = NULL;
+      int i = 0;
+      const char *enumerand;
+      char *bit;
+      int value;
+
+      while ((enumerand = ctf_enum_next (state->cds_fp, id,
+                                        &it, &value)) != NULL)
+       {
+         i++;
+         if ((i > 5) && (i < enum_count - 4))
+           continue;
+
+         str = str_append (str, indent);
+
+         if (asprintf (&bit, "%s: %i\n", enumerand, value) < 0)
+           {
+             err = ENOMEM;
+             ctf_next_destroy (it);
+             goto err;
+           }
+         str = str_append (str, bit);
+         free (bit);
+
+         if ((i == 5) && (enum_count > 10))
+           {
+             str = str_append (str, indent);
+             str = str_append (str, "...\n");
+           }
+       }
+      if (ctf_errno (state->cds_fp) != ECTF_NEXT_END)
+       {
+         ctf_err_warn (state->cds_fp, 1, ctf_errno (state->cds_fp),
+                       _("cannot visit enumerands dumping type 0x%lx"), id);
+         goto err;
+       }
+    }
 
   ctf_dump_append (state, str);
+  free (indent);
+
   return 0;
 
  err:
-  free (membstate.cdm_toplevel_indent);
+  free (indent);
   free (str);
-  return 0;                            /* Swallow the error.  */
+  return ctf_set_errno (state->cds_fp, err);
 }
 
 /* Dump the string table into the cds_items.  */
index 3ba635f48bbf961e8e3d3983d499f43ecd8c16dc..a3d824b88482181a34403833cb5c1b14773dbc43 100644 (file)
@@ -826,10 +826,6 @@ ctf_type_aname (ctf_dict_t *fp, ctf_id_t type)
            case CTF_K_RESTRICT:
              ctf_decl_sprintf (&cd, "restrict");
              break;
-           case CTF_K_SLICE:
-             /* No representation: just changes encoding of contained type,
-                which is not in any case printed.  Skip it.  */
-             break;
            }
 
          k = cdp->cd_kind;
This page took 0.049122 seconds and 4 git commands to generate.