Go to file
Tom de Vries 573d8bb08b [gdb/symtab] Return correct reader for top-level CU in cooked_indexer::ensure_cu_exists
With the test-case included in this patch, we run into:
...
$ gdb -q -batch $exec
Dwarf Error: Could not find abbrev number 3 in CU at offset 0xdb \
  [in module $exec]
...

The debug info consists of two CUs:
...
  Compilation Unit @ offset 0xb2:
   Length:        0x25 (32-bit)
   Version:       4
   Abbrev Offset: 0x6c
   Pointer Size:  8
 <0><bd>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <be>   DW_AT_language    : 2	(non-ANSI C)
 <1><bf>: Abbrev Number: 2 (DW_TAG_subprogram)
    <c0>   DW_AT_low_pc      : 0x4004a7
    <c8>   DW_AT_high_pc     : 0x4004b2
    <d0>   DW_AT_specification: <0xe8>
 <1><d4>: Abbrev Number: 3 (DW_TAG_subprogram)
    <d5>   DW_AT_name        : main
 <1><da>: Abbrev Number: 0
  Compilation Unit @ offset 0xdb:
   Length:        0xf (32-bit)
   Version:       4
   Abbrev Offset: 0x86
   Pointer Size:  8
 <0><e6>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <e7>   DW_AT_language    : 2	(non-ANSI C)
 <1><e8>: Abbrev Number: 2 (DW_TAG_subprogram)
    <e9>   DW_AT_specification: <0xd4>
 <1><ed>: Abbrev Number: 0
...
where:
- DIE 0xbf in CU@0xb2 contains an inter-CU reference to
- DIE 0xe8 in CU@0xdb, which contains an inter-CU reference to
- DIE 0xd4 back in CU@0xb2.

The dwarf error is caused by this bit of code in
cooked_indexer::ensure_cu_exists:
...
  if (per_cu == m_per_cu)
    return reader;
...

The dwarf error happens as follows:
- a cutu_reader A is created for CU@0xb2
- using cutu_reader A, the cooked index reader starts indexing dies, with
  m_per_cu set to CU@0xb2
- while indexing it scans the attributes of DIE 0xbf and encounters the
  inter-CU reference to DIE 0xe8
- it calls cooked_indexer::ensure_cu_exists, which creates a cutu_reader B for
  CU@0xdb and returns it
- using cutu_reader B, it continues scanning attributes of DIE 0xe8 and
  encounters the inter-CU reference to DIE 0xd4
- it calls cooked_indexer::ensure_cu_exists, the problematic bit is triggered
  and cutu_reader B is returned
- using cutu_reader B, it continues scanning attributes of DIE 0xd4
- this goes wrong because:
  - the attributes of the DIE are encoded using the abbreviation table at
    offset 0x6c, while
  - the decoding is done using cutu_reader B which uses the abbreviation table
    at offset 0x86.

Fix this by removing the problematic if clause.

Since cutu_reader A is not preserved in m_index_storage,
cooked_indexer::ensure_cu_exists cannot find it there and creates a duplicate
cutu_reader C for CU@0xb2.  Fix this in process_psymtab_comp_unit by preserving
the cutu_reader A as well in m_index_storage.

Tested on x86_64-linux and aarch64-linux.

PR symtab/32081
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32081

Approved-By: Tom Tromey <tom@tromey.com>
Reported-By: Andreas Schwab <schwab@linux-m68k.org>
2024-08-22 10:00:27 +02:00
bfd Automatic date update in version.in 2024-08-22 00:00:35 +00:00
binutils Remove Walter Lee as maintainer for Tile Gx and Tile Pro 2024-08-19 16:34:29 +01:00
config
contrib
cpu
elfcpp
etc
gas gas: ginsn: x86: pacify Wmaybe-uininitialized compiler warning 2024-08-19 11:08:39 -07:00
gdb [gdb/symtab] Return correct reader for top-level CU in cooked_indexer::ensure_cu_exists 2024-08-22 10:00:27 +02:00
gdbserver btrace, python: Enable ptwrite filter registration. 2024-08-14 11:20:57 +02:00
gdbsupport gdb: avoid '//' in filenames when searching for debuginfo 2024-08-19 15:02:56 +01:00
gnulib
gold PR32032 dwp segfaults on hello world binary 2024-07-29 16:25:59 +09:30
gprof
gprofng gprofng: testsuite: fix 'wrapper' typo 2024-08-22 04:15:16 +01:00
include RISC-V: Add support for XCvBitmanip extension in CV32E40P 2024-08-06 13:57:33 +08:00
ld Revert "MIPS: correct macro use in gas and ld testsuites" 2024-08-15 09:49:33 -07:00
libbacktrace
libctf libctf: fix ctf_archive_count return value on big-endian 2024-07-31 21:10:06 +01:00
libdecnumber
libiberty
libsframe
opcodes opcodes/cgen: drop trailing whitespace also for cris 2024-08-16 08:34:50 +02:00
readline
sim sim: pru: Fix test case assembly with latest GAS 2024-08-12 23:33:59 +03:00
texinfo
zlib
.cvsignore
.editorconfig
.gitattributes
.gitignore
.pre-commit-config.yaml pre-commit: autoupdate 2024-08-12 13:07:59 -04:00
ar-lib
ChangeLog
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
SECURITY.txt
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.