Files
binutils-gdb/gdb/dwarf2
Simon Marchi 4996027dbf gdb/dwarf: save DWARF version in dwarf2_loclist_baton, remove it from dwarf2_per_cu
When running:

    $ make check TESTS="gdb.cp/cpexprs-debug-types.exp" RUNTESTFLAGS="--target_board=fission"

I get:

    (gdb) break -qualified main
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.h:295: internal-error: version: Assertion `m_dwarf_version != 0' failed.

The problem is that dwarf2_per_cu objects created in the
read_cutu_die_from_dwo code path never have their DWARF version set.  A
seemingly obvious solution would be to add a call to
dwarf2_per_cu::set_version in there (there's a patch in the referenced
PR that does that).  However, this comment in
read_comp_units_from_section is a bit scary:

      /* Init this asap, to avoid a data race in the set_version in
	 cutu_reader::cutu_reader (which may be run in parallel for the cooked
	 index case).  */
      this_cu->set_version (cu_header.version);

I don't know if a DWO file can be read while the cooked indexer runs, so
if it would be a problem here, but I prefer to be safe than sorry.  This
patch side-steps the problem by deleting the DWARF version from
dwarf2_per_cu.

The only users of dwarf2_per_cu::version are the loclists callbacks in
`loc.c`.  Add the DWARF version to dwarf2_loclist_baton and modify those
callbacks to get the version from there instead.  Initialize that new
field in fill_in_loclist_baton.

I like this approach because there is no version field that is possibly
unset now.

I wasn't keen on doing this at first because I thought it would waste
space, but the dwarf2_loclist_baton has 7 bytes of padding at the end
anyway, so we might as well use that.

Cc: Ricky Zhou <ricky@rzhou.org>
Cc: Tom de Vries <tdevries@suse.de>
Cc: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32309
Change-Id: I30d4ede7d67da5d80ff65c6122f5868e1098ec52
Approved-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit f62cf22157)
2025-03-10 16:24:47 -04:00
..
2024-11-25 22:07:04 -05:00
2024-11-25 22:07:04 -05:00
2024-11-04 10:49:06 -07:00
2024-08-30 13:57:11 -04:00
2024-12-18 10:00:44 -07:00
2024-12-18 10:00:44 -07:00
2024-11-25 22:07:04 -05:00
2024-08-30 13:57:11 -04:00
2024-12-18 10:00:44 -07:00
2024-08-30 13:57:11 -04:00
2024-12-18 10:00:44 -07:00
2024-12-18 10:00:44 -07:00
2024-08-30 13:57:11 -04:00
2024-12-18 10:00:44 -07:00
2024-12-18 10:00:44 -07:00
2024-12-18 10:00:44 -07:00
2024-12-18 10:00:44 -07:00
2024-08-30 13:57:11 -04:00
2024-08-30 13:57:11 -04:00
2024-11-27 18:48:43 +01:00
2024-12-18 10:00:44 -07:00
2024-12-18 10:00:44 -07:00
2024-12-12 20:18:23 -07:00
2024-12-18 10:00:44 -07:00
2024-08-27 09:08:41 +02:00
2024-09-09 11:32:40 -06:00
2024-12-18 10:00:44 -07:00