static void process_struct_members (struct ctf_context *cp, ctf_id_t tid,
struct type *type);
+static struct type *read_forward_type (struct ctf_context *cp, ctf_id_t tid);
+
static struct symbol *new_symbol (struct ctf_context *cp, struct type *type,
ctf_id_t tid);
return nullptr;
}
+/* Fetch the type for TID in CCP OF's tid_and_type hash, add the type to
+ * context CCP if hash is empty or TID does not have a saved type. */
+
+static struct type *
+fetch_tid_type (struct ctf_context *ccp, ctf_id_t tid)
+{
+ struct objfile *of = ccp->of;
+ struct type *typ;
+
+ typ = get_tid_type (of, tid);
+ if (typ == nullptr)
+ {
+ ctf_add_type_cb (tid, ccp);
+ typ = get_tid_type (of, tid);
+ }
+
+ return typ;
+}
+
/* Return the size of storage in bits for INTEGER, FLOAT, or ENUM. */
static int
FIELD_NAME (*fp) = name;
kind = ctf_type_kind (ccp->fp, tid);
- t = get_tid_type (ccp->of, tid);
+ t = fetch_tid_type (ccp, tid);
if (t == nullptr)
{
t = read_type_record (ccp, tid);
type->set_code (TYPE_CODE_FUNC);
ctf_func_type_info (fp, tid, &cfi);
- rettype = get_tid_type (of, cfi.ctc_return);
+ rettype = fetch_tid_type (ccp, cfi.ctc_return);
TYPE_TARGET_TYPE (type) = rettype;
set_type_align (type, ctf_type_align (fp, tid));
return nullptr;
}
- element_type = get_tid_type (objfile, ar.ctr_contents);
+ element_type = fetch_tid_type (ccp, ar.ctr_contents);
if (element_type == nullptr)
return nullptr;
- idx_type = get_tid_type (objfile, ar.ctr_index);
+ idx_type = fetch_tid_type (ccp, ar.ctr_index);
if (idx_type == nullptr)
idx_type = objfile_type (objfile)->builtin_int;
struct objfile *objfile = ccp->of;
struct type *base_type, *cv_type;
- base_type = get_tid_type (objfile, btid);
+ base_type = fetch_tid_type (ccp, btid);
if (base_type == nullptr)
{
base_type = read_type_record (ccp, btid);
ctf_dict_t *fp = ccp->fp;
struct type *base_type, *cv_type;
- base_type = get_tid_type (objfile, btid);
+ base_type = fetch_tid_type (ccp, btid);
if (base_type == nullptr)
{
base_type = read_type_record (ccp, btid);
struct objfile *objfile = ccp->of;
struct type *base_type, *cv_type;
- base_type = get_tid_type (objfile, btid);
+ base_type = fetch_tid_type (ccp, btid);
if (base_type == nullptr)
{
base_type = read_type_record (ccp, btid);
char *aname = obstack_strdup (&objfile->objfile_obstack, name);
this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, aname);
set_tid_type (objfile, tid, this_type);
- target_type = get_tid_type (objfile, btid);
+ target_type = fetch_tid_type (ccp, btid);
if (target_type != this_type)
TYPE_TARGET_TYPE (this_type) = target_type;
else
struct objfile *of = ccp->of;
struct type *target_type, *type;
- target_type = get_tid_type (of, btid);
+ target_type = fetch_tid_type (ccp, btid);
if (target_type == nullptr)
{
target_type = read_type_record (ccp, btid);
return set_tid_type (of, tid, type);
}
+/* Read information from a TID of CTF_K_FORWARD. */
+
+static struct type *
+read_forward_type (struct ctf_context *ccp, ctf_id_t tid)
+{
+ struct objfile *of = ccp->of;
+ ctf_dict_t *fp = ccp->fp;
+ struct type *type;
+ uint32_t kind;
+
+ type = alloc_type (of);
+
+ gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (fp, tid));
+ if (name != NULL && strlen (name.get()) != 0)
+ type->set_name (obstack_strdup (&of->objfile_obstack, name.get ()));
+
+ kind = ctf_type_kind_forwarded (fp, tid);
+ if (kind == CTF_K_UNION)
+ type->set_code (TYPE_CODE_UNION);
+ else
+ type->set_code (TYPE_CODE_STRUCT);
+
+ TYPE_LENGTH (type) = 0;
+ type->set_is_stub (true);
+
+ return set_tid_type (of, tid, type);
+}
+
/* Read information associated with type TID. */
static struct type *
case CTF_K_ARRAY:
type = read_array_type (ccp, tid);
break;
+ case CTF_K_FORWARD:
+ type = read_forward_type (ccp, tid);
+ break;
case CTF_K_UNKNOWN:
break;
default:
if ((tid = ctf_lookup_by_symbol (ccp->fp, idx)) == CTF_ERR)
return nullptr;
- type = get_tid_type (ccp->of, tid);
+ type = fetch_tid_type (ccp, tid);
if (type == nullptr)
return nullptr;
return nullptr;
tid = ctf_lookup_by_symbol (ccp->fp, idx);
- ftype = get_tid_type (ccp->of, tid);
+ ftype = fetch_tid_type (ccp, tid);
if ((finfo.ctc_flags & CTF_FUNC_VARARG) != 0)
ftype->set_has_varargs (true);
ftype->set_num_fields (argc);
to find the argument type. */
for (int iparam = 0; iparam < argc; iparam++)
{
- atyp = get_tid_type (ccp->of, argv[iparam]);
+ atyp = fetch_tid_type (ccp, argv[iparam]);
if (atyp)
ftype->field (iparam).set_type (atyp);
else
}
sym = new_symbol (ccp, ftype, tid);
- rettyp = get_tid_type (ccp->of, finfo.ctc_return);
+ rettyp = fetch_tid_type (ccp, finfo.ctc_return);
if (rettyp != nullptr)
SYMBOL_TYPE (sym) = rettyp;
else