mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 15:15:42 +00:00
libctf, ld: more dumper improvements
Dump more details about the types found in data object and function info sections (the type ID and recursive info on the type itself, but not on its members). Before now, this was being dumped for entries in the variable section, but not for the closely-related function info and data object sections, which is inconsistent and makes finding the corresponding types in the type section unnecessarily hard. (This also gets rid of code in which bugs have already been found in favour of the same code everything else in the dumper uses to dump types.) While we're doing that, change the recursive type dumper in question to recursively dump info on arrays' element type, just as we do for all types that reference other types. (Arrays are not a kind of reference type in libctf, but perhaps we should change that in future and make ctf_type_reference return the element type.) ld/ChangeLog 2021-01-05 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/array.d: Adjust for dumper changes. * 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/function.d: Likewise. * testsuite/ld-ctf/slice.d: Likewise. libctf/ChangeLog 2021-01-05 Nick Alcock <nick.alcock@oracle.com> * ctf-dump.c (ctf_dump_objts): Dump by calling ctf_dump_format_type. (ctf_dump_format_type): Don't emit the size for function objects. Dump the element type of arrays like we dump the pointed-to type of pointers, etc.
This commit is contained in:
10
ld/ChangeLog
10
ld/ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
|
* testsuite/ld-ctf/array.d: Adjust for dumper changes.
|
||||||
|
* 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/function.d: Likewise.
|
||||||
|
* testsuite/ld-ctf/slice.d: Likewise.
|
||||||
|
|
||||||
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
* testsuite/ld-ctf/array.d: Adjust for dumper changes.
|
* testsuite/ld-ctf/array.d: Adjust for dumper changes.
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ Contents of CTF section .ctf:
|
|||||||
Labels:
|
Labels:
|
||||||
|
|
||||||
Data objects:
|
Data objects:
|
||||||
digits -> int \[10\]
|
digits -> 0x[0-9a-f]*: int \[10\] .*
|
||||||
digits_names -> char \*\[10\]
|
digits_names -> 0x[0-9a-f]*: char \*\[10\] .*
|
||||||
|
|
||||||
Function objects:
|
Function objects:
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ Contents of CTF section \.ctf:
|
|||||||
String section: .*
|
String section: .*
|
||||||
#...
|
#...
|
||||||
Data objects:
|
Data objects:
|
||||||
bar -> struct var_3
|
bar -> 0x[0-9a-f]*: struct var_3 \(size 0x[0-9a-f]*\)
|
||||||
var_1 -> foo_t
|
var_1 -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_666 -> foo_t \*
|
var_666 -> 0x[0-9a-f]*: foo_t \* \(size 0x[0-9a-f]*\) -> .*
|
||||||
|
|
||||||
Function objects:
|
Function objects:
|
||||||
func_[0-9]* -> void \*\(\*\) \(const char \*restrict, int \(\*\)\(\*\) \(const char \*\)\)
|
func_[0-9]* -> 0x[0-9a-f]*: void \*\(\*\) \(const char \*restrict, int \(\*\)\(\*\) \(const char \*\)\)
|
||||||
#...
|
#...
|
||||||
Types:
|
Types:
|
||||||
#...
|
#...
|
||||||
@@ -46,13 +46,13 @@ CTF archive member: .*/data-func-1\.c:
|
|||||||
Labels:
|
Labels:
|
||||||
|
|
||||||
Data objects:
|
Data objects:
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
var_[0-9]* -> foo_t
|
var_[0-9]* -> 0x[0-9a-f]*: foo_t \(size 0x[0-9a-f]*\) -> .*
|
||||||
#...
|
#...
|
||||||
Function objects:
|
Function objects:
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Contents of CTF section .ctf:
|
|||||||
Version: 4 \(CTF_VERSION_3\)
|
Version: 4 \(CTF_VERSION_3\)
|
||||||
#...
|
#...
|
||||||
Data objects:
|
Data objects:
|
||||||
a -> struct
|
a -> 0x[0-9a-f]*: struct \(size 0x[0-9a-f]*\)
|
||||||
#...
|
#...
|
||||||
Types:
|
Types:
|
||||||
#...
|
#...
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Contents of CTF section .ctf:
|
|||||||
Labels:
|
Labels:
|
||||||
|
|
||||||
Data objects:
|
Data objects:
|
||||||
a -> struct A
|
a -> 0x[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
|
||||||
#...
|
#...
|
||||||
Function objects:
|
Function objects:
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Contents of CTF section .ctf:
|
|||||||
Labels:
|
Labels:
|
||||||
|
|
||||||
Data objects:
|
Data objects:
|
||||||
a -> struct A
|
a -> 0x[0-9a-f]*: struct A \(size 0x[0-9a-f]*\)
|
||||||
#...
|
#...
|
||||||
Function objects:
|
Function objects:
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ Contents of CTF section .ctf:
|
|||||||
String section: .*
|
String section: .*
|
||||||
#...
|
#...
|
||||||
Function objects:
|
Function objects:
|
||||||
foo -> int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\)
|
foo -> 0x[0-9a-f]*: int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\)
|
||||||
#...
|
#...
|
||||||
Types:
|
Types:
|
||||||
#...
|
#...
|
||||||
0x[0-9a-f]*: int \(\*\) \(char, int, float, void \*, void \(\*\)\(\*\) \(int\)\) \(size 0x0\)
|
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]*\)
|
*\[0x0\] \(ID 0x[0-9a-f]*\) \(kind 5\) int \(\*\) \(char, int[0-9]*, float, void \*, void \(\*\)\(\*\) \(int\)\) \(aligned at 0x[0-9a-f]*\)
|
||||||
#...
|
#...
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Contents of CTF section .ctf:
|
|||||||
String section: .*
|
String section: .*
|
||||||
#...
|
#...
|
||||||
Data objects:
|
Data objects:
|
||||||
slices -> struct slices
|
slices -> 0x[0-9a-f]*: struct slices \(size 0x[0-9a-f]*\)
|
||||||
#...
|
#...
|
||||||
Types:
|
Types:
|
||||||
#...
|
#...
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
|
* ctf-dump.c (ctf_dump_objts): Dump by calling ctf_dump_format_type.
|
||||||
|
(ctf_dump_format_type): Don't emit the size for function objects.
|
||||||
|
Dump the element type of arrays like we dump the pointed-to type of
|
||||||
|
pointers, etc.
|
||||||
|
|
||||||
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
* ctf-dump.c (ctf_dump_format_type): Add 0x to hex type IDs.
|
* ctf-dump.c (ctf_dump_format_type): Add 0x to hex type IDs.
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ctf_encoding_t enc;
|
ctf_encoding_t enc;
|
||||||
|
ctf_arinfo_t ar;
|
||||||
|
int kind, unsliced_kind;
|
||||||
const char *nonroot_leader = "";
|
const char *nonroot_leader = "";
|
||||||
const char *nonroot_trailer = "";
|
const char *nonroot_trailer = "";
|
||||||
|
|
||||||
@@ -123,26 +125,25 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
|
|||||||
bit = NULL;
|
bit = NULL;
|
||||||
|
|
||||||
if (buf[0] != '\0')
|
if (buf[0] != '\0')
|
||||||
{
|
str = str_append (str, buf);
|
||||||
str = str_append (str, buf);
|
|
||||||
str = str_append (str, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
free (buf);
|
free (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
|
unsliced_kind = ctf_type_kind_unsliced (fp, id);
|
||||||
|
kind = ctf_type_kind (fp, id);
|
||||||
|
|
||||||
/* Slices get a different print representation. */
|
/* Slices get a different print representation. */
|
||||||
if (ctf_type_kind_unsliced (fp, id) == CTF_K_SLICE)
|
if (unsliced_kind == CTF_K_SLICE)
|
||||||
{
|
{
|
||||||
ctf_type_encoding (fp, id, &enc);
|
ctf_type_encoding (fp, id, &enc);
|
||||||
if (asprintf (&bit, "[slice 0x%x:0x%x] ",
|
if (asprintf (&bit, " [slice 0x%x:0x%x]",
|
||||||
enc.cte_offset, enc.cte_bits) < 0)
|
enc.cte_offset, enc.cte_bits) < 0)
|
||||||
goto oom;
|
goto oom;
|
||||||
}
|
}
|
||||||
else if (ctf_type_kind (fp, id) == CTF_K_INTEGER)
|
else if (kind == CTF_K_INTEGER)
|
||||||
{
|
{
|
||||||
ctf_type_encoding (fp, id, &enc);
|
ctf_type_encoding (fp, id, &enc);
|
||||||
if (asprintf (&bit, "[0x%x:0x%x] ",
|
if (asprintf (&bit, " [0x%x:0x%x]",
|
||||||
enc.cte_offset, enc.cte_bits) < 0)
|
enc.cte_offset, enc.cte_bits) < 0)
|
||||||
goto oom;
|
goto oom;
|
||||||
}
|
}
|
||||||
@@ -150,16 +151,27 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
|
|||||||
free (bit);
|
free (bit);
|
||||||
bit = NULL;
|
bit = NULL;
|
||||||
|
|
||||||
if (asprintf (&bit, "(size 0x%lx)%s",
|
if (kind != CTF_K_FUNCTION)
|
||||||
(unsigned long) ctf_type_size (fp, id),
|
if (asprintf (&bit, " (size 0x%lx)%s",
|
||||||
nonroot_trailer) < 0)
|
(unsigned long) ctf_type_size (fp, id),
|
||||||
goto oom;
|
nonroot_trailer) < 0)
|
||||||
|
goto oom;
|
||||||
|
|
||||||
str = str_append (str, bit);
|
str = str_append (str, bit);
|
||||||
free (bit);
|
free (bit);
|
||||||
bit = NULL;
|
bit = NULL;
|
||||||
|
|
||||||
new_id = ctf_type_reference (fp, id);
|
/* Keep going as long as this type references another. We consider arrays
|
||||||
|
to "reference" their element type. */
|
||||||
|
|
||||||
|
if (kind == CTF_K_ARRAY)
|
||||||
|
{
|
||||||
|
if (ctf_array_info (fp, id, &ar) < 0)
|
||||||
|
goto err;
|
||||||
|
new_id = ar.ctr_contents;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
new_id = ctf_type_reference (fp, id);
|
||||||
if (new_id != CTF_ERR)
|
if (new_id != CTF_ERR)
|
||||||
str = str_append (str, " ->");
|
str = str_append (str, " ->");
|
||||||
} while (new_id != CTF_ERR);
|
} while (new_id != CTF_ERR);
|
||||||
@@ -383,36 +395,26 @@ ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state, int functions)
|
|||||||
while ((id = ctf_symbol_next (fp, &i, &name, functions)) != CTF_ERR)
|
while ((id = ctf_symbol_next (fp, &i, &name, functions)) != CTF_ERR)
|
||||||
{
|
{
|
||||||
char *typestr = NULL;
|
char *typestr = NULL;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
/* Emit the name, if we know it. */
|
/* Emit the name, if we know it. No trailing space: ctf_dump_format_type
|
||||||
|
has a leading one. */
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
if (asprintf (&str, "%s -> ", name) < 0)
|
if (asprintf (&str, "%s ->", name) < 0)
|
||||||
goto oom;
|
goto oom;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
str = xstrdup ("");
|
str = xstrdup ("");
|
||||||
|
|
||||||
if ((typestr = ctf_type_aname (fp, id)) == NULL)
|
if ((typestr = ctf_dump_format_type (state->cds_fp, id,
|
||||||
|
CTF_ADD_ROOT)) == NULL)
|
||||||
{
|
{
|
||||||
if (id == 0 || ctf_errno (fp) == ECTF_NONREPRESENTABLE)
|
ctf_dump_append (state, str);
|
||||||
{
|
continue; /* Swallow the error. */
|
||||||
if (asprintf (&typestr, " (%s)", _("type not represented in CTF")) < 0)
|
|
||||||
goto oom;
|
|
||||||
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (asprintf (&typestr, _("error: %s"), ctf_errmsg (ctf_errno (fp))) < 0)
|
|
||||||
goto oom;
|
|
||||||
|
|
||||||
err = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
str = str_append (str, typestr);
|
str = str_append (str, typestr);
|
||||||
str = str_append (str, "\n");
|
free (typestr);
|
||||||
ctf_dump_append (state, str);
|
ctf_dump_append (state, str);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -420,12 +422,6 @@ ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state, int functions)
|
|||||||
ctf_set_errno (fp, ENOMEM);
|
ctf_set_errno (fp, ENOMEM);
|
||||||
ctf_next_destroy (i);
|
ctf_next_destroy (i);
|
||||||
return -1;
|
return -1;
|
||||||
out:
|
|
||||||
str = str_append (str, typestr);
|
|
||||||
free (typestr);
|
|
||||||
ctf_dump_append (state, str);
|
|
||||||
ctf_next_destroy (i);
|
|
||||||
return err; /* errno is set for us. */
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user