CTF: incorrect underlying type setting for enumeration types

A bug was filed against the incorrect underlying type setting for
an enumeration type, which was caused by a copy and paste error.
This patch fixes the problem by setting it by calling objfile_int_type,
which was originally dwarf2_per_objfile::int_type, with ctf_type_size bits.
Also add error checking on ctf_func_type_info call.
This commit is contained in:
Weimin Pan
2021-10-18 14:15:21 -04:00
parent 19b9612448
commit b3a01ce215
6 changed files with 42 additions and 36 deletions

View File

@ -1374,3 +1374,29 @@ objfile_flavour_name (struct objfile *objfile)
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");
}