]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/symtab] Note errors in process_skeletonless_type_units
authorTom de Vries <tdevries@suse.de>
Wed, 28 May 2025 20:17:19 +0000 (22:17 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 28 May 2025 20:17:19 +0000 (22:17 +0200)
commit11cb20e27b50419ffadb65706d716f9019f03516
tree6db3a2497f007fe418057c6536646757cb99d9b0
parentf2172071e6b6f20a0401b68a70655930e40f6455
[gdb/symtab] Note errors in process_skeletonless_type_units

With a hello world a.out, and using the compiler flags from target board
dwarf5-fission-debug-types:
...
$ gcc -gdwarf-5 -fdebug-types-section -gsplit-dwarf ~/data/hello.c
...
I run into:
...
$ gdb -q -batch a.out
terminate called after throwing an instance of 'gdb_exception_error'
...

What happens is that an error is thrown due to invalid dwarf, but the error is
not caught, causing gdb to terminate.

In a way, this is a duplicate of PR32861, in the sense that we no longer run
into this after:
- applying the proposed patch (work around compiler bug), or
- using gcc 9 or newer (compiler bug fixed).

But in this case, the failure mode is worse than in PR32861.

Fix this by catching the error in
cooked_index_worker_debug_info::process_skeletonless_type_units.

With the patch, we get instead:
...
$ gdb -q -batch a.out
Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing outside of \
  .debug_str.dwo section in CU at offset 0x0 [in module a.out]
...

While we're at it, absorb the common use of
cooked_index_worker_result::note_error:
...
  try
    {
      ...
    }
  catch (gdb_exception &exc)
    {
      (...).note_error (std::move (exc));
    }
...
into the method and rename it to catch_error, resulting in more compact code
for the fix:
...
  (...).catch_error ([&] ()
    {
      ...
    });
...

While we're at it, also use it in
cooked_index_worker_debug_info::process_units which looks like it needs the
same fix.

Tested on x86_64-linux.

PR symtab/32979
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32979
gdb/dwarf2/cooked-index-worker.h
gdb/dwarf2/read-debug-names.c
gdb/dwarf2/read.c