}
}
-/* Find a pointer to type by looking in fp->ctf_ptrtab. If we can't find a
- pointer to the given type, see if we can compute a pointer to the type
- resulting from resolving the type down to its base type and use that
+/* Find a pointer to type by looking in fp->ctf_ptrtab and fp->ctf_pptrtab. If
+ we can't find a pointer to the given type, see if we can compute a pointer to
+ the type resulting from resolving the type down to its base type and use that
instead. This helps with cases where the CTF data includes "struct foo *"
- but not "foo_t *" and the user accesses "foo_t *" in the debugger.
-
- XXX what about parent dicts? */
+ but not "foo_t *" and the user accesses "foo_t *" in the debugger. */
ctf_id_t
ctf_type_pointer (ctf_dict_t *fp, ctf_id_t type)
{
ctf_dict_t *ofp = fp;
ctf_id_t ntype;
+ uint32_t idx;
if (ctf_lookup_by_id (&fp, type) == NULL)
return CTF_ERR; /* errno is set for us. */
- if ((ntype = fp->ctf_ptrtab[ctf_type_to_index (fp, type)]) != 0)
+ idx = ctf_type_to_index (fp, type);
+ if ((ntype = fp->ctf_ptrtab[idx]) != 0)
+ return (ctf_index_to_type (fp, ntype));
+
+ if (idx < ofp->ctf_pptrtab_len
+ && (ntype = ofp->ctf_pptrtab[idx]) != 0)
return (ctf_index_to_type (fp, ntype));
+ /* Try again after resolution. */
if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
if (ctf_lookup_by_id (&fp, type) == NULL)
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));
- if ((ntype = fp->ctf_ptrtab[ctf_type_to_index (fp, type)]) != 0)
+ idx = ctf_type_to_index (fp, type);
+ if ((ntype = fp->ctf_ptrtab[idx]) != 0)
+ return (ctf_index_to_type (fp, ntype));
+
+ if (idx < ofp->ctf_pptrtab_len
+ && (ntype = ofp->ctf_pptrtab[idx]) != 0)
return (ctf_index_to_type (fp, ntype));
return (ctf_set_typed_errno (ofp, ECTF_NOTYPE));