Go to file
Tom de Vries 2fe9a3c41f [gdb/symtab] Fix bad compile unit index complaint
I noticed this code in dw2_debug_names_iterator::next:
...
        case DW_IDX_compile_unit:
          /* Don't crash on bad data.  */
          if (ull >= per_bfd->all_comp_units.size ())
            {
              complaint (_(".debug_names entry has bad CU index %s"
                           " [in module %s]"),
                         pulongest (ull),
                         objfile_name (objfile));
              continue;
            }
          per_cu = per_bfd->get_cu (ull);
          break;
...

This code used to DTRT, before we started keeping both CUs and TUs in
all_comp_units.

Fix by using "per_bfd->all_comp_units.size () - per_bfd->tu_stats.nr_tus"
instead.

It's hard to produce a test-case for this, but let's try at least to trigger
the complaint somehow.  We start out by creating an exec with .debug_types and
.debug_names:
...
$ gcc -g ~/hello.c -fdebug-types-section
$ gdb-add-index -dwarf-5 a.out
...
and verify that we don't see any complaints:
...
$ gdb -q -batch -iex "set complaints 100" ./a.out
...

We look at the CU and TU table using readelf -w and conclude that we have
nr_cus == 6 and nr_tus == 1.

Now override ull in dw2_debug_names_iterator::next for the DW_IDX_compile_unit
case to 6, and we have:
...
$ gdb -q -batch -iex "set complaints 100" ./a.out
During symbol reading: .debug_names entry has bad CU index 6 [in module a.out]
...

After this, it still crashes because this code in
dw2_debug_names_iterator::next:
...
  /* Skip if already read in.  */
  if (m_per_objfile->symtab_set_p (per_cu))
    goto again;
...
is called with per_cu == nullptr.

Fix this by skipping the entry if per_cu == nullptr.

Now revert the fix and observe that the complaint disappears, so we've
confirmed that the fix is required.

A somewhat similar issue for .gdb_index in dw2_symtab_iter_next has been filed
as PR29367.

Tested on x86_64-linux, with native and target board cc-with-debug-names.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29336
2022-07-21 13:05:39 +02:00
bfd PowerPC64: fix build error on 32-bit hosts 2022-07-21 13:35:51 +09:30
binutils PR29390, DW_CFA_AARCH64_negate_ra_state vs. DW_CFA_GNU_window_save 2022-07-21 16:37:06 +09:30
config Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
contrib
cpu Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
elfcpp Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
etc
gas x86/Intel: correct AVX512F scatter insn element sizes 2022-07-21 12:32:04 +02:00
gdb [gdb/symtab] Fix bad compile unit index complaint 2022-07-21 13:05:39 +02:00
gdbserver gdbserver: remove unused variable 2022-07-13 20:10:18 +08:00
gdbsupport [gdbsupport] Improve thread scheduling in parallel_for_each 2022-07-18 08:34:06 +02:00
gnulib
gold Update version to 2.39.50 and regenerate files 2022-07-08 11:19:44 +01:00
gprof Regenerate with automake-1.15.1 2022-07-09 20:10:47 +09:30
gprofng gprofng: link libgprofng.so against -lpthread 2022-07-18 10:42:02 -07:00
include [AArch64] Support AArch64 MTE memory tag dumps in core files 2022-07-19 15:24:27 +01:00
intl
ld x86: Disallow invalid relocations against protected symbols 2022-07-19 08:41:52 -07:00
libbacktrace
libctf Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
libdecnumber
libiberty Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
opcodes x86: replace wrong attributes on VCVTDQ2PH{X,Y} 2022-07-21 12:32:25 +02:00
readline
sim
texinfo
zlib Regenerate with automake-1.15.1 2022-07-09 20:10:47 +09:30
.cvsignore
.editorconfig
.gitattributes
.gitignore
ar-lib
ChangeLog Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
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
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.