aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ChangeLog6
-rw-r--r--libctf/ctf-dump.c5
-rw-r--r--libctf/ctf-types.c8
3 files changed, 17 insertions, 2 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 2d80e78..d19327e 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,11 @@
2021-03-18 Nick Alcock <nick.alcock@oracle.com>
+ * ctf-types.c (ctf_type_encoding): Support, after a fashion, for enums.
+ * ctf-dump.c (ctf_dump_format_type): Do not report enums' degenerate
+ encoding.
+
+2021-03-18 Nick Alcock <nick.alcock@oracle.com>
+
* ctf-dedup.c (ctf_dedup_rhash_type): Report errors on the input
dict properly.
* ctf-open.c (ctf_bufopen_internal): Report errors initializing
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 409626a..8540212 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -142,7 +142,10 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
unsliced_kind = ctf_type_kind_unsliced (fp, id);
kind = ctf_type_kind (fp, id);
- if (ctf_type_encoding (fp, id, &ep) == 0)
+ /* Report encodings of everything with an encoding other than enums:
+ base-type enums cannot have a nonzero cte_offset or cte_bits value.
+ (Slices of them can, but they are of kind CTF_K_SLICE.) */
+ if (unsliced_kind != CTF_K_ENUM && ctf_type_encoding (fp, id, &ep) == 0)
{
if ((ssize_t) ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
&& flag & CTF_FT_BITFIELD)
diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index ed76eca..9afe06b 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -1157,7 +1157,7 @@ ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type)
return (ctf_set_errno (ofp, ECTF_NOTYPE));
}
-/* Return the encoding for the specified INTEGER or FLOAT. */
+/* Return the encoding for the specified INTEGER, FLOAT, or ENUM. */
int
ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep)
@@ -1194,6 +1194,12 @@ ctf_type_encoding (ctf_dict_t *fp, ctf_id_t type, ctf_encoding_t *ep)
ep->cte_offset = CTF_FP_OFFSET (data);
ep->cte_bits = CTF_FP_BITS (data);
break;
+ case CTF_K_ENUM:
+ /* v3 only: we must guess at the underlying integral format. */
+ ep->cte_format = CTF_INT_SIGNED;
+ ep->cte_offset = 0;
+ ep->cte_bits = 0;
+ break;
case CTF_K_SLICE:
{
const ctf_slice_t *slice;