From 57f97d0e6dd4dfbb54f2f39c5e59d5860040d0b6 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Tue, 5 Jan 2021 13:25:56 +0000 Subject: [PATCH] libctf, ld: CTF dumper changes for consistency In most places in CTF dumper output, we emit 0x... for hex strings, but in three places (top-level type IDs, string table offsets, and the file magic number) we don't emit the 0x. This is very confusing if by chance there are no hex digits in the output. Add 0x consistently to everything, and adjust tests accordingly. While we're at it, improve the indentation of the output so that subsequent lines in aggregate output are indented by at least as many columns as the colon in the type output. (Subsequent indentation is still 4 spaces at a time.) ld/ChangeLog 2021-01-05 Nick Alcock * 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/function.d: Likewise. * testsuite/ld-ctf/slice.d: Likewise. * testsuite/ld-ctf/super-sub-cycles.d: Likewise. libctf/ChangeLog 2021-01-05 Nick Alcock * ctf-dump.c (ctf_dump_format_type): Add 0x to hex type IDs. (ctf_dump_header): Add 0x to the hex magic number. (ctf_dump_str): Add 0x to the hex string offsets. (ctf_dump_membstate_t) : New. (ctf_dump_type): Adjust. Free it when we're done. (type_hex_digits): New. (ctf_dump_member): Align output depending on the width of the type ID being generated. Use printf padding, not a loop, to generate indentation. --- ld/ChangeLog | 31 ++++++++++++ ld/testsuite/ld-ctf/array.d | 6 +-- ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d | 10 ++-- ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d | 12 ++--- .../ld-ctf/conflicting-cycle-1.parent.d | 6 +-- ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d | 12 ++--- ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d | 14 +++--- .../ld-ctf/conflicting-cycle-2.parent.d | 14 +++--- ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d | 12 ++--- ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d | 14 +++--- .../ld-ctf/conflicting-cycle-3.parent.d | 8 +-- ld/testsuite/ld-ctf/conflicting-enums.d | 10 ++-- ld/testsuite/ld-ctf/conflicting-typedefs.d | 18 +++---- .../ld-ctf/cross-tu-cyclic-conflicting.d | 38 +++++++------- .../ld-ctf/cross-tu-cyclic-nonconflicting.d | 34 ++++++------- ld/testsuite/ld-ctf/cross-tu-into-cycle.d | 22 ++++---- ld/testsuite/ld-ctf/cross-tu-noncyclic.d | 24 ++++----- ld/testsuite/ld-ctf/cycle-1.d | 12 ++--- ld/testsuite/ld-ctf/cycle-2.A.d | 14 +++--- ld/testsuite/ld-ctf/cycle-2.B.d | 14 +++--- ld/testsuite/ld-ctf/cycle-2.C.d | 14 +++--- ld/testsuite/ld-ctf/data-func-conflicted.d | 6 +-- ld/testsuite/ld-ctf/diag-cttname-null.d | 8 +-- ld/testsuite/ld-ctf/diag-cuname.d | 12 ++--- ld/testsuite/ld-ctf/diag-parlabel.d | 12 ++--- .../ld-ctf/diag-wrong-magic-number-mixed.d | 14 +++--- ld/testsuite/ld-ctf/function.d | 6 +-- ld/testsuite/ld-ctf/slice.d | 14 +++--- ld/testsuite/ld-ctf/super-sub-cycles.d | 30 +++++------ libctf/ChangeLog | 12 +++++ libctf/ctf-dump.c | 50 +++++++++++++++---- 31 files changed, 287 insertions(+), 216 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index dee8378bcc7..21ba58a0bfd 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,34 @@ +2021-01-05 Nick Alcock + + * 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/function.d: Likewise. + * testsuite/ld-ctf/slice.d: Likewise. + * testsuite/ld-ctf/super-sub-cycles.d: Likewise. + 2021-01-05 Alan Modra * testsuite/ld-scripts/sysroot-prefix.exp: Exclude some targets. diff --git a/ld/testsuite/ld-ctf/array.d b/ld/testsuite/ld-ctf/array.d index 82e9939783f..e07d63e2243 100644 --- a/ld/testsuite/ld-ctf/array.d +++ b/ld/testsuite/ld-ctf/array.d @@ -10,7 +10,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Data object section: .* \(0x8 bytes\) @@ -29,7 +29,7 @@ Contents of CTF section .ctf: Types: #... - [0-9a-f]*: .*\[10\] .* + 0x[0-9a-f]*: .*\[10\] .* #... - [0-9a-f]*: .*\[10\] .* + 0x[0-9a-f]*: .*\[10\] .* #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d b/ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d index 40636f062f5..99b0564bad7 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-1.B-1.d @@ -14,7 +14,7 @@ CTF archive member: .*/B.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: .ctf @@ -30,12 +30,12 @@ CTF archive member: .*/B.c: Function objects: Variables: - b -> 80000001: struct B \(size 0x[0-9]*\) + b -> 0x80000001: struct B \(size 0x[0-9]*\) Types: - 8[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]*: struct B .* + *\[0x0\] \(ID 0x8[0-9a-f]*\) \(kind 6\) struct B \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct C \* c \(.* Strings: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d b/ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d index c6fdceb8cf8..32bc5c24f05 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-1.B-2.d @@ -14,7 +14,7 @@ CTF archive member: .*/B-2.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: .ctf @@ -30,13 +30,13 @@ CTF archive member: .*/B-2.c: Function objects: Variables: - b -> 80000001: struct B \(.* + b -> 0x80000001: struct B \(.* Types: - 8[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]*: 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]*\) Strings: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-1.parent.d b/ld/testsuite/ld-ctf/conflicting-cycle-1.parent.d index 558eb36f2fe..4cbe9b61f3c 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-1.parent.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-1.parent.d @@ -13,7 +13,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0xac bytes\) @@ -29,8 +29,8 @@ Contents of CTF section .ctf: #... Types: #... - [0-9a-f]*: struct B \(.* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct B \(.* + 0x[0-9a-f]*: struct B \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct B \(.* #... CTF archive member: .*: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d b/ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d index 79282a248e6..5e5fade0af8 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-2.A-1.d @@ -16,7 +16,7 @@ CTF archive member: .*/A.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: .* @@ -29,13 +29,13 @@ CTF archive member: .*/A.c: Function objects: Variables: - a -> 80000001: struct A \(size 0x[0-9a-f]*\) + a -> 0x80000001: struct A \(size 0x[0-9a-f]*\) Types: - 8[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]*: 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]*\) Strings: - 0: + 0x0: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d b/ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d index 4f6d44e3577..ff6785cfde2 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-2.A-2.d @@ -16,7 +16,7 @@ CTF archive member: .*/A-2.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: .* @@ -29,14 +29,14 @@ CTF archive member: .*/A-2.c: Function objects: Variables: - a -> 80000001: struct A \(size 0x[0-9a-f]*\) + a -> 0x80000001: struct A \(size 0x[0-9a-f]*\) Types: - 8[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]*: 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]*\) Strings: - 0: + 0x0: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-2.parent.d b/ld/testsuite/ld-ctf/conflicting-cycle-2.parent.d index 95aa17d4dd2..d111ef7b994 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-2.parent.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-2.parent.d @@ -15,7 +15,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0x94 bytes\) @@ -28,13 +28,13 @@ Contents of CTF section .ctf: Function objects: Variables: - cycle_1 -> [0-9a-f]*: struct cycle_1 \* \(size 0x[0-9a-f]*\) -> [0-9a-f]*: struct cycle_1 \(size 0x[0-9a-f]*\) + 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]*\) Types: #... - [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]*: 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]*\) #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d b/ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d index 48078b93c97..df61153db2a 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-3.C-1.d @@ -15,7 +15,7 @@ CTF archive member: .*/C.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: .* @@ -28,13 +28,13 @@ CTF archive member: .*/C.c: Function objects: Variables: - c -> 80000001: struct C \(size 0x[0-9a-f]*\) + c -> 0x80000001: struct C \(size 0x[0-9a-f]*\) Types: - 8[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]*\) + 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]*\) Strings: - 0: + 0x0: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d b/ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d index 854a71938e4..e1cfd0cf771 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-3.C-2.d @@ -15,7 +15,7 @@ CTF archive member: .*/C-2.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: .* @@ -28,14 +28,14 @@ CTF archive member: .*/C-2.c: Function objects: Variables: - c -> 80000001: struct C \(size 0x[0-9a-f]*\) + c -> 0x80000001: struct C \(size 0x[0-9a-f]*\) Types: - 8[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]*\) + 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]*\) Strings: - 0: + 0x0: #... diff --git a/ld/testsuite/ld-ctf/conflicting-cycle-3.parent.d b/ld/testsuite/ld-ctf/conflicting-cycle-3.parent.d index 28525b6c4fa..11d2a048618 100644 --- a/ld/testsuite/ld-ctf/conflicting-cycle-3.parent.d +++ b/ld/testsuite/ld-ctf/conflicting-cycle-3.parent.d @@ -14,7 +14,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: 0x0 -- 0x57 \(0x58 bytes\) @@ -30,9 +30,9 @@ Contents of CTF section .ctf: Types: #... - [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]*: 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]*\) #... Strings: - 0: + 0x0: #... diff --git a/ld/testsuite/ld-ctf/conflicting-enums.d b/ld/testsuite/ld-ctf/conflicting-enums.d index 8b16b4cb9e1..b93d8124f36 100644 --- a/ld/testsuite/ld-ctf/conflicting-enums.d +++ b/ld/testsuite/ld-ctf/conflicting-enums.d @@ -10,7 +10,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Types: @@ -20,16 +20,16 @@ Contents of CTF section .ctf: CTF archive member: .*enum.*\.c: #... Types: - 8[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]*\) + 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]*\) Strings: #... CTF archive member: .*enum.*\.c: #... Types: - 8[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]*\) + 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]*\) Strings: #... diff --git a/ld/testsuite/ld-ctf/conflicting-typedefs.d b/ld/testsuite/ld-ctf/conflicting-typedefs.d index 09d6c3cf54e..309e4535d7f 100644 --- a/ld/testsuite/ld-ctf/conflicting-typedefs.d +++ b/ld/testsuite/ld-ctf/conflicting-typedefs.d @@ -10,24 +10,24 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Types: - 1: .*int .* - .* - [0-9]:.*int .* - .* - [0-9]: word .* - \[0x0\] \(ID 0x[0-9]\) \(kind 10\) word \(aligned at 0x[48]\) + 0x1: .*int .* + .* + 0x[0-9]:.*int .* + .* + 0x[0-9]: word .* + *\[0x0\] \(ID 0x[0-9]\) \(kind 10\) word \(aligned at 0x[48]\) Strings: #... CTF archive member: .*typedef.*\.c: #... Types: - 80000001: word .* - \[0x0\] \(ID 0x80000001\) \(kind 10\) word \(aligned at 0x[48]\) + 0x80000001: word .* + *\[0x0\] \(ID 0x80000001\) \(kind 10\) word \(aligned at 0x[48]\) Strings: #... diff --git a/ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d b/ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d index aa36533ea37..3c975ebaa51 100644 --- a/ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d +++ b/ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d @@ -14,20 +14,20 @@ Contents of CTF section \.ctf: #... Types: #... - [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]*: 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]*\) #... - [0-9a-f]*: struct B .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B .* + 0x[0-9a-f]*: struct B .* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B .* #... - [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]*: 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]*\) #... - [0-9a-f]*: struct A .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct A .* + 0x[0-9a-f]*: struct A .* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 9\) struct A .* #... - [0-9a-f]*: struct C .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct C .* + 0x[0-9a-f]*: struct C .* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct C .* #... Strings: @@ -36,10 +36,10 @@ Contents of CTF section \.ctf: CTF archive member: .*/ld/testsuite/ld-ctf/cross-tu-cyclic-1\.c: #... Types: - 80.*[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]*: 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 .* Strings: #... @@ -47,11 +47,11 @@ 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: - 80.*[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]*: 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 .* Strings: #... diff --git a/ld/testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d b/ld/testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d index 39f5c187e54..9b0d738434a 100644 --- a/ld/testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d +++ b/ld/testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d @@ -14,7 +14,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... @@ -29,22 +29,22 @@ Contents of CTF section .ctf: Types: #... - [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]*\) - [0-9a-f]*: long int .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) long int:[0-9].* - [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]*\) - [0-9a-f]*: struct B \* \(size 0x[0-9a-f]*\) -> [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]*\) - [0-9a-f]*: struct A \* \(size 0x[0-9a-f]*\) -> [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]*\) - [0-9a-f]*: int .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int:.* + 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:.* Strings: #... diff --git a/ld/testsuite/ld-ctf/cross-tu-into-cycle.d b/ld/testsuite/ld-ctf/cross-tu-into-cycle.d index 6bfdc40a800..a21fedc8126 100644 --- a/ld/testsuite/ld-ctf/cross-tu-into-cycle.d +++ b/ld/testsuite/ld-ctf/cross-tu-into-cycle.d @@ -16,7 +16,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... @@ -31,16 +31,16 @@ Contents of CTF section .ctf: conflicty -> .* Types: - [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 .* - [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 .* - [0-9a-f]*: struct B \* .* - \[0x0\] .* - [0-9a-f]*: struct A \* .* - \[0x0\] .* + 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\] .* Strings: #... diff --git a/ld/testsuite/ld-ctf/cross-tu-noncyclic.d b/ld/testsuite/ld-ctf/cross-tu-noncyclic.d index 418119a7367..d96e5d20ee8 100644 --- a/ld/testsuite/ld-ctf/cross-tu-noncyclic.d +++ b/ld/testsuite/ld-ctf/cross-tu-noncyclic.d @@ -12,7 +12,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0x74 bytes\) @@ -29,18 +29,18 @@ Contents of CTF section .ctf: Types: #... - [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]*: 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 .* #... - [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]*: struct B .* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct B .* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 1\) int foo:[0-9]* .* #... - [0-9a-f]*: struct B \* \(size 0x[0-9a-f]*\) -\> [0-9a-f]*: struct B .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* .* + 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 \* .* #... - [0-9a-f]*: struct A \* \(size 0x[0-9a-f]*\) -> [0-9a-f]*: struct A .* - \[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* .* + 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 \* .* #... diff --git a/ld/testsuite/ld-ctf/cycle-1.d b/ld/testsuite/ld-ctf/cycle-1.d index 8e9530b3146..578709349fa 100644 --- a/ld/testsuite/ld-ctf/cycle-1.d +++ b/ld/testsuite/ld-ctf/cycle-1.d @@ -12,7 +12,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0xa8 bytes\) @@ -28,9 +28,9 @@ Contents of CTF section .ctf: #... Types: #... - [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]*: 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 \(.* #... diff --git a/ld/testsuite/ld-ctf/cycle-2.A.d b/ld/testsuite/ld-ctf/cycle-2.A.d index a909b90e738..ddb5381e93c 100644 --- a/ld/testsuite/ld-ctf/cycle-2.A.d +++ b/ld/testsuite/ld-ctf/cycle-2.A.d @@ -11,7 +11,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0x6c bytes\) @@ -25,16 +25,16 @@ Contents of CTF section .ctf: Variables: #... - a -> [0-9a-f]*: struct A \(.* + a -> 0x[0-9a-f]*: struct A \(.* #... Types: #... - [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]*: struct A \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.* #... Strings: - 0: + 0x0: #... - [0-9a-f]*: A + 0x[0-9a-f]*: A #... diff --git a/ld/testsuite/ld-ctf/cycle-2.B.d b/ld/testsuite/ld-ctf/cycle-2.B.d index 320e17cc767..1d1cdc5377d 100644 --- a/ld/testsuite/ld-ctf/cycle-2.B.d +++ b/ld/testsuite/ld-ctf/cycle-2.B.d @@ -11,7 +11,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0x6c bytes\) @@ -25,16 +25,16 @@ Contents of CTF section .ctf: Variables: #... - b -> [0-9a-f]*: struct B \(.* + b -> 0x[0-9a-f]*: struct B \(.* #... Types: #... - [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: - 0: + 0x0: #... - [0-9a-f]*: B + 0x[0-9a-f]*: B #... diff --git a/ld/testsuite/ld-ctf/cycle-2.C.d b/ld/testsuite/ld-ctf/cycle-2.C.d index df436062bd3..4d8f14513dd 100644 --- a/ld/testsuite/ld-ctf/cycle-2.C.d +++ b/ld/testsuite/ld-ctf/cycle-2.C.d @@ -11,7 +11,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Type section: .* \(0x6c bytes\) @@ -25,16 +25,16 @@ Contents of CTF section .ctf: Variables: #... - c -> [0-9a-f]*: struct C \(.* + c -> 0x[0-9a-f]*: struct C \(.* #... Types: #... - [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]*: struct C \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct C \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct A \* a \(.* #... Strings: - 0: + 0x0: #... - [0-9a-f]*: C + 0x[0-9a-f]*: C #... diff --git a/ld/testsuite/ld-ctf/data-func-conflicted.d b/ld/testsuite/ld-ctf/data-func-conflicted.d index 1fa8bb2fe5f..62855f8189e 100644 --- a/ld/testsuite/ld-ctf/data-func-conflicted.d +++ b/ld/testsuite/ld-ctf/data-func-conflicted.d @@ -10,7 +10,7 @@ Contents of CTF section \.ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Data object section: .* \(0xc bytes\) @@ -34,7 +34,7 @@ Contents of CTF section \.ctf: CTF archive member: .*/data-func-1\.c: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Parent name: \.ctf @@ -59,5 +59,5 @@ CTF archive member: .*/data-func-1\.c: Variables: Types: - 80000001: foo_t .* -> .* int .* + 0x80000001: foo_t .* -> .* int .* #... diff --git a/ld/testsuite/ld-ctf/diag-cttname-null.d b/ld/testsuite/ld-ctf/diag-cttname-null.d index 4523dbc5e2f..00db4251a4d 100644 --- a/ld/testsuite/ld-ctf/diag-cttname-null.d +++ b/ld/testsuite/ld-ctf/diag-cttname-null.d @@ -9,7 +9,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Data objects: @@ -17,7 +17,7 @@ Contents of CTF section .ctf: #... Types: #... - [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]*: struct \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.* #... diff --git a/ld/testsuite/ld-ctf/diag-cuname.d b/ld/testsuite/ld-ctf/diag-cuname.d index 45e9a7e6771..19a4bfd80fa 100644 --- a/ld/testsuite/ld-ctf/diag-cuname.d +++ b/ld/testsuite/ld-ctf/diag-cuname.d @@ -9,7 +9,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Compilation unit name: \(\?\) @@ -29,12 +29,12 @@ Contents of CTF section .ctf: Types: #... - [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]*: struct A \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.* #... Strings: - 0: + 0x0: #... - [0-9a-f]*: \(\?\) + 0x[0-9a-f]*: \(\?\) #... diff --git a/ld/testsuite/ld-ctf/diag-parlabel.d b/ld/testsuite/ld-ctf/diag-parlabel.d index f0f40243310..b2b047cb10f 100644 --- a/ld/testsuite/ld-ctf/diag-parlabel.d +++ b/ld/testsuite/ld-ctf/diag-parlabel.d @@ -9,7 +9,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Compilation unit name: .*A.c @@ -28,12 +28,12 @@ Contents of CTF section .ctf: Types: #... - [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]*: struct A \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 6\) struct A \(.* + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 3\) struct B \* b \(.* #... Strings: - 0: + 0x0: #... - [0-9a-f]*: A + 0x[0-9a-f]*: A #... diff --git a/ld/testsuite/ld-ctf/diag-wrong-magic-number-mixed.d b/ld/testsuite/ld-ctf/diag-wrong-magic-number-mixed.d index cb394985d93..8fc1cc883da 100644 --- a/ld/testsuite/ld-ctf/diag-wrong-magic-number-mixed.d +++ b/ld/testsuite/ld-ctf/diag-wrong-magic-number-mixed.d @@ -10,7 +10,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Variable section: 0x0 -- 0x17 \(0x18 bytes\) @@ -25,16 +25,16 @@ Contents of CTF section .ctf: Variables: #... - b -> [0-9a-f]*: struct B \(.* + b -> 0x[0-9a-f]*: struct B \(.* #... Types: #... - [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: - 0: + 0x0: #... - [0-9a-f]*: B + 0x[0-9a-f]*: B #... diff --git a/ld/testsuite/ld-ctf/function.d b/ld/testsuite/ld-ctf/function.d index f5303d7c3ba..241adc2fb3a 100644 --- a/ld/testsuite/ld-ctf/function.d +++ b/ld/testsuite/ld-ctf/function.d @@ -9,7 +9,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Compilation unit name: .*function.c @@ -22,6 +22,6 @@ Contents of CTF section .ctf: #... Types: #... - [0-9a-f]*: int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\) \(size 0x0\) - \[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]*: int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\) \(size 0x0\) + *\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 5\) int \(\*\) \(char, int[0-9]*, float, void \*, void \(\*\)\(\*\) \(int\)\) \(aligned at 0x[0-9a-f]*\) #... diff --git a/ld/testsuite/ld-ctf/slice.d b/ld/testsuite/ld-ctf/slice.d index b493ce05c75..e42ffdf4b65 100644 --- a/ld/testsuite/ld-ctf/slice.d +++ b/ld/testsuite/ld-ctf/slice.d @@ -9,7 +9,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Compilation unit name: .*slice.c @@ -23,10 +23,10 @@ Contents of CTF section .ctf: #... Types: #... - [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]*: 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\) #... diff --git a/ld/testsuite/ld-ctf/super-sub-cycles.d b/ld/testsuite/ld-ctf/super-sub-cycles.d index e4707d331e6..65a43a4de9c 100644 --- a/ld/testsuite/ld-ctf/super-sub-cycles.d +++ b/ld/testsuite/ld-ctf/super-sub-cycles.d @@ -9,7 +9,7 @@ Contents of CTF section .ctf: Header: - Magic number: dff2 + Magic number: 0xdff2 Version: 4 \(CTF_VERSION_3\) #... Compilation unit name: .*super-sub-cycles.c @@ -18,18 +18,18 @@ Contents of CTF section .ctf: #... Types: #... - [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]*: 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 \(.* #... diff --git a/libctf/ChangeLog b/libctf/ChangeLog index cc8e34a3a22..99f9022ecf0 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,15 @@ +2021-01-05 Nick Alcock + + * ctf-dump.c (ctf_dump_format_type): Add 0x to hex type IDs. + (ctf_dump_header): Add 0x to the hex magic number. + (ctf_dump_str): Add 0x to the hex string offsets. + (ctf_dump_membstate_t) : New. + (ctf_dump_type): Adjust. Free it when we're done. + (type_hex_digits): New. + (ctf_dump_member): Align output depending on the width of the type + ID being generated. Use printf padding, not a loop, to generate + indentation. + 2021-01-05 Nick Alcock * ctf-decl.c (ctf_decl_push): Don't print array decls backwards. diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index 621ff25b983..ee22f77f832 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -47,6 +47,7 @@ typedef struct ctf_dump_membstate { char **cdm_str; ctf_dict_t *cdm_fp; + char *cdm_toplevel_indent; } ctf_dump_membstate_t; static int @@ -115,7 +116,7 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag) goto err; } - if (asprintf (&bit, " %s%lx: ", nonroot_leader, id) < 0) + if (asprintf (&bit, " %s0x%lx: ", nonroot_leader, id) < 0) goto oom; str = str_append (str, bit); free (bit); @@ -236,7 +237,7 @@ ctf_dump_header (ctf_dict_t *fp, ctf_dump_state_t *state) }; const char *verstr = NULL; - if (asprintf (&str, "Magic number: %x\n", hp->cth_magic) < 0) + if (asprintf (&str, "Magic number: 0x%x\n", hp->cth_magic) < 0) goto err; ctf_dump_append (state, str); @@ -454,26 +455,51 @@ 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. */ static int ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset, - int depth, void *arg) + int depth, void *arg) { ctf_dump_membstate_t *state = arg; char *typestr = NULL; char *bit = NULL; ctf_encoding_t ep; int has_encoding = 0; - ssize_t i; - for (i = 0; i < depth; i++) - *state->cdm_str = str_append (*state->cdm_str, " "); + /* Align neatly. */ + + if (depth == 0) + { + if (asprintf (&state->cdm_toplevel_indent, " %*s", + type_hex_digits (id), "") < 0) + goto oom; + } + + if (asprintf (&bit, "%s%*s", state->cdm_toplevel_indent, depth * 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)", + if (asprintf (&bit, "[0x%lx] (type not represented in CTF)", offset) < 0) goto oom; @@ -491,7 +517,7 @@ ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset, 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 " + 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, @@ -501,7 +527,7 @@ ctf_dump_member (const char *name, ctf_id_t id, unsigned long offset, } else { - if (asprintf (&bit, " [0x%lx] (ID 0x%lx) (kind %i) %s%s%s " + 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, @@ -540,7 +566,7 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg) { char *str; ctf_dump_state_t *state = arg; - ctf_dump_membstate_t membstate = { &str, state->cds_fp }; + 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) @@ -558,6 +584,7 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg) _("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); @@ -568,6 +595,7 @@ ctf_dump_type (ctf_id_t id, int flag, void *arg) return 0; err: + free (membstate.cdm_toplevel_indent); free (str); return 0; /* Swallow the error. */ } @@ -583,7 +611,7 @@ ctf_dump_str (ctf_dict_t *fp, ctf_dump_state_t *state) fp->ctf_str[CTF_STRTAB_0].cts_len;) { char *str; - if (asprintf (&str, "%lx: %s", + if (asprintf (&str, "0x%lx: %s", (unsigned long) (s - fp->ctf_str[CTF_STRTAB_0].cts_strs), s) < 0) return (ctf_set_errno (fp, errno)); -- 2.30.2