public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "simark at simark dot ca" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/32742] [gdb/symtab, fission] read.c:20914: internal-error: set_lang: Assertion `old_value == language_unknown || old_value == language_minimal || old_value == lang' failed
Date: Tue, 04 Mar 2025 20:03:49 +0000	[thread overview]
Message-ID: <bug-32742-4717-wi4dRnpc58@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-32742-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=32742

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #5 from Simon Marchi <simark at simark dot ca> ---
I'm working with this reproducer precisely:

$ ./gdb  -nx -q --data-directory=data-directory -ex 'maint set dwarf sync on'
-ex 'maintenance set per-command time on' -ex 'maintenance set worker-threads
0' -ex 'file testsuite/outputs/gdb.ada/access_tagged_param/foo' -ex "b break
pck.adb:19" -batch

Focusing on the CU at offset 0x0, the first place the Ada language gets set is:

#0  dwarf2_per_cu::set_lang (this=0x50f0000044b0, lang=language_ada,
dw_lang=DW_LANG_Ada95) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:20788
#1  0x0000555561666af6 in cutu_reader::prepare_one_comp_unit
(this=0x7ffff10bf2b0, cu=0x51700008e000, pretend_language=language_minimal) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:21029
#2  0x000055556159f740 in cutu_reader::cutu_reader (this=0x7ffff10bf2b0,
this_cu=0x50f0000044b0, per_objfile=0x516000066080,
abbrev_table=0x510000004640, existing_cu=0x0, skip_partial=false, 
    pretend_language=language_minimal, cache=0x7ffff11b95e0) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:3371
#3  0x00005555615a547a in process_psymtab_comp_unit (this_cu=0x50f0000044b0,
per_objfile=0x516000066080, storage=0x7ffff11b95e0) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:3799
#4  0x00005555615a9292 in cooked_index_worker_debug_info::process_cus
(this=0x51700008dc80, task_number=0, first=std::unique_ptr<dwarf2_per_cu> =
{...}, end=std::unique_ptr<dwarf2_per_cu> = {...})
    at /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:4122

I think this is expected.  The cutu_reader identified that the
DW_TAG_compile_unit is a DWO stub, it has read the DWO file and now
cutu_reader::comp_unit_die points to the DIE from the DWO, which has all the
information (the stub DIE in the main file does not have the DW_AT_language
attribute).  cutu_reader::prepare_one_comp_unit properly reads the language
from there and sets it.

The second time the language gets set is:

#0  dwarf2_per_cu::set_lang (this=0x50f0000044b0, lang=language_minimal,
dw_lang=0) at /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:20788
#1  0x0000555561666af6 in cutu_reader::prepare_one_comp_unit
(this=0x7ffff0f42730, cu=0x517000091b80, pretend_language=language_minimal) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:21029
#2  0x00005555615a1822 in cutu_reader::cutu_reader (this=0x7ffff0f42730,
this_cu=0x50f0000044b0, per_objfile=0x516000066080,
pretend_language=language_minimal, parent_cu=0x0, dwo_file=0x0)
    at /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:3464
#3  0x000055556158c850 in dw2_get_file_names (this_cu=0x50f0000044b0,
per_objfile=0x516000066080) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:1956
#4  0x000055556158f4f5 in dw_expand_symtabs_matching_file_matcher
(per_objfile=0x516000066080, file_matcher=...) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:2157
#5  0x00005555616329e2 in cooked_index_functions::expand_symtabs_matching
(this=0x50200002ab50, objfile=0x516000065780, file_matcher=...,
lookup_name=0x0, symbol_matcher=..., expansion_notify=..., 
    search_flags=..., domain=..., lang_matcher=...) at
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:15912
#6  0x0000555562ca8a14 in objfile::map_symtabs_matching_filename
(this=0x516000065780, name=0x50200002ad90 "break pck.adb", real_path=0x0,
callback=...) at /home/smarchi/src/binutils-gdb/gdb/symfile-debug.c:207
#7  0x0000555562d68775 in iterate_over_symtabs (pspace=0x513000005600,
name=0x50200002ad90 "break pck.adb", callback=...) at
/home/smarchi/src/binutils-gdb/gdb/symtab.c:727


In dw2_get_file_names, we create a temporary cutu_reader using the other
constructor, the one that says:

  /* Read CU/TU THIS_CU but do not follow DW_AT_GNU_dwo_name (DW_AT_dwo_name)
     if present. DWO_FILE, if non-NULL, is the DWO file to read (the caller is
     assumed to have already done the lookup to find the DWO file).

That cutu_reader constructor also ends with a call to prepare_one_comp_unit,
which sets the language.  But here, since we operate without considering the
DWO we didn't identify the language properly, so we try to set it to
language_minimal.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2025-03-04 20:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25  9:59 [Bug symtab/32742] New: " vries at gcc dot gnu.org
2025-02-26 12:17 ` [Bug symtab/32742] " vries at gcc dot gnu.org
2025-02-26 12:29 ` vries at gcc dot gnu.org
2025-02-26 12:56 ` vries at gcc dot gnu.org
2025-02-27 18:12 ` tromey at sourceware dot org
2025-03-04 20:03 ` simark at simark dot ca [this message]
2025-03-07 14:54 ` simon.marchi at polymtl dot ca
2025-03-08  2:55 ` cvs-commit at gcc dot gnu.org
2025-03-08  2:56 ` simon.marchi at polymtl dot ca
2025-03-09 17:21 ` simon.marchi at polymtl dot ca
2025-03-09 17:21 ` simon.marchi at polymtl dot ca
2025-03-11 13:35 ` tromey at sourceware dot org

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=bug-32742-4717-wi4dRnpc58@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).