From: Bratislav Filipovic <bfilipov@amd.com>
To: <bratislav.filipovic@amd.com>
Cc: <gdb-patches@sourceware.org>, <simon.marchi@efficios.com>,
<tdevries@suse.de>, Bratislav Filipovic <bfilipov@amd.com>
Subject: [PATCH] dwarf2: avoid decoding .debug_line for type units
Date: Thu, 23 Apr 2026 16:37:52 +0000 [thread overview]
Message-ID: <20260423163752.3240149-1-bfilipov@amd.com> (raw)
In-Reply-To: <DM4PR12MB762374F63A140314A6356A5CFE2F2@DM4PR12MB7623.namprd12.prod.outlook.com>
Running gdb.dwarf2/pr13961.exp with clang fails with an internal error:
gdb/dwarf2/read.c: internal-error: decode_line_header_for_cu:
Assertion `!cu->per_cu->is_debug_types ()' failed.
pr13961 is a legacy .S test that references a .debug_line label from
both a CU and a TU. The assembly includes an empty .debug_line section
declaration:
.section .debug_line,"",%progbits
.Ldebug_line0:
With gcc this results in a dummy (valid, but content-less) .debug_line
header being emitted, so GDB can build a line header and resolve file
indices. With clang the .debug_line section can be missing/empty,
leaving the line header unset.
During symbol creation, new_symbol may then try to lazily decode the
CU-only line header while processing a type unit, which triggers the
assertion above.
Fix this by only decoding the line header for non-type units. If no
line header is available, emit a complaint and continue without setting
the symtab rather than attempting CU-only line decoding from a TU.
Tested: gdb.dwarf2/pr13961.exp (CC_FOR_TARGET=clang-23)
---
gdb/dwarf2/read.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index bc7b8b46d87..655cc753334 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -15430,21 +15430,21 @@ is_ada_import_or_export (dwarf2_cu *cu, const char *name,
static void
new_symbol_file_line (struct die_info *die, struct dwarf2_cu *cu,
- struct symbol *sym)
+ struct symbol *sym)
{
bool inlined_func = (die->tag == DW_TAG_inlined_subroutine);
/* Handle DW_AT_call_line / DW_AT_decl_line. */
struct attribute *attr
= dwarf2_attr (die, inlined_func ? DW_AT_call_line : DW_AT_decl_line,
- cu);
+ cu);
if (attr != nullptr)
sym->set_line (attr->unsigned_constant ().value_or (0));
/* Handle DW_AT_call_file / DW_AT_decl_file. */
struct dwarf2_cu *file_cu = cu;
attr = dwarf2_attr (die, inlined_func ? DW_AT_call_file : DW_AT_decl_file,
- &file_cu);
+ &file_cu);
if (attr == nullptr)
return;
@@ -15452,16 +15452,27 @@ new_symbol_file_line (struct die_info *die, struct dwarf2_cu *cu,
if (!index_cst.has_value ())
return;
- if (file_cu->line_header == nullptr)
+ /* decode_line_header_for_cu is CU-only and asserts on debug_types.
+ For type units, the TU setup code runs before processing child DIEs,
+ so if line_header is still nullptr here it means there is no usable
+ line table for this unit. */
+ if (file_cu->line_header == nullptr
+ && !file_cu->per_cu->is_debug_types ())
{
file_and_directory fnd (nullptr, nullptr);
decode_line_header_for_cu (file_cu->dies, file_cu, fnd);
}
file_name_index file_index = (file_name_index) *index_cst;
- struct file_entry *fe = nullptr;
- if (file_cu->line_header != nullptr)
- fe = file_cu->line_header->file_name_at (file_index);
+
+ /* Check if we successfully got line_header. */
+ if (file_cu->line_header == nullptr)
+ {
+ complaint (_("missing .debug_line information to resolve file index"));
+ return;
+ }
+
+ struct file_entry *fe = file_cu->line_header->file_name_at (file_index);
if (fe == nullptr)
{
--
2.43.0
next prev parent reply other threads:[~2026-04-23 16:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 13:35 Bratislav Filipovic
2026-04-01 14:54 ` [PING][PATCH] " Filipovic, Bratislav
2026-04-16 14:10 ` [PATCH] testsuite: ada-valprint-error relocation issue Bratislav Filipovic
2026-04-16 15:14 ` Tom de Vries
2026-04-20 13:16 ` [PATCH][PING] dwarf2: avoid decoding .debug_line for type units Filipovic, Bratislav
2026-04-23 16:37 ` Bratislav Filipovic [this message]
2026-04-23 17:42 ` [PATCH] " Simon Marchi
2026-04-27 10:26 ` [FYI] " Filipovic, Bratislav
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=20260423163752.3240149-1-bfilipov@amd.com \
--to=bfilipov@amd.com \
--cc=bratislav.filipovic@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=tdevries@suse.de \
/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