aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-types.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-10-25 11:17:02 +0100
committerNick Alcock <nick.alcock@oracle.com>2021-10-25 11:17:05 +0100
commiteb5323fdf88aff59afca0a545877c4d777ff2726 (patch)
treebacc4ebe4f83df36805d5a30ec1f890be3e89295 /libctf/ctf-types.c
parenta0cc569d599f92c3a9168fcd23a0b18f7ff42f1d (diff)
downloadgdb-eb5323fdf88aff59afca0a545877c4d777ff2726.zip
gdb-eb5323fdf88aff59afca0a545877c4d777ff2726.tar.gz
gdb-eb5323fdf88aff59afca0a545877c4d777ff2726.tar.bz2
libctf, ld: handle nonrepresentable types better
ctf_type_visit (used, among other things, by the type dumping code) was aborting when it saw a nonrepresentable type anywhere: even a single structure member with a nonrepresentable type caused an abort with ECTF_NONREPRESENTABLE. This is not useful behaviour, given that the abort comes from a type-resolution we are only doing in order to determine whether the type is a structure or union. We know nonrepresentable types can't be either, so handle that case and pass the nonrepresentable type down. (The added test verifies that the dumper now handles this case and prints nonrepresentable structure members as it already does nonrepresentable top-level types, rather than skipping the whole structure -- or, without the previous commit, skipping the whole types section.) ld/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/nonrepresentable-member.*: New test. libctf/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * ctf-types.c (ctf_type_rvisit): Handle nonrepresentable types.
Diffstat (limited to 'libctf/ctf-types.c')
-rw-r--r--libctf/ctf-types.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index 243de93..5583485 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -1641,20 +1641,27 @@ ctf_type_rvisit (ctf_dict_t *fp, ctf_id_t type, ctf_visit_f *func,
unsigned char *vlen;
ssize_t size, increment, vbytes;
uint32_t kind, n, i = 0;
+ int nonrepresentable = 0;
int rc;
- if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
- return -1; /* errno is set for us. */
+ if ((type = ctf_type_resolve (fp, type)) == CTF_ERR) {
+ if (ctf_errno (fp) != ECTF_NONREPRESENTABLE)
+ return -1; /* errno is set for us. */
+ else
+ nonrepresentable = 1;
+ }
- if ((tp = ctf_lookup_by_id (&fp, type)) == NULL)
- return -1; /* errno is set for us. */
+ if (!nonrepresentable)
+ if ((tp = ctf_lookup_by_id (&fp, type)) == NULL)
+ return -1; /* errno is set for us. */
if ((rc = func (name, otype, offset, depth, arg)) != 0)
return rc;
- kind = LCTF_INFO_KIND (fp, tp->ctt_info);
+ if (!nonrepresentable)
+ kind = LCTF_INFO_KIND (fp, tp->ctt_info);
- if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
+ if (nonrepresentable || (kind != CTF_K_STRUCT && kind != CTF_K_UNION))
return 0;
ctf_get_ctt_size (fp, tp, &size, &increment);