aboutsummaryrefslogtreecommitdiff
path: root/gdb/ctfread.c
diff options
context:
space:
mode:
authorWeimin Pan <weimin.pan@oracle.com>2021-10-18 14:15:21 -0400
committerWeimin Pan <weimin.pan@oracle.com>2021-10-18 14:15:21 -0400
commitb3a01ce2155d3532761f07639e00ce3d0317837d (patch)
tree401a78bd61bb190b2da7ccdd27248d49e18ff954 /gdb/ctfread.c
parent19b96124487358e723f920bfa30c272f5c0c5995 (diff)
downloadgdb-b3a01ce2155d3532761f07639e00ce3d0317837d.zip
gdb-b3a01ce2155d3532761f07639e00ce3d0317837d.tar.gz
gdb-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/ctfread.c')
-rw-r--r--gdb/ctfread.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 712683b..06e2224 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -691,7 +691,12 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid)
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));
@@ -733,8 +738,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t 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);
@@ -744,9 +748,8 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
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);