From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH v3 5/9] gdb/ctf: check return value of ctf_type_align
Date: Fri, 27 Feb 2026 22:51:52 -0500 [thread overview]
Message-ID: <20260228035425.422765-6-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260228035425.422765-1-simon.marchi@efficios.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
I tried to build the Linux kernel with -gctf. I am not sure if the
result is good, because I got plenty of warnings like:
ld: warning: orphan section `.ctf' from `vmlinux.o' being placed in section `.ctf'
Nevertheless, I tried to load it in GDB, and it didn't complain.
However, when doing "maint expand-symtabs", I did hit this assert:
/home/simark/src/binutils-gdb/gdb/gdbtypes.c:3640: internal-error: set_type_align: Assertion `(align & (align - 1)) == 0' failed.
This is because ctf_type_align returns -1 for some types, which is an
indication of an error. Update the code to check the return value of
ctf_type_align for errors, and emit complaints if it happens.
With this patch, if I enable the complaints, I see a bunch of messages
like this:
During symbol reading: ctf_type_align read_structure_type failed - Type is not a complete type.
Change-Id: Ibed23e7f1490d9163b8dde1318b9e45dec2906d6
---
gdb/ctfread.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index c8457a70cf46..ed4a7383427d 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -616,7 +616,14 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid)
type->set_code (TYPE_CODE_STRUCT);
type->set_length (ctf_type_size (dict, tid));
- set_type_align (type, ctf_type_align (dict, tid));
+
+ if (ssize_t align = ctf_type_align (dict, tid);
+ align >= 0)
+ set_type_align (type, align);
+ else
+ complaint (_("ctf_type_align read_structure_type failed - %s"),
+ ctf_errmsg (ctf_errno (dict)));
+
return set_tid_type (objfile, tid, type);
}
@@ -673,7 +680,13 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid)
}
rettype = fetch_tid_type (ccp, cfi.ctc_return);
type->set_target_type (rettype);
- set_type_align (type, ctf_type_align (dict, tid));
+
+ if (ssize_t align = ctf_type_align (dict, tid);
+ align >= 0)
+ set_type_align (type, align);
+ else
+ complaint (_("ctf_type_align read_func_kind_type failed - %s"),
+ ctf_errmsg (ctf_errno (dict)));
/* Set up function's arguments. */
argc = cfi.ctc_argc;
@@ -723,7 +736,13 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
type->set_length (ctf_type_size (dict, tid));
/* Set the underlying type based on its ctf_type_size bits. */
type->set_target_type (objfile_int_type (objfile, type->length (), false));
- set_type_align (type, ctf_type_align (dict, tid));
+
+ if (ssize_t align = ctf_type_align (dict, tid);
+ align >= 0)
+ set_type_align (type, align);
+ else
+ complaint (_("ctf_type_align read_enum_type failed - %s"),
+ ctf_errmsg (ctf_errno (dict)));
return set_tid_type (objfile, tid, type);
}
@@ -814,7 +833,12 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid)
else
type->set_length (ctf_type_size (dict, tid));
- set_type_align (type, ctf_type_align (dict, tid));
+ if (ssize_t align = ctf_type_align (dict, tid);
+ align >= 0)
+ set_type_align (type, align);
+ else
+ complaint (_("ctf_type_align read_array_type failed - %s"),
+ ctf_errmsg (ctf_errno (dict)));
return set_tid_type (objfile, tid, type);
}
@@ -936,7 +960,13 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid)
}
type = lookup_pointer_type (target_type);
- set_type_align (type, ctf_type_align (ccp->dict, tid));
+
+ if (ssize_t align = ctf_type_align (ccp->dict, tid);
+ align >= 0)
+ set_type_align (type, align);
+ else
+ complaint (_("ctf_type_align read_pointer_type failed - %s"),
+ ctf_errmsg (ctf_errno (ccp->dict)));
return set_tid_type (objfile, tid, type);
}
--
2.53.0
next prev parent reply other threads:[~2026-02-28 3:54 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 6:45 [RFC PATCH 0/8] Make CTF reader build full symtabs, get rid of psymtab simon.marchi
2026-02-03 6:45 ` [RFC PATCH 1/8] gdb/ctf: add debug logging in ctfread.c simon.marchi
2026-02-03 12:40 ` Eli Zaretskii
2026-02-03 16:21 ` Simon Marchi
2026-02-03 16:37 ` Eli Zaretskii
2026-02-03 20:39 ` Simon Marchi
2026-02-03 6:45 ` [RFC PATCH 2/8] gdb/ctf: add unique_ptr types simon.marchi
2026-02-03 6:45 ` [RFC PATCH 3/8] gdb/ctf: editorial renames simon.marchi
2026-02-03 6:45 ` [RFC PATCH 4/8] gdb/ctf: use ctf_per_objfile in ctf_archive_iter_psymtab_data and ctf_context simon.marchi
2026-02-12 17:44 ` Tom Tromey
2026-02-12 18:35 ` Simon Marchi
2026-02-03 6:45 ` [RFC PATCH 5/8] gdb/ctf: check return value of ctf_type_align simon.marchi
2026-02-12 17:49 ` Tom Tromey
2026-02-12 18:37 ` Simon Marchi
2026-02-03 6:45 ` [RFC PATCH 6/8] gdb/ctf: add scoped_time_it in elfctf_build_psymtabs simon.marchi
2026-02-03 6:45 ` [RFC PATCH 7/8] gdb/ctf: don't use psymtabs, create symtabs directly simon.marchi
2026-02-12 17:54 ` Tom Tromey
2026-02-03 6:45 ` [RFC PATCH 8/8] gdb: remove psymtab.{c,h} simon.marchi
2026-02-12 17:58 ` [RFC PATCH 0/8] Make CTF reader build full symtabs, get rid of psymtab Tom Tromey
2026-02-12 18:47 ` Simon Marchi
2026-02-17 19:50 ` [PATCH v2 0/9] " simon.marchi
2026-02-17 19:50 ` [PATCH v2 1/9] gdb/ctf: add debug logging in ctfread.c simon.marchi
2026-02-17 19:50 ` [PATCH v2 2/9] gdb/ctf: add unique_ptr types simon.marchi
2026-02-17 19:50 ` [PATCH v2 3/9] gdb/ctf: editorial renames simon.marchi
2026-02-17 19:50 ` [PATCH v2 4/9] gdb/ctf: use ctf_per_objfile in ctf_archive_iter_psymtab_data and ctf_context simon.marchi
2026-02-17 19:50 ` [PATCH v2 5/9] gdb/ctf: check return value of ctf_type_align simon.marchi
2026-02-17 19:50 ` [PATCH v2 6/9] gdb/ctf: add scoped_time_it in elfctf_build_psymtabs simon.marchi
2026-02-17 19:50 ` [PATCH v2 7/9] gdb: make expanded_symbols_functions hold compunit symtabs simon.marchi
2026-02-17 19:50 ` [PATCH v2 8/9] gdb/ctf: don't use psymtabs, create symtabs directly simon.marchi
2026-02-17 19:50 ` [PATCH v2 9/9] gdb: remove psymtab.{c,h} simon.marchi
2026-02-28 3:51 ` [PATCH v3 0/9] Make CTF reader build full symtabs, get rid of psymtab Simon Marchi
2026-02-28 3:51 ` [PATCH v3 1/9] gdb/ctf: add debug logging in ctfread.c Simon Marchi
2026-02-28 10:12 ` Eli Zaretskii
2026-02-28 16:23 ` Simon Marchi
2026-02-28 3:51 ` [PATCH v3 2/9] gdb/ctf: add unique_ptr types Simon Marchi
2026-02-28 3:51 ` [PATCH v3 3/9] gdb/ctf: editorial renames Simon Marchi
2026-02-28 3:51 ` [PATCH v3 4/9] gdb/ctf: use ctf_per_objfile in ctf_archive_iter_psymtab_data and ctf_context Simon Marchi
2026-02-28 3:51 ` Simon Marchi [this message]
2026-02-28 3:51 ` [PATCH v3 6/9] gdb/ctf: add scoped_time_it in elfctf_build_psymtabs Simon Marchi
2026-02-28 3:51 ` [PATCH v3 7/9] gdb: make expanded_symbols_functions hold compunit symtabs Simon Marchi
2026-03-04 19:21 ` Tom Tromey
2026-03-04 19:32 ` Tom Tromey
2026-03-09 18:56 ` Simon Marchi
2026-03-09 18:48 ` Simon Marchi
2026-03-10 17:09 ` Tom Tromey
2026-02-28 3:51 ` [PATCH v3 8/9] gdb/ctf: don't use psymtabs, create symtabs directly Simon Marchi
2026-03-04 19:29 ` Tom Tromey
2026-03-09 18:51 ` Simon Marchi
2026-02-28 3:51 ` [PATCH v3 9/9] gdb: remove psymtab.{c,h} Simon Marchi
2026-02-28 10:18 ` Eli Zaretskii
2026-03-04 19:33 ` [PATCH v3 0/9] Make CTF reader build full symtabs, get rid of psymtab Tom Tromey
2026-03-09 18:57 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260228035425.422765-6-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox