_CTF_ITEM (ECTF_NODATASEC, "Variable not found in datasec.") \
_CTF_ITEM (ECTF_NOTDECLTAG, "This function requires a decl tag.") \
_CTF_ITEM (ECTF_NOTTAG, "This function requires a type or decl tag.") \
+ _CTF_ITEM (ECTF_TOOLARGE, "Prefix required for correct representation.")
#define ECTF_BASE 1000 /* Base value for libctf errnos. */
#undef _CTF_FIRST
};
-#define ECTF_NERR (ECTF_NOTSERIALIZED - ECTF_BASE + 1) /* Count of CTF errors. */
+#define ECTF_NERR (ECTF_TOOLARGE - ECTF_BASE + 1) /* Count of CTF errors. */
/* The CTF data model is inferred to be the caller's data model or the data
model of the given object, unless ctf_setmodel is explicitly called. */
extern char *ctf_type_name (ctf_dict_t *, ctf_id_t, char *, size_t);
+/* Retrieve raw (BTF or CTF-format) type data for the type with a given ID.
+ The vlen follows the record returned in the usual way for a type.
+
+ If PREFIX is 0, return only the data for the type itself: if the type is too
+ large to be accurately represented without a CTF_K_BIG prefix, this will
+ fail with ECTF_TOOLARGE. Otherwise, return the entire type, includiung
+ any prefixes. */
+
+extern const ctf_type_t *ctf_type_data (ctf_dict_t *, ctf_id_t, int prefix);
+
/* Return the size or alignment of a type. Types with no meaningful size, like
function types, return 0 as their size; incomplete types set ECTF_INCOMPLETE.
The type is resolved for you, so cvr-quals and typedefs can be passsed in. */
ctf_dynhash_lookup (ctf_name_table (fp, kind), name);
}
+/* Retrieve raw type data. */
+
+const ctf_type_t *
+ctf_type_data (ctf_dict_t *fp, ctf_id_t type, int prefix)
+{
+ const ctf_type_t *tp, *suffix, *big;
+
+ if (fp->ctf_flags & LCTF_NO_STR)
+ {
+ ctf_set_errno (fp, ECTF_NOPARENT);
+ return NULL;
+ }
+
+ if ((tp = ctf_lookup_by_id (&fp, type, &suffix)) == NULL)
+ return NULL; /* errno is set for us. */
+
+ if (!prefix && ((big = ctf_find_prefix (fp, tp, CTF_K_BIG)) != NULL)
+ && ((CTF_INFO_VLEN (big->ctt_info) != 0) || (big->ctt_size != 0)))
+ {
+ ctf_set_errno (fp, ECTF_TOOLARGE);
+ return NULL;
+ }
+
+ if (prefix)
+ return tp;
+ else
+ return suffix;
+}
+
/* Lookup the given type ID and return its name as a new dynamically-allocated
string. */