struct ctf_nextfield new_field;
struct field *fp;
struct type *t;
- uint32_t kind;
+ ctf_kind_t kind;
fp = &new_field.field;
fp->set_name (name);
if (type != nullptr)
sym->set_type (type);
- uint32_t kind = ctf_type_kind (dict, tid);
+ ctf_kind_t kind = ctf_type_kind (dict, tid);
switch (kind)
{
case CTF_K_STRUCT:
case CTF_K_ENUM:
sym->set_domain (STRUCT_DOMAIN);
break;
+ default:;
}
add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
ctf_encoding_t cet;
struct type *type = nullptr;
const char *name;
- uint32_t kind;
+ ctf_kind_t kind;
if (ctf_type_encoding (dict, tid, &cet))
{
struct objfile *of = ccp->of;
ctf_dict_t *dict = ccp->dict;
struct type *type;
- uint32_t kind;
+ ctf_kind_t kind;
type = type_allocator (of, language_c).new_type ();
struct objfile *of = ccp->of;
ctf_dict_t *dict = ccp->dict;
struct type *type;
- uint32_t kind;
+ ctf_kind_t kind;
type = type_allocator (of, language_c).new_type ();
read_type_record (struct ctf_context *ccp, ctf_id_t tid)
{
ctf_dict_t *dict = ccp->dict;
- uint32_t kind;
+ ctf_kind_t kind;
struct type *type = nullptr;
ctf_id_t btid;
ctf_add_type_cb (ctf_dict_t *fp, ctf_id_t tid, struct ctf_context *ccp)
{
struct type *type;
- uint32_t kind;
+ ctf_kind_t kind;
/* Check if tid's type has already been defined. */
type = get_tid_type (ccp->of, tid);
{
struct symbol *sym = nullptr;
struct type *type;
- uint32_t kind;
+ ctf_kind_t kind;
type = get_tid_type (ccp->of, id);
while ((tid = ctf_symbol_next (dict, &i, &tname, functions)) != CTF_ERR)
{
- uint32_t kind = ctf_type_kind (dict, tid);
+ ctf_kind_t kind = ctf_type_kind (dict, tid);
location_class loc_class;
domain_enum tdomain = functions ? FUNCTION_DOMAIN : VAR_DOMAIN;
static void
ctf_psymtab_type_cb (ctf_dict_t *fp, ctf_id_t tid, struct ctf_context *ccp)
{
- uint32_t kind;
+ ctf_kind_t kind;
int section = -1;
domain_enum domain = UNDEF_DOMAIN;
domain = TYPE_DOMAIN;
loc_class = LOC_TYPEDEF;
break;
- case CTF_K_UNKNOWN:
+ default:
return;
}
ctf_psymtab_var_cb (ctf_dict_t *fp, const char *name, ctf_id_t id,
struct ctf_context *ccp)
{
- uint32_t kind = ctf_type_kind (ccp->dict, id);
+ ctf_kind_t kind = ctf_type_kind (ccp->dict, id);
ccp->pst->add_psymbol (name, true,
kind == CTF_K_FUNCTION
CTF_K_TYPE_TAG and CTF_K_DECL_TAG, since they may be associated with many
types: use ctf_tag_next. */
-extern ctf_id_t ctf_lookup_by_kind (ctf_dict_t *, int kind, const char *);
+extern ctf_id_t ctf_lookup_by_kind (ctf_dict_t *, ctf_kind_t kind, const char *);
/* Type lookup functions. */
CTFv4 note: forwards to enums also return CTF_K_FORWARD, even though they
are encoded differently. */
-extern int ctf_type_kind (ctf_dict_t *, ctf_id_t);
+extern ctf_kind_t ctf_type_kind (ctf_dict_t *, ctf_id_t);
/* Return the kind of a type (CTF_K_* constant). Slices are considered to be
the kind they are a slice of; forwards are considered to be the kind they are
a forward of. */
-extern int ctf_type_kind_forwarded (ctf_dict_t *, ctf_id_t);
+extern ctf_kind_t ctf_type_kind_forwarded (ctf_dict_t *, ctf_id_t);
/* Return nonzero if this type is conflicting, zero if it's not, < 0 on error; if
CUNAME is set, set it to the name of the conflicting compilation unit for the
extern ctf_id_t ctf_type_next (ctf_dict_t *, ctf_next_t **,
int *flag, int want_hidden);
-extern ctf_id_t ctf_type_kind_next (ctf_dict_t *, ctf_next_t **, int kind);
+extern ctf_id_t ctf_type_kind_next (ctf_dict_t *, ctf_next_t **, ctf_kind_t kind);
extern ctf_id_t ctf_variable_next (ctf_dict_t *, ctf_next_t **,
const char **);
extern ctf_id_t ctf_datasec_var_next (ctf_dict_t *, ctf_id_t, ctf_next_t **,
extern ctf_id_t ctf_add_float (ctf_dict_t *, uint32_t,
const char *, const ctf_encoding_t *);
extern ctf_id_t ctf_add_forward (ctf_dict_t *, uint32_t, const char *,
- uint32_t);
+ ctf_kind_t);
extern ctf_id_t ctf_add_integer (ctf_dict_t *, uint32_t, const char *,
const ctf_encoding_t *);
/* Prohibit writeout of this type kind: attempts to write it out cause
an ECTF_KIND_PROHIBITED error. */
-extern ctf_ret_t ctf_write_suppress_kind (ctf_dict_t *fp, int kind,
+extern ctf_ret_t ctf_write_suppress_kind (ctf_dict_t *fp, ctf_kind_t kind,
int prohibited);
/* Linking. These functions are used by ld to link .ctf sections in input
CTF_INFO_VLEN() will extract the number of elements in the list, and
the type of each element is shown in the comments below. */
-#define CTF_V3_K_UNKNOWN 0 /* Unknown type (used for padding and
+typedef enum ctf_v3_kind
+ {
+ CTF_V3_K_UNKNOWN = 0, /* Unknown type (used for padding and
unrepresentable types). */
-#define CTF_V3_K_INTEGER 1 /* Variant data is CTF_INT_DATA (see below). */
-#define CTF_V3_K_FLOAT 2 /* Variant data is CTF_FP_DATA (see below). */
-#define CTF_V3_K_POINTER 3 /* ctt_type is referenced type. */
-#define CTF_V3_K_ARRAY 4 /* Variant data is single ctf_array_t. */
-#define CTF_V3_K_FUNCTION 5 /* ctt_type is return type, variant data is
+ CTF_V3_K_INTEGER = 1, /* Variant data is CTF_INT_DATA (see below). */
+ CTF_V3_K_FLOAT = 2, /* Variant data is CTF_FP_DATA (see below). */
+ CTF_V3_K_POINTER = 3, /* ctt_type is referenced type. */
+ CTF_V3_K_ARRAY = 4, /* Variant data is single ctf_array_t. */
+ CTF_V3_K_FUNCTION = 5, /* ctt_type is return type, variant data is
list of argument types (unsigned short's for v1,
uint32_t's for v2). */
-#define CTF_V3_K_STRUCT 6 /* Variant data is list of ctf_member_t's. */
-#define CTF_V3_K_UNION 7 /* Variant data is list of ctf_member_t's. */
-#define CTF_V3_K_ENUM 8 /* Variant data is list of ctf_enum_t's. */
-#define CTF_V3_K_FORWARD 9 /* No additional data; ctt_name is tag. */
-#define CTF_V3_K_TYPEDEF 10 /* ctt_type is referenced type. */
-#define CTF_V3_K_VOLATILE 11 /* ctt_type is base type. */
-#define CTF_V3_K_CONST 12 /* ctt_type is base type. */
-#define CTF_V3_K_RESTRICT 13 /* ctt_type is base type. */
-#define CTF_V3_K_SLICE 14 /* Variant data is a ctf_slice_t. */
-
-#define CTF_V3_K_MAX 14 /* Maximum possible (V3) CTF_K_* value. */
+ CTF_V3_K_STRUCT = 6, /* Variant data is list of ctf_member_t's. */
+ CTF_V3_K_UNION = 7, /* Variant data is list of ctf_member_t's. */
+ CTF_V3_K_ENUM = 8, /* Variant data is list of ctf_enum_t's. */
+ CTF_V3_K_FORWARD = 9, /* No additional data; ctt_name is tag. */
+ CTF_V3_K_TYPEDEF = 10, /* ctt_type is referenced type. */
+ CTF_V3_K_VOLATILE = 11, /* ctt_type is base type. */
+ CTF_V3_K_CONST = 12, /* ctt_type is base type. */
+ CTF_V3_K_RESTRICT = 13, /* ctt_type is base type. */
+ CTF_V3_K_SLICE = 14, /* Variant data is a ctf_slice_t. */
+
+ CTF_V3_K_MAX = 14 /* Maximum possible (V3) CTF_K_* value. */
+ } ctf_v3_kind_t;
/* Values for CTF_TYPE_KIND() for BTF, shared by CTFv4. Kind names as unchanged
as possible, since they are user-exposed, but their values all differ. */
-#define CTF_K_UNKNOWN 0 /* Unknown type (used for padding and
- unrepresentable and suppressed types). */
-#define CTF_K_INTEGER 1 /* Variant data is CTF_INT_DATA (see below). */
-#define CTF_K_POINTER 2 /* ctt_type is referenced type. */
-#define CTF_K_ARRAY 3 /* Variant data is single ctf_array_t. */
-#define CTF_K_STRUCT 4 /* Variant data is list of ctf_member_t's;
- kind_flag 1 if bitfields present. */
-#define CTF_K_UNION 5 /* Ditto. */
-#define CTF_K_ENUM 6 /* Variant data is list of ctf_enum_t's: if 0,
- this is a forward. kflag 1 is signed. */
-#define CTF_K_FORWARD 7 /* No additional data; kind_flag 1 for unions. */
-#define CTF_K_TYPEDEF 8 /* ctt_type is referenced type. */
-#define CTF_K_VOLATILE 9 /* ctt_type is base type. */
-#define CTF_K_CONST 10 /* ctt_type is base type. */
-#define CTF_K_RESTRICT 11 /* ctt_type is base type. */
-#define CTF_K_FUNC_LINKAGE 12 /* Literal vlen field is ctf_linkage_t.ctl.linkage;
- ctt_type is CTF_K_FUNCTION. Named. */
-#define CTF_K_FUNCTION 13 /* ctt_type is return type, variant data is
- list of ctf_param_t. Unnamed. */
-#define CTF_K_VAR 14 /* Variable. ctt_type is variable type.
- Variant data is ctf_linkage_t. */
-#define CTF_K_DATASEC 15 /* Variant data is list of ctf_var_secinfo_t. */
-#define CTF_K_BTF_FLOAT 16 /* No data beyond a size. */
-#define CTF_K_DECL_TAG 17 /* ctt_type is referenced type. Variant data is
- ctf_decl_tag_t. */
-#define CTF_K_TYPE_TAG 18 /* ctt_type is referenced type. */
-#define CTF_K_ENUM64 19 /* Variant data is list of ctf_enum64_t. kflag
- 1 is signed. */
+typedef enum ctf_kind
+ {
+ CTF_K_UNKNOWN = 0, /* Unknown type (used for padding and
+ unrepresentable and suppressed types). */
+ CTF_K_INTEGER = 1, /* Variant data is CTF_INT_DATA (see below). */
+ CTF_K_POINTER = 2, /* ctt_type is referenced type. */
+ CTF_K_ARRAY = 3, /* Variant data is single ctf_array_t. */
+ CTF_K_STRUCT = 4, /* Variant data is list of ctf_member_t's;
+ kind_flag 1 if bitfields present. */
+ CTF_K_UNION = 5, /* Ditto. */
+ CTF_K_ENUM = 6, /* Variant data is list of ctf_enum_t's: if 0,
+ this is a forward. kflag 1 is signed. */
+ CTF_K_FORWARD = 7, /* No additional data; kind_flag 1 for unions. */
+ CTF_K_TYPEDEF = 8, /* ctt_type is referenced type. */
+ CTF_K_VOLATILE = 9, /* ctt_type is base type. */
+ CTF_K_CONST = 10, /* ctt_type is base type. */
+ CTF_K_RESTRICT = 11, /* ctt_type is base type. */
+ CTF_K_FUNC_LINKAGE = 12, /* Literal vlen field is ctf_linkage_t.ctl.linkage;
+ ctt_type is CTF_K_FUNCTION. Named. */
+ CTF_K_FUNCTION = 13, /* ctt_type is return type, variant data is
+ list of ctf_param_t. Unnamed. */
+ CTF_K_VAR = 14, /* Variable. ctt_type is variable type.
+ Variant data is ctf_linkage_t. */
+ CTF_K_DATASEC = 15, /* Variant data is list of ctf_var_secinfo_t. */
+ CTF_K_BTF_FLOAT = 16,/* No data beyond a size. */
+ CTF_K_DECL_TAG = 17, /* ctt_type is referenced type. Variant data is
+ ctf_decl_tag_t. */
+ CTF_K_TYPE_TAG = 18, /* ctt_type is referenced type. */
+ CTF_K_ENUM64 = 19, /* Variant data is list of ctf_enum64_t. kflag
+ 1 is signed. */
/* Values for CTF_TYPE_KIND() for CTFv4. Count down from the top of the ID
space, */
-#define CTF_K_FLOAT 31 /* Variant data is a CTF_FP_* value. */
-#define CTF_K_SLICE 30 /* Variant data is a ctf_slice_t. */
-#define CTF_K_BIG 29 /* Prefix type.
- vlen is high 16 bits of type vlen;
- size is high 32 bits of type size. */
-#define CTF_K_CONFLICTING 28 /* Prefix type. Name is disambiguator for
+ CTF_K_FLOAT = 31, /* Variant data is a CTF_FP_* value. */
+ CTF_K_SLICE = 30, /* Variant data is a ctf_slice_t. */
+ CTF_K_BIG = 29, /* Prefix type.
+ vlen is high 16 bits of type vlen;
+ size is high 32 bits of type size. */
+ CTF_K_CONFLICTING = 28, /* Prefix type. Name is disambiguator for
conflicting type (e.g. translation unit
name).
If a type is both CONFLICTING and BIG,
CONFLICTING will always prefix BIG. */
-#define CTF_BTF_K_MAX 19 /* Maximum possible (V4) BTF_K_* value. */
-#define CTF_K_MAX 31 /* Maximum possible (V4) CTF_K_* value. */
-
+ CTF_BTF_K_MAX = 19, /* Maximum possible (V4) BTF_K_* value. */
+ CTF_K_MAX = 31 /* Maximum possible (V4) CTF_K_* value. */
+ } ctf_kind_t;
#define CTF_PREFIX_KIND(kind) ((kind) == CTF_K_BIG || (kind) == CTF_K_CONFLICTING)
}
ctf_dynhash_t *
-ctf_name_table (ctf_dict_t *fp, int kind)
+ctf_name_table (ctf_dict_t *fp, ctf_kind_t kind)
{
switch (kind)
{
int
ctf_insert_type_decl_tag (ctf_dict_t *fp, ctf_id_t type, const char *name,
- int kind)
+ ctf_kind_t kind)
{
ctf_dynset_t *types;
ctf_dynhash_t *h = ctf_name_table (fp, kind);
}
int
-ctf_dtd_insert (ctf_dict_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
+ctf_dtd_insert (ctf_dict_t *fp, ctf_dtdef_t *dtd, int flag, ctf_kind_t kind)
{
const char *name;
if (ctf_dynhash_insert (fp->ctf_dthash, (void *) (uintptr_t) dtd->dtd_type,
ctf_dtd_delete (ctf_dict_t *fp, ctf_dtdef_t *dtd)
{
const char *name = ctf_type_name_raw (fp, dtd->dtd_type);
- int name_kind = ctf_type_kind_forwarded (fp, dtd->dtd_type);
+ ctf_kind_t name_kind = ctf_type_kind_forwarded (fp, dtd->dtd_type);
/* Repeated calls should do nothing. */
if (name_kind < 0 && ctf_errno (fp) == ECTF_BADID)
or to the first prefix requested by PREFIXES, if nonzero. */
static ctf_dtdef_t *
-ctf_add_generic (ctf_dict_t *fp, uint32_t flag, const char *name, int kind,
- int prefixes, size_t vbytes, size_t vbytes_extra,
- ctf_type_t **typep)
+ctf_add_generic (ctf_dict_t *fp, uint32_t flag, const char *name,
+ ctf_kind_t kind, int prefixes, size_t vbytes,
+ size_t vbytes_extra, ctf_type_t **typep)
{
ctf_dtdef_t *dtd;
ctf_id_t type;
ctf_id_t
ctf_add_encoded (ctf_dict_t *fp, uint32_t flag,
- const char *name, const ctf_encoding_t *ep, uint32_t kind)
+ const char *name, const ctf_encoding_t *ep, ctf_kind_t kind)
{
ctf_dtdef_t *dtd;
uint32_t encoding;
}
ctf_id_t
-ctf_add_reftype (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref, uint32_t kind)
+ctf_add_reftype (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref, ctf_kind_t kind)
{
ctf_dtdef_t *dtd;
ctf_dict_t *typedict = fp;
ctf_dtdef_t *dtd;
ctf_slice_t slice;
ctf_id_t resolved_ref = ref;
- int kind;
+ ctf_kind_t kind;
ctf_dict_t *tmp = fp;
if (ep == NULL)
{
ctf_dtdef_t *dtd;
size_t vlen_size = 0;
- int kind = is_decl ? CTF_K_DECL_TAG : CTF_K_TYPE_TAG;
- int ref_kind = ctf_type_kind (fp, type);
+ ctf_kind_t kind = is_decl ? CTF_K_DECL_TAG : CTF_K_TYPE_TAG;
+ ctf_kind_t ref_kind = ctf_type_kind (fp, type);
if (component_idx < -1)
return (ctf_set_typed_errno (fp, ECTF_BADCOMPONENT));
static ctf_id_t
ctf_add_sou_sized (ctf_dict_t *fp, uint32_t flag, const char *name,
- size_t size, int kind)
+ size_t size, ctf_kind_t kind)
{
ctf_dtdef_t *dtd;
ctf_type_t *prefix;
static ctf_id_t
ctf_add_enum_internal (ctf_dict_t *fp, uint32_t flag, const char *name,
- int kind, int is_signed)
+ ctf_kind_t kind, int is_signed)
{
ctf_dtdef_t *dtd;
ctf_id_t type = 0;
static ctf_id_t
ctf_add_enum_encoded_internal (ctf_dict_t *fp, uint32_t flag, const char *name,
- int kind, const ctf_encoding_t *ep)
+ ctf_kind_t kind, const ctf_encoding_t *ep)
{
ctf_id_t type = 0;
int is_signed = ((ep->cte_format & CTF_INT_SIGNED) != 0);
ctf_id_t
ctf_add_forward (ctf_dict_t *fp, uint32_t flag, const char *name,
- uint32_t kind)
+ ctf_kind_t kind)
{
ctf_dtdef_t *dtd;
ctf_id_t type = 0;
ctf_dict_t *ofp = fp;
ctf_dtdef_t *dtd;
- uint32_t kind, vlen, root, en_name;
+ ctf_kind_t kind;
+ uint32_t vlen, root, en_name;
if (name == NULL)
return (ctf_set_errno (fp, EINVAL));
ctf_type_t *prefix;
ssize_t msize, ssize;
- uint32_t kind, kflag;
+ ctf_kind_t kind;
+ uint32_t kflag;
size_t vlen;
size_t i;
int is_incomplete = 0;
const ctf_encoding_t encoding)
{
ctf_dtdef_t *dtd = ctf_dtd_lookup (fp, type);
- int kind;
- int otype = type;
+ ctf_kind_t kind;
+ ctf_id_t otype = type;
if (dtd == NULL)
return (ctf_set_errno (fp, ECTF_BADID));
ctf_dtdef_t *sec_dtd = NULL;
ctf_dtdef_t *var_dtd = NULL;
- uint32_t kind, kflag;
+ ctf_kind_t kind;
+ uint32_t kflag;
size_t vlen;
ctf_linkage_t *l;
ctf_dict_t *proc_tracking_fp)
{
ctf_id_t dst_type = CTF_ERR;
- uint32_t dst_kind = CTF_K_UNKNOWN;
+ ctf_kind_t dst_kind = CTF_K_UNKNOWN;
ctf_dict_t *tmp_fp = dst_fp;
ctf_id_t tmp;
const char *name;
- uint32_t kind, forward_kind, flag, bitfields;
- uint32_t isroot;
+ ctf_kind_t kind, forward_kind;
+ uint32_t isroot, bitfields;
+ int flag;
size_t vlen;
const ctf_type_t *src_prefix, *src_tp, *dst_prefix;
same kind and (if a struct or union) has the same number of members,
hand it straight back. */
- if (ctf_type_kind_unsliced (tmp_fp, tmp) == (int) kind)
+ if (ctf_type_kind_unsliced (tmp_fp, tmp) == kind)
{
if (kind == CTF_K_STRUCT || kind == CTF_K_UNION
|| kind == CTF_K_ENUM)
{
ctf_decl_node_t *cdp;
ctf_decl_prec_t prec;
- uint32_t kind, n = 1;
+ ctf_kind_t kind;
+ uint32_t n = 1;
int is_qual = 0;
const ctf_type_t *tp, *suffix;
while allowing for the four C namespaces (normal, struct, union, enum).
Return a pointer into the cd_decorated_names atoms table. */
static const char *
-ctf_decorate_type_name (ctf_dict_t *fp, const char *name, int kind)
+ctf_decorate_type_name (ctf_dict_t *fp, const char *name, ctf_kind_t kind)
{
ctf_dedup_t *d = &fp->ctf_dedup;
const char *ret;
/* Determine whether this type is being hashed as a stub (in which case it is
unsafe to cache it). */
static int
-ctf_dedup_is_stub (const char *name, int kind, int fwdkind, int flags)
+ctf_dedup_is_stub (const char *name, ctf_kind_t kind, ctf_kind_t fwdkind, int flags)
{
/* We can cache all types unless we are recursing to children and are hashing
in a tagged struct, union or forward, all of which are replaced with their
ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs,
int input_num, ctf_id_t type, void *type_id,
const ctf_type_t *tp, const char *name,
- const char *decorated, int kind, int flags,
+ const char *decorated, ctf_kind_t kind, int flags,
unsigned long depth,
int (*populate_fun) (ctf_dict_t *fp,
ctf_dict_t *input,
const char *whaterr;
ctf_error_t err = 0;
int64_t component_idx = -1;
+ uint32_t ukind = (uint32_t) kind;
/* "citer" is for types that reference only one other type: "citers" can store
many of them, but is more expensive to both populate and traverse. */
case CTF_K_RESTRICT:
case CTF_K_SLICE:
name = NULL;
+ break;
+ default:;
+ /* No need to annul anything else. */
}
/* Mix in invariant stuff, transforming the type kind if needed. Note that
ctf_sha1_init (&hash);
if (name)
ctf_dedup_sha1_add (&hash, name, strlen (name) + 1, "name", depth);
- ctf_dedup_sha1_add (&hash, &kind, sizeof (uint32_t), "kind", depth);
+ /* Force the kind hash to rely on an arch-independent, explicitly-sized type. */
+ ctf_dedup_sha1_add (&hash, &ukind, sizeof (ukind), "kind", depth);
/* Hash content of this type. */
switch (kind)
break;
case CTF_K_FORWARD:
{
- int fwdkind = ctf_type_kind_forwarded_tp (input, tp);
+ uint32_t ufwdkind = ctf_type_kind_forwarded_tp (input, tp);
/* Add the forwarded kind. */
- ctf_dedup_sha1_add (&hash, &fwdkind, sizeof (fwdkind), "forwarded kind",
+ ctf_dedup_sha1_add (&hash, &ufwdkind, sizeof (ufwdkind), "forwarded kind",
depth);
break;
}
if (kind == CTF_K_DECL_TAG && component_idx > -1)
{
- int child_kind = ctf_type_kind (input, child_type);
+ ctf_kind_t child_kind = ctf_type_kind (input, child_type);
if (child_kind == CTF_K_STRUCT || child_kind == CTF_K_UNION)
{
const char *name;
const char *whaterr;
const char *decorated = NULL;
- uint32_t kind, fwdkind;
+ ctf_kind_t kind, fwdkind;
int isroot;
depth++;
ctf_dedup_t *d = &fp->ctf_dedup;
ctf_dynset_t *type_ids;
void *root_visible;
- int kind;
+ ctf_kind_t kind;
#ifdef ENABLE_LIBCTF_HASH_DEBUGGING
ctf_dprintf ("Hash %s, %s, into output mapping for %i/%lx @ %s\n",
ctf_error_t err;
const void *one_id;
ctf_next_t *i = NULL;
- int orig_kind = ctf_type_kind_unsliced (input, type);
+ ctf_kind_t orig_kind = ctf_type_kind_unsliced (input, type);
int orig_first_tu;
orig_first_tu = CTF_DEDUP_GID_TO_INPUT
/* Look up a type kind from the output mapping, given a type hash value.
Optionally return its GID as well. */
-static int
+static ctf_kind_t
ctf_dedup_hash_kind_gid (ctf_dict_t *fp, ctf_dict_t **inputs, const char *hash,
void **gid)
{
{
ctf_dedup_t *d = &fp->ctf_dedup;
const char *name;
- int kind;
+ ctf_kind_t kind;
void *id;
ctf_dict_t *input;
ctf_dedup_count_types (void *key_, void *value _libctf_unused_, void *arg_)
{
const char *hval = (const char *) key_;
- int kind;
+ ctf_kind_t kind;
ctf_dedup_type_counter_t *arg = (ctf_dedup_type_counter_t *) arg_;
kind = ctf_dedup_hash_kind_gid (arg->fp, arg->inputs, hval, NULL);
const char *hval = (const char *) hval_;
ctf_dynset_t *type_ids;
void *id;
- int kind;
+ ctf_kind_t kind;
/* Dig through the types in this hash to find the non-forwards
and mark them ambiguous. */
ctf_id_t input_id;
const char *name;
const char *decorated;
- int fwdkind;
+ ctf_kind_t fwdkind;
int multiple = 0;
ctf_error_t err;
static int
ctf_dedup_member_decl_tag (ctf_dict_t *fp, ctf_id_t type)
{
- int ref_kind = ctf_type_kind (fp, ctf_type_reference (fp, type));
+ ctf_kind_t ref_kind = ctf_type_kind (fp, ctf_type_reference (fp, type));
if (ref_kind == CTF_K_STRUCT || ref_kind == CTF_K_UNION)
{
{
ctf_dedup_t *od = &output->ctf_dedup;
ctf_dedup_t *td = &target->ctf_dedup;
- int kind;
- int fwdkind;
+ ctf_kind_t kind, fwdkind;
const char *name = ctf_type_name_raw (input, id);
const char *decorated;
void *v;
void *arg)
{
ctf_dedup_t *d = &output->ctf_dedup;
- int kind = ctf_type_kind_unsliced (input, type);
+ ctf_kind_t kind = ctf_type_kind_unsliced (input, type);
const char *name;
ctf_dict_t *target = output;
ctf_dict_t *real_input;
{
ctf_encoding_t ep;
ctf_arinfo_t ar;
- int kind, unsliced_kind;
+ ctf_kind_t kind, unsliced_kind;
ssize_t size, align;
const char *nonroot_leader = "";
const char *nonroot_trailer = "";
{
ctf_list_t cd_list; /* Linked list pointers. */
ctf_id_t cd_type; /* Type identifier. */
- uint32_t cd_kind; /* Type kind. */
+ ctf_kind_t cd_kind; /* Type kind. */
uint32_t cd_n; /* Type dimension if array. */
} ctf_decl_node_t;
#define LCTF_NO_TYPE 0x0010 /* No type additions possible. */
#define LCTF_PRESERIALIZED 0x0020 /* Already serialized all but the strtab. */
-extern ctf_dynhash_t *ctf_name_table (ctf_dict_t *, int);
+extern ctf_dynhash_t *ctf_name_table (ctf_dict_t *, ctf_kind_t);
extern const ctf_type_t *ctf_lookup_by_id (ctf_dict_t **, ctf_id_t,
const ctf_type_t **suffix);
extern const ctf_type_t *ctf_find_prefix (ctf_dict_t *, const ctf_type_t *,
- int kind);
+ ctf_kind_t kind);
extern ctf_id_t ctf_lookup_by_sym_or_name (ctf_dict_t *, unsigned long symidx,
const char *symname, int try_parent,
int is_function);
-extern ctf_id_t ctf_lookup_by_rawname (ctf_dict_t *, int, const char *);
+extern ctf_id_t ctf_lookup_by_rawname (ctf_dict_t *, ctf_kind_t, const char *);
extern ctf_id_t ctf_lookup_by_symbol (ctf_dict_t *, unsigned long);
extern ctf_id_t ctf_lookup_by_symbol_name (ctf_dict_t *, const char *);
extern void ctf_list_splice (ctf_list_t *, ctf_list_t *);
extern int ctf_list_empty_p (ctf_list_t *lp);
-extern int ctf_dtd_insert (ctf_dict_t *, ctf_dtdef_t *, int flag, int kind);
+extern int ctf_dtd_insert (ctf_dict_t *, ctf_dtdef_t *, int flag, ctf_kind_t kind);
extern void ctf_dtd_delete (ctf_dict_t *, ctf_dtdef_t *);
extern ctf_dtdef_t *ctf_dtd_lookup (const ctf_dict_t *, ctf_id_t);
extern ctf_dtdef_t *ctf_dynamic_type (const ctf_dict_t *, ctf_id_t);
extern ctf_id_t ctf_add_encoded (ctf_dict_t *, uint32_t, const char *,
- const ctf_encoding_t *, uint32_t kind);
+ const ctf_encoding_t *, ctf_kind_t kind);
extern ctf_id_t ctf_add_reftype (ctf_dict_t *, uint32_t, ctf_id_t,
- uint32_t kind);
+ ctf_kind_t kind);
extern ctf_ret_t ctf_add_funcobjt_sym_forced (ctf_dict_t *, int is_function,
const char *, ctf_id_t);
extern int ctf_insert_type_decl_tag (ctf_dict_t *, ctf_id_t, const char *,
- int kind);
+ ctf_kind_t kind);
extern ctf_ret_t ctf_track_enumerator (ctf_dict_t *, ctf_id_t, const char *);
extern int ctf_dedup_atoms_init (ctf_dict_t *);
extern ctf_id_t ctf_type_resolve_unsliced (ctf_dict_t *, ctf_id_t);
extern ctf_id_t ctf_type_resolve_nonrepresentable (ctf_dict_t *, ctf_id_t, int allow_zero);
-extern int ctf_type_kind_unsliced (ctf_dict_t *, ctf_id_t);
-extern int ctf_type_kind_unsliced_tp (ctf_dict_t *, const ctf_type_t *);
-extern int ctf_type_kind_tp (ctf_dict_t *, const ctf_type_t *);
-extern int ctf_type_kind_forwarded_tp (ctf_dict_t *, const ctf_type_t *);
+extern ctf_kind_t ctf_type_kind_unsliced (ctf_dict_t *, ctf_id_t);
+extern ctf_kind_t ctf_type_kind_unsliced_tp (ctf_dict_t *, const ctf_type_t *);
+extern ctf_kind_t ctf_type_kind_tp (ctf_dict_t *, const ctf_type_t *);
+extern ctf_kind_t ctf_type_kind_forwarded_tp (ctf_dict_t *, const ctf_type_t *);
extern ssize_t ctf_type_align_natural (ctf_dict_t *fp, ctf_id_t prev_type,
ctf_id_t type, ssize_t bit_offset);
extern ctf_var_secinfo_t *ctf_datasec_entry (ctf_dict_t *, ctf_id_t,
return (fp->ctf_dictops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
}
-static inline int
-ctf_forwardable_kind (int kind)
+static inline ctf_kind_t
+ctf_forwardable_kind (ctf_kind_t kind)
{
return (kind == CTF_K_STRUCT || kind == CTF_K_UNION || kind == CTF_K_ENUM);
}
/* Find a given prefix in some type, if any. */
const ctf_type_t *
-ctf_find_prefix (ctf_dict_t *fp, const ctf_type_t *tp, int kind)
+ctf_find_prefix (ctf_dict_t *fp, const ctf_type_t *tp, ctf_kind_t kind)
{
- uint32_t kind_ = kind;
+ ctf_kind_t kind_ = kind;
while (LCTF_IS_PREFIXED_INFO (tp->ctt_info)
&& CTF_INFO_KIND (tp->ctt_info) != kind_)
/* Look up some kind of thing in the name tables. */
ctf_id_t
-ctf_lookup_by_kind (ctf_dict_t *fp, int kind, const char *name)
+ctf_lookup_by_kind (ctf_dict_t *fp, ctf_kind_t kind, const char *name)
{
ctf_id_t type;
{
const ctf_type_t *tp;
ctf_dtdef_t *dtd;
- int kind;
+ ctf_kind_t kind;
unsigned char *vlen;
/* It's a shame we can't use ctf_type_kind_next here, but we're
-/* Opening CTF files: back-compatibility.
+kind/* Opening CTF files: back-compatibility.
(TODO: not yet implemented, not yet tied in to build system.)
Copyright (C) 2019-2025 Free Software Foundation, Inc.
for (tp = tbuf; tp < tend;
tp = (ctf_type_v1_t *) ((uintptr_t) tp + increment + vbytes))
{
- unsigned short kind = CTF_V1_INFO_KIND (tp->ctt_info);
+ ctf_kind_t kind = CTF_V1_INFO_KIND (tp->ctt_info);
unsigned long vlen = CTF_V1_INFO_VLEN (tp->ctt_info);
size = get_ctt_size_v1 (fp, (const ctf_type_t *) tp, NULL, &increment);
tp = (ctf_type_v1_t *) ((uintptr_t) tp + increment + vbytes),
t2p = (ctf_type_t *) ((uintptr_t) t2p + v2increment + v2bytes))
{
- unsigned short kind = CTF_V1_INFO_KIND (tp->ctt_info);
+ ctf_kind_t kind = CTF_V1_INFO_KIND (tp->ctt_info);
int isroot = CTF_V1_INFO_ISROOT (tp->ctt_info);
unsigned long vlen = CTF_V1_INFO_VLEN (tp->ctt_info);
ssize_t v2size;
while ((uintptr_t) t < ((uintptr_t) start) + len)
{
- uint32_t kind;
+ ctf_kind_t kind;
size_t size;
uint32_t vlen;
size_t vbytes;
}
static ssize_t
-get_vbytes_old (ctf_dict_t *fp, unsigned short kind, size_t vlen)
+get_vbytes_old (ctf_dict_t *fp, uint32_t kind, size_t vlen)
{
switch (kind)
{
static ssize_t
get_vbytes_v1 (ctf_dict_t *fp, const ctf_type_t *tp, ssize_t size)
{
- unsigned short kind = CTF_V1_INFO_KIND (tp->ctt_info);
+ uint32_t kind = CTF_V1_INFO_KIND (tp->ctt_info);
size_t vlen = CTF_V1_INFO_VLEN (tp->ctt_info);
switch (kind)
static ssize_t
get_vbytes_v2 (ctf_dict_t *fp, const ctf_type_t *tp, ssize_t size)
{
- unsigned short kind = CTF_V2_INFO_KIND (tp->ctt_info);
+ uint32_t kind = CTF_V2_INFO_KIND (tp->ctt_info);
size_t vlen = CTF_V2_INFO_VLEN (tp->ctt_info);
switch (kind)
get_vbytes_v4 (ctf_dict_t *fp, const ctf_type_t *tp,
ssize_t size _libctf_unused_)
{
- unsigned short kind = LCTF_KIND (fp, tp);
+ uint32_t kind = LCTF_KIND (fp, tp);
ssize_t vlen = LCTF_VLEN (fp, tp);
switch (kind)
for (tp = tbuf; tp < tend; typemax++)
{
- unsigned short kind = LCTF_INFO_UNPREFIXED_KIND (fp, tp->ctt_info);
+ ctf_kind_t kind = LCTF_INFO_UNPREFIXED_KIND (fp, tp->ctt_info);
size_t vlen = LCTF_VLEN (fp, tp);
int nonroot = 0;
ssize_t size, increment, vbytes;
for (id = 1, tp = tbuf; tp < tend; xp++, id++)
{
- unsigned short kind = LCTF_KIND (fp, tp);
+ ctf_kind_t kind = LCTF_KIND (fp, tp);
unsigned short isroot = LCTF_INFO_ISROOT (fp, tp->ctt_info);
size_t vlen = LCTF_VLEN (fp, tp);
ssize_t size, increment, vbytes;
while ((uintptr_t) t < ((uintptr_t) start) + len)
{
- uint32_t kind;
- uint32_t raw_kind;
+ ctf_kind_t kind;
+ ctf_kind_t raw_kind;
uint32_t vlen;
size_t vbytes;
ctf_type_t *tprefixed;
/* Kind suppression. */
ctf_ret_t
-ctf_write_suppress_kind (ctf_dict_t *fp, int kind, int prohibited)
+ctf_write_suppress_kind (ctf_dict_t *fp, ctf_kind_t kind, int prohibited)
{
ctf_dynset_t *set;
fp->ctf_write_suppressions = set;
}
- if ((ctf_dynset_cinsert (set, (const void *) (uintptr_t) kind)) < 0)
+ if ((ctf_dynset_cinsert (set, (const void *) (ctf_kind_t) kind)) < 0)
return (ctf_set_errno (fp, errno));
return 0;
ctf_prefix_elidable (ctf_dict_t *fp, uint32_t kind, ctf_dtdef_t *dtd,
ctf_type_t *prefix)
{
- int prefix_kind = LCTF_INFO_UNPREFIXED_KIND (fp, prefix->ctt_info);
+ ctf_kind_t prefix_kind = LCTF_INFO_UNPREFIXED_KIND (fp, prefix->ctt_info);
if ((prefix_kind == CTF_K_BIG) && prefix->ctt_size == 0
&& LCTF_INFO_UNPREFIXED_VLEN (fp, prefix->ctt_info) == 0)
while ((err = ctf_dynset_next (fp->ctf_write_prohibitions,
&prohibit_i, &pkind)) == 0)
{
- int kind = (uintptr_t) pkind;
+ ctf_kind_t kind = (ctf_kind_t) pkind;
if (ctf_type_kind_next (fp, &i, kind) != CTF_ERR)
{
dtd != NULL; dtd = ctf_list_next (dtd))
{
ctf_type_t *tp = dtd->dtd_buf;
- uint32_t kind = LCTF_KIND (fp, dtd->dtd_buf);
- uint32_t prefix_kind;
+ ctf_kind_t kind = LCTF_KIND (fp, dtd->dtd_buf);
+ ctf_kind_t prefix_kind;
/* Any un-suppressed prefixes other than an empty/redundant CTF_K_BIG must
be CTF. (Redundant CTF_K_BIGs will be elided instead.) */
if (!ctf_prefix_elidable (fp, kind, dtd, tp))
if (!fp->ctf_write_suppressions
|| ctf_dynset_lookup (fp->ctf_write_suppressions,
- (const void *) (uintptr_t) prefix_kind) == NULL)
+ (const void *) (ctf_kind_t) prefix_kind) == NULL)
return 0;
tp++;
if (fp->ctf_write_suppressions
&& ctf_dynset_lookup (fp->ctf_write_suppressions,
- (const void *) (uintptr_t) kind))
+ (const void *) (ctf_kind_t) kind))
continue;
if (kind == CTF_K_FLOAT || kind == CTF_K_SLICE)
for (dtd = ctf_list_next (&fp->ctf_dtdefs);
dtd != NULL; dtd = ctf_list_next (dtd))
{
- uint32_t kind = LCTF_KIND (fp, dtd->dtd_buf);
- uint32_t prefix_kind;
+ ctf_kind_t kind = LCTF_KIND (fp, dtd->dtd_buf);
+ ctf_kind_t prefix_kind;
ctf_type_t *tp = dtd->dtd_buf;
/* Check for suppressions: a suppression consumes precisely one ctf_type_t
{
if (!ctf_prefix_elidable (fp, kind, dtd, tp)
&& (ctf_dynset_lookup (fp->ctf_write_suppressions,
- (const void *) (uintptr_t) prefix_kind) != NULL))
+ (const void *) (ctf_kind_t) prefix_kind) != NULL))
{
type_size += sizeof (ctf_type_t);
suppress = 1;
for (dtd = ctf_list_next (&fp->ctf_dtdefs);
dtd != NULL; dtd = ctf_list_next (dtd), id++)
{
- uint32_t prefix_kind;
- uint32_t kind = LCTF_KIND (fp, dtd->dtd_buf);
+ ctf_kind_t prefix_kind;
+ ctf_kind_t kind = LCTF_KIND (fp, dtd->dtd_buf);
size_t vlen = LCTF_VLEN (fp, dtd->dtd_buf);
ctf_type_t *tp = dtd->dtd_buf;
ctf_type_t *copied;
if (!fp->ctf_write_suppressions
|| ctf_dynset_lookup (fp->ctf_write_suppressions,
- (const void *) (uintptr_t) prefix_kind) == NULL)
+ (const void *) (ctf_kind_t) prefix_kind) == NULL)
{
if (_libctf_btf_mode == LIBCTF_BTM_BTF)
{
if (fp->ctf_write_suppressions
&& ctf_dynset_lookup (fp->ctf_write_suppressions,
- (const void *) (uintptr_t) kind) != NULL)
+ (const void *) (ctf_kind_t) kind) != NULL)
suppress = 1;
if (suppress)
return -1; /* errno is set for us. */
break;
+ /* These kinds have no strings or type IDs in them, and so don't need
+ any special treatment. */
+ case CTF_K_INTEGER:
+ case CTF_K_FORWARD:
+ case CTF_K_FLOAT:
+ case CTF_K_BTF_FLOAT:
+ case CTF_K_UNKNOWN:
+ break;
+
+ /* These kinds are prefixes, and cannot appear here. */
+ case CTF_K_BIG:
+ case CTF_K_CONFLICTING:
+ ctf_err_warn (fp, 1, ECTF_INTERNAL, "type %lx: prefix type found during serialization",
+ id);
+ break;
+
case CTF_K_SLICE:
{
ctf_slice_t *slice = (ctf_slice_t *) t;
int *bit_width, int flags)
{
ctf_dict_t *ofp = fp;
- uint32_t kind;
+ ctf_kind_t kind;
ssize_t offset;
size_t nmemb;
unsigned char *vlen;
int64_t *val)
{
ctf_dict_t *ofp = fp;
- uint32_t kind;
+ ctf_kind_t kind;
const char *name;
ctf_next_t *i = *it;
ctf_error_t err;
of a single parent. */
ctf_id_t
-ctf_type_kind_next (ctf_dict_t *fp, ctf_next_t **it, int kind)
+ctf_type_kind_next (ctf_dict_t *fp, ctf_next_t **it, ctf_kind_t kind)
{
ctf_next_t *i = *it;
ctf_error_t err;
/* Look up a name in the given name table, in the appropriate hash given the
kind of the identifier. The name is a raw, undecorated identifier. */
-ctf_id_t ctf_lookup_by_rawname (ctf_dict_t *fp, int kind, const char *name)
+ctf_id_t ctf_lookup_by_rawname (ctf_dict_t *fp, ctf_kind_t kind, const char *name)
{
return (ctf_id_t) (uintptr_t)
ctf_dynhash_lookup (ctf_name_table (fp, kind), name);
ctf_decl_sprintf (&cd, _("(nonrepresentable type %s)"),
name);
break;
+ /* CTF_K_SLICE has no print representation: see ctf_decl_push(). */
+ case CTF_K_SLICE:
+ /* CTF_K_BIG and CTF_K_CONFLICTING cannot appear and have no print
+ representation. */
+ case CTF_K_BIG:
+ case CTF_K_CONFLICTING:
+ break;
}
k = cdp->cd_kind;
{
const ctf_type_t *tp;
ctf_dict_t *ofp = fp;
- int kind;
+ ctf_kind_t kind;
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
return -1; /* errno is set for us. */
Pretend that all forwards are of type CTF_K_FORWARD, for ease of
use and compatibility. */
-int
+ctf_kind_t
ctf_type_kind_unsliced_tp (ctf_dict_t *fp, const ctf_type_t *tp)
{
if (LCTF_KIND (fp, tp) == CTF_K_ENUM
/* Return the kind (CTF_K_* constant) for the specified type pointer.
Slices are considered to be of the same kind as the type sliced. */
-int
+ctf_kind_t
ctf_type_kind_tp (ctf_dict_t *fp, const ctf_type_t *tp)
{
- int kind;
+ ctf_kind_t kind;
if ((kind = ctf_type_kind_unsliced_tp (fp, tp)) < 0)
return -1; /* errno is set for us. */
/* Return the kind of this type pointer, except, for forwards, return the kind
of thing this is a forward to. */
-int
+ctf_kind_t
ctf_type_kind_forwarded_tp (ctf_dict_t *fp, const ctf_type_t *tp)
{
- int kind;
+ ctf_kind_t kind;
if ((kind = ctf_type_kind_tp (fp, tp)) < 0)
return -1; /* errno is set for us. */
Pretend that all forwards are of type CTF_K_FORWARD, for ease of
use and compatibility. */
-int
+ctf_kind_t
ctf_type_kind_unsliced (ctf_dict_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
/* Return the kind (CTF_K_* constant) for the specified type ID.
Slices are considered to be of the same kind as the type sliced. */
-int
+ctf_kind_t
ctf_type_kind (ctf_dict_t *fp, ctf_id_t type)
{
- int kind;
+ ctf_kind_t kind;
if ((kind = ctf_type_kind_unsliced (fp, type)) < 0)
return -1;
/* Return the kind of this type, except, for forwards, return the kind of thing
this is a forward to. */
-int
+ctf_kind_t
ctf_type_kind_forwarded (ctf_dict_t *fp, ctf_id_t type)
{
- int ret;
+ ctf_kind_t ret;
ctf_dict_t *ofp = fp;
const ctf_type_t *tp, *suffix;
ctf_id_t
ctf_tag (ctf_dict_t *fp, ctf_id_t tag)
{
- int kind = ctf_type_kind (fp, tag);
+ ctf_kind_t kind = ctf_type_kind (fp, tag);
int64_t component_idx;
ctf_id_t ref;
const ctf_type_t *ltp, *rtp;
ctf_encoding_t le, re;
ctf_arinfo_t la, ra;
- int lkind, rkind;
+ ctf_kind_t lkind, rkind;
int same_names = 0;
if (lfp->ctf_flags & LCTF_NO_STR)
{
ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
- uint32_t kind;
+ ctf_kind_t kind;
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
return -1; /* errno is set for us. */
int big = 0;
size_t total_offset = 0;
unsigned char *vlen;
- uint32_t kind, i = 0;
+ ctf_kind_t kind;
+ uint32_t i = 0;
size_t n;
if (fp->ctf_flags & LCTF_NO_STR)
ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
unsigned char *vlen;
- int kind;
+ ctf_kind_t kind;
size_t n;
if (fp->ctf_flags & LCTF_NO_STR)
ctf_dict_t *ofp = fp;
const ctf_type_t *tp;
unsigned char *vlen;
- int kind;
+ ctf_kind_t kind;
size_t n;
if (fp->ctf_flags & LCTF_NO_STR)
ctf_bool_t
ctf_enum_unsigned (ctf_dict_t *fp, ctf_id_t type)
{
- int kind;
+ ctf_kind_t kind;
const ctf_type_t *tp; /* The suffixed kind, if prefixed */
if ((kind = ctf_type_kind (fp, type)) < 0)
ctf_bool_t
ctf_struct_bitfield (ctf_dict_t * fp, ctf_id_t type)
{
- int kind;
+ ctf_kind_t kind;
const ctf_type_t *tp; /* The suffixed kind, if prefixed */
if ((kind = ctf_type_kind (fp, type)) < 0)
{
ctf_dict_t *ofp = fp;
const ctf_type_t *tp, *suffix;
- uint32_t kind;
+ ctf_kind_t kind;
unsigned char *vlen;
const ctf_param_t *args;
const ctf_type_t *suffix;
unsigned char *vlen;
ctf_linkage_t *l;
-
- int kind;
+ ctf_kind_t kind;
if ((tp = ctf_lookup_by_id (&fp, type, &suffix)) == NULL)
return -1; /* errno is set for us. */
{
ctf_id_t otype = type;
int nonrepresentable = 0;
- uint32_t kind;
+ ctf_kind_t kind;
ctf_next_t *it = NULL;
ctf_id_t membtype;
ssize_t this_offset;