{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
+ ctf_dtdef_t *dtd;
ssize_t size, increment;
uint32_t kind, n;
int rc;
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
return (ctf_set_errno (ofp, ECTF_NOTSOU));
- if (size < CTF_LSTRUCT_THRESH)
+ if ((dtd = ctf_dynamic_type (fp, type)) == NULL)
{
- const ctf_member_t *mp = (const ctf_member_t *) ((uintptr_t) tp +
- increment);
-
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, mp++)
+ if (size < CTF_LSTRUCT_THRESH)
{
- const char *name = ctf_strptr (fp, mp->ctm_name);
- if ((rc = func (name, mp->ctm_type, mp->ctm_offset, arg)) != 0)
+ const ctf_member_t *mp = (const ctf_member_t *) ((uintptr_t) tp +
+ increment);
+
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, mp++)
+ {
+ const char *name = ctf_strptr (fp, mp->ctm_name);
+ if ((rc = func (name, mp->ctm_type, mp->ctm_offset, arg)) != 0)
return rc;
+ }
}
+ else
+ {
+ const ctf_lmember_t *lmp = (const ctf_lmember_t *) ((uintptr_t) tp +
+ increment);
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, lmp++)
+ {
+ const char *name = ctf_strptr (fp, lmp->ctlm_name);
+ if ((rc = func (name, lmp->ctlm_type,
+ (unsigned long) CTF_LMEM_OFFSET (lmp), arg)) != 0)
+ return rc;
+ }
+ }
}
else
{
- const ctf_lmember_t *lmp = (const ctf_lmember_t *) ((uintptr_t) tp +
- increment);
+ ctf_dmdef_t *dmd;
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, lmp++)
+ for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next (dmd))
{
- const char *name = ctf_strptr (fp, lmp->ctlm_name);
- if ((rc = func (name, lmp->ctlm_type,
- (unsigned long) CTF_LMEM_OFFSET (lmp), arg)) != 0)
+ if ((rc = func (dmd->dmd_name, dmd->dmd_type,
+ dmd->dmd_offset, arg)) != 0)
return rc;
}
}
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const ctf_enum_t *ep;
+ ctf_dtdef_t *dtd;
ssize_t increment;
uint32_t n;
int rc;
(void) ctf_get_ctt_size (fp, tp, NULL, &increment);
- ep = (const ctf_enum_t *) ((uintptr_t) tp + increment);
+ if ((dtd = ctf_dynamic_type (ofp, type)) == NULL)
+ {
+ ep = (const ctf_enum_t *) ((uintptr_t) tp + increment);
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, ep++)
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, ep++)
+ {
+ const char *name = ctf_strptr (fp, ep->cte_name);
+ if ((rc = func (name, ep->cte_value, arg)) != 0)
+ return rc;
+ }
+ }
+ else
{
- const char *name = ctf_strptr (fp, ep->cte_name);
- if ((rc = func (name, ep->cte_value, arg)) != 0)
- return rc;
+ ctf_dmdef_t *dmd;
+
+ for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next (dmd))
+ {
+ if ((rc = func (dmd->dmd_name, dmd->dmd_value, arg)) != 0)
+ return rc;
+ }
}
return 0;
int
ctf_variable_iter (ctf_file_t *fp, ctf_variable_f *func, void *arg)
{
- unsigned long i;
int rc;
if ((fp->ctf_flags & LCTF_CHILD) && (fp->ctf_parent == NULL))
return ECTF_NOPARENT;
- for (i = 0; i < fp->ctf_nvars; i++)
- if ((rc = func (ctf_strptr (fp, fp->ctf_vars[i].ctv_name),
- fp->ctf_vars[i].ctv_type, arg)) != 0)
- return rc;
+ if (!(fp->ctf_flags & LCTF_RDWR))
+ {
+ unsigned long i;
+ for (i = 0; i < fp->ctf_nvars; i++)
+ if ((rc = func (ctf_strptr (fp, fp->ctf_vars[i].ctv_name),
+ fp->ctf_vars[i].ctv_type, arg)) != 0)
+ return rc;
+ }
+ else
+ {
+ ctf_dvdef_t *dvd;
+
+ for (dvd = ctf_list_next (&fp->ctf_dvdefs); dvd != NULL;
+ dvd = ctf_list_next (dvd))
+ {
+ if ((rc = func (dvd->dvd_name, dvd->dvd_type, arg)) != 0)
+ return rc;
+ }
+ }
return 0;
}
return type;
}
+/* 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_file_t *fp, int kind, const char *name)
+{
+ return ctf_lookup_by_rawhash (fp, ctf_name_table (fp, kind), name);
+}
+
+/* Look up a name in the given name table, in the appropriate hash given the
+ readability state of the dictionary. The name is a raw, undecorated
+ identifier. */
+
+ctf_id_t ctf_lookup_by_rawhash (ctf_file_t *fp, ctf_names_t *np, const char *name)
+{
+ ctf_id_t id;
+
+ if (fp->ctf_flags & LCTF_RDWR)
+ id = (ctf_id_t) ctf_dynhash_lookup (np->ctn_writable, name);
+ else
+ id = ctf_hash_lookup_type (np->ctn_readonly, fp, name);
+ return id;
+}
+
/* Lookup the given type ID and return its name as a new dynamcally-allocated
string. */
ctf_type_lname (ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
{
char *str = ctf_type_aname (fp, type);
- size_t slen = strlen (str);
+ size_t slen;
if (str == NULL)
- return CTF_ERR; /* errno is set for us */
+ return CTF_ERR; /* errno is set for us. */
+ slen = strlen (str);
snprintf (buf, len, "%s", str);
free (str);
if ((dtd = ctf_dynamic_type (ofp, type)) != NULL)
{
- *ep = dtd->dtd_u.dtu_enc;
+ switch (LCTF_INFO_KIND (fp, tp->ctt_info))
+ {
+ case CTF_K_INTEGER:
+ case CTF_K_FLOAT:
+ *ep = dtd->dtd_u.dtu_enc;
+ break;
+ case CTF_K_SLICE:
+ {
+ const ctf_slice_t *slice;
+ ctf_encoding_t underlying_en;
+ slice = &dtd->dtd_u.dtu_slice;
+
+ data = ctf_type_encoding (fp, slice->cts_type, &underlying_en);
+ ep->cte_format = underlying_en.cte_format;
+ ep->cte_offset = slice->cts_offset;
+ ep->cte_bits = slice->cts_bits;
+ break;
+ }
+ default:
+ return (ctf_set_errno (ofp, ECTF_NOTINTFP));
+ }
return 0;
}
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
+ ctf_dtdef_t *dtd;
ssize_t size, increment;
uint32_t kind, n;
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
return (ctf_set_errno (ofp, ECTF_NOTSOU));
- if (size < CTF_LSTRUCT_THRESH)
+ if ((dtd = ctf_dynamic_type (fp, type)) == NULL)
{
- const ctf_member_t *mp = (const ctf_member_t *) ((uintptr_t) tp +
- increment);
+ if (size < CTF_LSTRUCT_THRESH)
+ {
+ const ctf_member_t *mp = (const ctf_member_t *) ((uintptr_t) tp +
+ increment);
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, mp++)
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, mp++)
+ {
+ if (strcmp (ctf_strptr (fp, mp->ctm_name), name) == 0)
+ {
+ mip->ctm_type = mp->ctm_type;
+ mip->ctm_offset = mp->ctm_offset;
+ return 0;
+ }
+ }
+ }
+ else
{
- if (strcmp (ctf_strptr (fp, mp->ctm_name), name) == 0)
+ const ctf_lmember_t *lmp = (const ctf_lmember_t *) ((uintptr_t) tp +
+ increment);
+
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, lmp++)
{
- mip->ctm_type = mp->ctm_type;
- mip->ctm_offset = mp->ctm_offset;
- return 0;
+ if (strcmp (ctf_strptr (fp, lmp->ctlm_name), name) == 0)
+ {
+ mip->ctm_type = lmp->ctlm_type;
+ mip->ctm_offset = (unsigned long) CTF_LMEM_OFFSET (lmp);
+ return 0;
+ }
}
}
}
else
{
- const ctf_lmember_t *lmp = (const ctf_lmember_t *) ((uintptr_t) tp +
- increment);
+ ctf_dmdef_t *dmd;
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, lmp++)
+ for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next (dmd))
{
- if (strcmp (ctf_strptr (fp, lmp->ctlm_name), name) == 0)
+ if (strcmp (dmd->dmd_name, name) == 0)
{
- mip->ctm_type = lmp->ctlm_type;
- mip->ctm_offset = (unsigned long) CTF_LMEM_OFFSET (lmp);
+ mip->ctm_type = dmd->dmd_type;
+ mip->ctm_offset = dmd->dmd_offset;
return 0;
}
}
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const ctf_enum_t *ep;
+ const ctf_dtdef_t *dtd;
ssize_t increment;
uint32_t n;
(void) ctf_get_ctt_size (fp, tp, NULL, &increment);
- ep = (const ctf_enum_t *) ((uintptr_t) tp + increment);
+ if ((dtd = ctf_dynamic_type (ofp, type)) == NULL)
+ {
+ ep = (const ctf_enum_t *) ((uintptr_t) tp + increment);
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, ep++)
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, ep++)
+ {
+ if (ep->cte_value == value)
+ return (ctf_strptr (fp, ep->cte_name));
+ }
+ }
+ else
{
- if (ep->cte_value == value)
- return (ctf_strptr (fp, ep->cte_name));
+ ctf_dmdef_t *dmd;
+
+ for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next (dmd))
+ {
+ if (dmd->dmd_value == value)
+ return dmd->dmd_name;
+ }
}
(void) ctf_set_errno (ofp, ECTF_NOENUMNAM);
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const ctf_enum_t *ep;
+ const ctf_dtdef_t *dtd;
ssize_t increment;
uint32_t n;
ep = (const ctf_enum_t *) ((uintptr_t) tp + increment);
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, ep++)
+ if ((dtd = ctf_dynamic_type (ofp, type)) == NULL)
{
- if (strcmp (ctf_strptr (fp, ep->cte_name), name) == 0)
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, ep++)
{
- if (valp != NULL)
- *valp = ep->cte_value;
- return 0;
+ if (strcmp (ctf_strptr (fp, ep->cte_name), name) == 0)
+ {
+ if (valp != NULL)
+ *valp = ep->cte_value;
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ ctf_dmdef_t *dmd;
+
+ for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next (dmd))
+ {
+ if (strcmp (dmd->dmd_name, name) == 0)
+ {
+ if (valp != NULL)
+ *valp = dmd->dmd_value;
+ return 0;
+ }
}
}
const ctf_type_t *tp;
uint32_t kind;
const uint32_t *args;
+ const ctf_dtdef_t *dtd;
ssize_t size, increment;
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
return (ctf_set_errno (fp, ECTF_NOTFUNC));
fip->ctc_return = tp->ctt_type;
- fip->ctc_argc = LCTF_INFO_VLEN (fp, tp->ctt_info);
fip->ctc_flags = 0;
+ fip->ctc_argc = LCTF_INFO_VLEN (fp, tp->ctt_info);
- args = (uint32_t *) ((uintptr_t) tp + increment);
+ if ((dtd = ctf_dynamic_type (fp, type)) == NULL)
+ args = (uint32_t *) ((uintptr_t) tp + increment);
+ else
+ args = (uint32_t *) dtd->dtd_u.dtu_argv;
if (fip->ctc_argc != 0 && args[fip->ctc_argc - 1] == 0)
{
{
const ctf_type_t *tp;
const uint32_t *args;
+ const ctf_dtdef_t *dtd;
ssize_t size, increment;
ctf_funcinfo_t f;
(void) ctf_get_ctt_size (fp, tp, &size, &increment);
- args = (uint32_t *) ((uintptr_t) tp + increment);
+ if ((dtd = ctf_dynamic_type (fp, type)) == NULL)
+ args = (uint32_t *) ((uintptr_t) tp + increment);
+ else
+ args = (uint32_t *) dtd->dtd_u.dtu_argv;
for (argc = MIN (argc, f.ctc_argc); argc != 0; argc--)
*argv++ = *args++;
{
ctf_id_t otype = type;
const ctf_type_t *tp;
+ const ctf_dtdef_t *dtd;
ssize_t size, increment;
uint32_t kind, n;
int rc;
(void) ctf_get_ctt_size (fp, tp, &size, &increment);
- if (size < CTF_LSTRUCT_THRESH)
+ if ((dtd = ctf_dynamic_type (fp, type)) == NULL)
{
- const ctf_member_t *mp = (const ctf_member_t *) ((uintptr_t) tp +
- increment);
-
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, mp++)
+ if (size < CTF_LSTRUCT_THRESH)
{
- if ((rc = ctf_type_rvisit (fp, mp->ctm_type,
- func, arg, ctf_strptr (fp, mp->ctm_name),
- offset + mp->ctm_offset,
- depth + 1)) != 0)
- return rc;
+ const ctf_member_t *mp = (const ctf_member_t *) ((uintptr_t) tp +
+ increment);
+
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, mp++)
+ {
+ if ((rc = ctf_type_rvisit (fp, mp->ctm_type,
+ func, arg, ctf_strptr (fp,
+ mp->ctm_name),
+ offset + mp->ctm_offset,
+ depth + 1)) != 0)
+ return rc;
+ }
}
+ else
+ {
+ const ctf_lmember_t *lmp = (const ctf_lmember_t *) ((uintptr_t) tp +
+ increment);
+ for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, lmp++)
+ {
+ if ((rc = ctf_type_rvisit (fp, lmp->ctlm_type,
+ func, arg, ctf_strptr (fp,
+ lmp->ctlm_name),
+ offset + (unsigned long) CTF_LMEM_OFFSET (lmp),
+ depth + 1)) != 0)
+ return rc;
+ }
+ }
}
else
{
- const ctf_lmember_t *lmp = (const ctf_lmember_t *) ((uintptr_t) tp +
- increment);
+ ctf_dmdef_t *dmd;
- for (n = LCTF_INFO_VLEN (fp, tp->ctt_info); n != 0; n--, lmp++)
+ for (dmd = ctf_list_next (&dtd->dtd_u.dtu_members);
+ dmd != NULL; dmd = ctf_list_next (dmd))
{
- if ((rc = ctf_type_rvisit (fp, lmp->ctlm_type,
- func, arg, ctf_strptr (fp,
- lmp->ctlm_name),
- offset + (unsigned long) CTF_LMEM_OFFSET (lmp),
+ if ((rc = ctf_type_rvisit (fp, dmd->dmd_type, func, arg,
+ dmd->dmd_name, dmd->dmd_offset,
depth + 1)) != 0)
return rc;
}