diff options
author | Weimin Pan <weimin.pan@oracle.com> | 2021-10-18 14:15:21 -0400 |
---|---|---|
committer | Weimin Pan <weimin.pan@oracle.com> | 2021-10-18 14:15:21 -0400 |
commit | b3a01ce2155d3532761f07639e00ce3d0317837d (patch) | |
tree | 401a78bd61bb190b2da7ccdd27248d49e18ff954 /gdb/objfiles.c | |
parent | 19b96124487358e723f920bfa30c272f5c0c5995 (diff) | |
download | binutils-b3a01ce2155d3532761f07639e00ce3d0317837d.zip binutils-b3a01ce2155d3532761f07639e00ce3d0317837d.tar.gz binutils-b3a01ce2155d3532761f07639e00ce3d0317837d.tar.bz2 |
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.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r-- | gdb/objfiles.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c index b65fa88..3da6f52 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -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"); +} |