aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-create.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-02 20:43:03 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:31 +0100
commit502e838ed9657ee74cdb4f53798e1468004c9524 (patch)
tree6571863adaa1fe7e0b450b7b104ced7a7391abe6 /libctf/ctf-create.c
parentdd987f004301f6a737fcd431a9ae14d2fc2675bf (diff)
downloadgdb-502e838ed9657ee74cdb4f53798e1468004c9524.zip
gdb-502e838ed9657ee74cdb4f53798e1468004c9524.tar.gz
gdb-502e838ed9657ee74cdb4f53798e1468004c9524.tar.bz2
libctf, types: support slices of anything terminating in an int
It is perfectly valid C to say e.g. typedef u64 int; struct foo_t { const volatile u64 wibble:2; }; i.e. bitfields have to be integral types, but they can be cv-qualified integral types or typedefs of same, etc. This is easy to fix: do a ctf_type_resolve_unsliced() at creation time to ensure the ultimate type is integral, and ctf_type_resolve() at lookup time so that if you somehow have e.g. a slice of a typedef of a slice of a cv-qualified int, we pull the encoding that the topmost slice is based on out of the subsidiary slice (and then modify it), not out of the underlying int. (This last bit is rather academic right now, since all slices override exactly the same properties of the underlying type, but it's still the right thing to do.) libctf/ * ctf-create.c (ctf_add_slice): Support slices of any kind that resolves to an integral type. * ctf-types.c (ctf_type_encoding): Resolve the type before fishing its encoding out.
Diffstat (limited to 'libctf/ctf-create.c')
-rw-r--r--libctf/ctf-create.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index 1416d18..c13b83d 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -944,6 +944,7 @@ ctf_add_slice (ctf_file_t *fp, uint32_t flag, ctf_id_t ref,
const ctf_encoding_t *ep)
{
ctf_dtdef_t *dtd;
+ ctf_id_t resolved_ref = ref;
ctf_id_t type;
int kind;
const ctf_type_t *tp;
@@ -961,7 +962,13 @@ ctf_add_slice (ctf_file_t *fp, uint32_t flag, ctf_id_t ref,
if (ref != 0 && ((tp = ctf_lookup_by_id (&tmp, ref)) == NULL))
return CTF_ERR; /* errno is set for us. */
- kind = ctf_type_kind_unsliced (tmp, ref);
+ /* Make sure we ultimately point to an integral type. We also allow slices to
+ point to the unimplemented type, for now, because the compiler can emit
+ such slices, though they're not very much use. */
+
+ resolved_ref = ctf_type_resolve_unsliced (tmp, ref);
+ kind = ctf_type_kind_unsliced (tmp, resolved_ref);
+
if ((kind != CTF_K_INTEGER) && (kind != CTF_K_FLOAT) &&
(kind != CTF_K_ENUM)
&& (ref != 0))