/* Type handling functions.
- Copyright (C) 2019-2021 Free Software Foundation, Inc.
+ Copyright (C) 2019-2022 Free Software Foundation, Inc.
This file is part of libctf.
prev = type;
type = tp->ctt_type;
break;
+ case CTF_K_UNKNOWN:
+ return (ctf_set_errno (ofp, ECTF_NONREPRESENTABLE));
default:
return type;
}
case CTF_K_RESTRICT:
ctf_decl_sprintf (&cd, "restrict");
break;
+ case CTF_K_UNKNOWN:
+ if (name[0] == '\0')
+ ctf_decl_sprintf (&cd, _("(nonrepresentable type)"));
+ else
+ ctf_decl_sprintf (&cd, _("(nonrepresentable type %s)"),
+ name);
+ break;
}
k = cdp->cd_kind;
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)
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;
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);