type = alloc_type (of);
type->set_code (TYPE_CODE_FUNC);
- ctf_func_type_info (fp, tid, &cfi);
+ if (ctf_func_type_info (fp, tid, &cfi) < 0)
+ {
+ const char *fname = ctf_type_name_raw (fp, tid);
+ error (_("Error getting function type info: %s"),
+ fname == nullptr ? "noname" : fname);
+ }
rettype = fetch_tid_type (ccp, cfi.ctc_return);
TYPE_TARGET_TYPE (type) = rettype;
set_type_align (type, ctf_type_align (fp, tid));
{
struct objfile *of = ccp->of;
ctf_dict_t *fp = ccp->fp;
- struct type *type, *target_type;
- ctf_funcinfo_t fi;
+ struct type *type;
type = alloc_type (of);
type->set_code (TYPE_CODE_ENUM);
TYPE_LENGTH (type) = ctf_type_size (fp, tid);
- ctf_func_type_info (fp, tid, &fi);
- target_type = get_tid_type (of, fi.ctc_return);
- TYPE_TARGET_TYPE (type) = target_type;
+ /* Set the underlying type based on its ctf_type_size bits. */
+ TYPE_TARGET_TYPE (type) = objfile_int_type (of, TYPE_LENGTH (type), false);
set_type_align (type, ctf_type_align (fp, tid));
return set_tid_type (of, tid, type);
dwarf2_cu::addr_sized_int_type (bool unsigned_p) const
{
int addr_size = this->per_cu->addr_size ();
- return this->per_objfile->int_type (addr_size, unsigned_p);
+ return objfile_int_type (this->per_objfile->objfile, addr_size, unsigned_p);
}
/* Start a symtab for DWARF. NAME, COMP_DIR, LOW_PC are passed to the
/* Pass 0 as the default as we know this attribute is constant
and the default value will not be returned. */
LONGEST sz = len->constant_value (0);
- prop_type = cu->per_objfile->int_type (sz, true);
+ prop_type = objfile_int_type (objfile, sz, true);
}
else
{
/* See read.h. */
-struct type *
-dwarf2_per_objfile::int_type (int size_in_bytes, bool unsigned_p) const
-{
- struct type *int_type;
-
- /* Helper macro to examine the various builtin types. */
-#define TRY_TYPE(F) \
- int_type = (unsigned_p \
- ? objfile_type (objfile)->builtin_unsigned_ ## F \
- : objfile_type (objfile)->builtin_ ## F); \
- if (int_type != NULL && TYPE_LENGTH (int_type) == size_in_bytes) \
- return int_type
-
- TRY_TYPE (char);
- TRY_TYPE (short);
- TRY_TYPE (int);
- TRY_TYPE (long);
- TRY_TYPE (long_long);
-
-#undef TRY_TYPE
-
- gdb_assert_not_reached ("unable to find suitable integer type");
-}
-
/* Read the DW_AT_type attribute for a sub-range. If this attribute is not
present (which is valid) then compute the default type based on the
compilation units address size. */
void set_type_for_signatured_type (signatured_type *sig_type,
struct type *type);
- /* Find an integer type SIZE_IN_BYTES bytes in size and return it.
- UNSIGNED_P controls if the integer is unsigned or not. */
- struct type *int_type (int size_in_bytes, bool unsigned_p) const;
-
/* Get the dwarf2_cu matching PER_CU for this objfile. */
dwarf2_cu *get_cu (dwarf2_per_cu_data *per_cu);
return bfd_flavour_name (bfd_get_flavour (objfile->obfd));
return NULL;
}
+
+/* See objfiles.h. */
+
+struct type *
+objfile_int_type (struct objfile *of, int size_in_bytes, bool unsigned_p)
+{
+ struct type *int_type;
+
+ /* Helper macro to examine the various builtin types. */
+#define TRY_TYPE(F) \
+ int_type = (unsigned_p \
+ ? objfile_type (of)->builtin_unsigned_ ## F \
+ : objfile_type (of)->builtin_ ## F); \
+ if (int_type != NULL && TYPE_LENGTH (int_type) == size_in_bytes) \
+ return int_type
+
+ TRY_TYPE (char);
+ TRY_TYPE (short);
+ TRY_TYPE (int);
+ TRY_TYPE (long);
+ TRY_TYPE (long_long);
+
+#undef TRY_TYPE
+
+ gdb_assert_not_reached ("unable to find suitable integer type");
+}
extern void set_objfile_main_name (struct objfile *objfile,
const char *name, enum language lang);
+/* Find an integer type SIZE_IN_BYTES bytes in size from OF and return it.
+ UNSIGNED_P controls if the integer is unsigned or not. */
+extern struct type *objfile_int_type (struct objfile *of, int size_in_bytes,
+ bool unsigned_p);
+
extern void objfile_register_static_link
(struct objfile *objfile,
const struct block *block,