forked from Imagelibrary/binutils-gdb
libctf: create, types: reftypes and pointers
This is pure adjustment for internal API changes, and a change to the type-compatibility of pointers to type 0 now that it can be void as well as "unrepresentable". By now this dance should be quite familiar.
This commit is contained in:
@@ -741,25 +741,26 @@ 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, uint32_t kind)
|
||||||
{
|
{
|
||||||
ctf_dtdef_t *dtd;
|
ctf_dtdef_t *dtd;
|
||||||
ctf_id_t type;
|
|
||||||
ctf_dict_t *typedict = fp;
|
ctf_dict_t *typedict = fp;
|
||||||
ctf_dict_t *refdict = fp;
|
ctf_dict_t *refdict = fp;
|
||||||
int child = fp->ctf_flags & LCTF_CHILD;
|
int child = fp->ctf_flags & LCTF_CHILD;
|
||||||
|
uint32_t type_idx;
|
||||||
|
uint32_t ref_idx;
|
||||||
|
|
||||||
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
|
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
|
||||||
return (ctf_set_typed_errno (fp, EINVAL));
|
return (ctf_set_typed_errno (fp, EINVAL));
|
||||||
|
|
||||||
if (ref != 0 && ctf_lookup_by_id (&refdict, ref) == NULL)
|
if (ref != 0 && ctf_lookup_by_id (&refdict, ref, NULL) == NULL)
|
||||||
return CTF_ERR; /* errno is set for us. */
|
return CTF_ERR; /* errno is set for us. */
|
||||||
|
|
||||||
if ((type = ctf_add_generic (fp, flag, NULL, kind, 0, &dtd)) == CTF_ERR)
|
if ((dtd = ctf_add_generic (fp, flag, NULL, kind, 0, 0, 0, NULL)) == NULL)
|
||||||
return CTF_ERR; /* errno is set for us. */
|
return CTF_ERR; /* errno is set for us. */
|
||||||
|
|
||||||
dtd->dtd_data.ctt_info = CTF_TYPE_INFO (kind, flag, 0);
|
dtd->dtd_data->ctt_info = CTF_TYPE_INFO (kind, 0, 0);
|
||||||
dtd->dtd_data.ctt_type = (uint32_t) ref;
|
dtd->dtd_data->ctt_type = (uint32_t) ref;
|
||||||
|
|
||||||
if (kind != CTF_K_POINTER)
|
if (kind != CTF_K_POINTER)
|
||||||
return type;
|
return dtd->dtd_type;
|
||||||
|
|
||||||
/* If we are adding a pointer, update the ptrtab, pointing at this type from
|
/* If we are adding a pointer, update the ptrtab, pointing at this type from
|
||||||
the type it points to. Note that ctf_typemax is at this point one higher
|
the type it points to. Note that ctf_typemax is at this point one higher
|
||||||
@@ -767,15 +768,16 @@ ctf_add_reftype (ctf_dict_t *fp, uint32_t flag, ctf_id_t ref, uint32_t kind)
|
|||||||
addition of this type. The pptrtab is lazily-updated as needed, so is not
|
addition of this type. The pptrtab is lazily-updated as needed, so is not
|
||||||
touched here. */
|
touched here. */
|
||||||
|
|
||||||
typedict = ctf_get_dict (fp, type);
|
typedict = ctf_get_dict (fp, dtd->dtd_type);
|
||||||
uint32_t type_idx = ctf_type_to_index (typedict, type);
|
|
||||||
uint32_t ref_idx = ctf_type_to_index (refdict, ref);
|
type_idx = ctf_type_to_index (typedict, dtd->dtd_type);
|
||||||
|
ref_idx = ctf_type_to_index (refdict, ref);
|
||||||
|
|
||||||
if (ctf_type_ischild (fp, ref) == child
|
if (ctf_type_ischild (fp, ref) == child
|
||||||
&& ref_idx < fp->ctf_typemax)
|
&& ref_idx < fp->ctf_typemax)
|
||||||
fp->ctf_ptrtab[ref_idx] = type_idx;
|
fp->ctf_ptrtab[ref_idx] = type_idx;
|
||||||
|
|
||||||
return type;
|
return dtd->dtd_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctf_id_t
|
ctf_id_t
|
||||||
|
|||||||
@@ -1848,7 +1848,7 @@ ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type)
|
|||||||
ctf_id_t ntype;
|
ctf_id_t ntype;
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
|
|
||||||
if (ctf_lookup_by_id (&fp, type) == NULL)
|
if (ctf_lookup_by_id (&fp, type, NULL) == NULL)
|
||||||
return CTF_ERR; /* errno is set for us. */
|
return CTF_ERR; /* errno is set for us. */
|
||||||
|
|
||||||
idx = ctf_type_to_index (fp, type);
|
idx = ctf_type_to_index (fp, type);
|
||||||
@@ -1863,7 +1863,7 @@ ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type)
|
|||||||
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
|
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
|
||||||
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
|
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
|
||||||
|
|
||||||
if (ctf_lookup_by_id (&fp, type) == NULL)
|
if (ctf_lookup_by_id (&fp, type, NULL) == NULL)
|
||||||
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
|
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
|
||||||
|
|
||||||
idx = ctf_type_to_index (fp, type);
|
idx = ctf_type_to_index (fp, type);
|
||||||
@@ -2019,10 +2019,9 @@ ctf_type_compat (ctf_dict_t *lfp, ctf_id_t ltype,
|
|||||||
if (lkind < 0 || rkind < 0)
|
if (lkind < 0 || rkind < 0)
|
||||||
return -1; /* errno is set for us. */
|
return -1; /* errno is set for us. */
|
||||||
|
|
||||||
ltp = ctf_lookup_by_id (&lfp, ltype);
|
if (ctf_lookup_by_id (&lfp, ltype, <p) != NULL &&
|
||||||
rtp = ctf_lookup_by_id (&rfp, rtype);
|
ctf_lookup_by_id (&rfp, rtype, &rtp) != NULL
|
||||||
|
&& ltp != NULL && rtp != NULL)
|
||||||
if (ltp != NULL && rtp != NULL)
|
|
||||||
same_names = (strcmp (ctf_strptr (lfp, ltp->ctt_name),
|
same_names = (strcmp (ctf_strptr (lfp, ltp->ctt_name),
|
||||||
ctf_strptr (rfp, rtp->ctt_name)) == 0);
|
ctf_strptr (rfp, rtp->ctt_name)) == 0);
|
||||||
|
|
||||||
@@ -2043,8 +2042,17 @@ ctf_type_compat (ctf_dict_t *lfp, ctf_id_t ltype,
|
|||||||
&& ctf_type_encoding (rfp, rtype, &re) == 0
|
&& ctf_type_encoding (rfp, rtype, &re) == 0
|
||||||
&& memcmp (&le, &re, sizeof (ctf_encoding_t)) == 0);
|
&& memcmp (&le, &re, sizeof (ctf_encoding_t)) == 0);
|
||||||
case CTF_K_POINTER:
|
case CTF_K_POINTER:
|
||||||
return (ctf_type_compat (lfp, ctf_type_reference (lfp, ltype),
|
{
|
||||||
rfp, ctf_type_reference (rfp, rtype)));
|
ctf_id_t lref = ctf_type_reference (lfp, ltype);
|
||||||
|
ctf_id_t rref = ctf_type_reference (rfp, rtype);
|
||||||
|
|
||||||
|
/* void * is only compatible with itself. */
|
||||||
|
|
||||||
|
if (lref == 0 && rref == 0)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return (ctf_type_compat (lfp, lref, rfp, rref));
|
||||||
|
}
|
||||||
case CTF_K_ARRAY:
|
case CTF_K_ARRAY:
|
||||||
return (ctf_array_info (lfp, ltype, &la) == 0
|
return (ctf_array_info (lfp, ltype, &la) == 0
|
||||||
&& ctf_array_info (rfp, rtype, &ra) == 0
|
&& ctf_array_info (rfp, rtype, &ra) == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user