Files
Tom de Vries 248f716500 [gdb/symtab] Fix segfault in process_psymtab_comp_unit
When running test-case gdb.dwarf2/dw2-dummy-cu.exp without -readnow, we run
into:
...
(gdb) file outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu^M
Reading symbols from outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu...^M
ERROR: Couldn't load dw2-dummy-cu into GDB (eof).
...

The problem is that we're running into a segfault:
...
Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
process_psymtab_comp_unit (this_cu=0x2141090, per_objfile=0x1aa4140,
    want_partial_unit=false, pretend_language=language_minimal)
    at /home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:7023
7023      switch (reader.comp_unit_die->tag)
...
due to reader.comp_unit_die == nullptr:
...
(gdb) p reader.comp_unit_die
$1 = (die_info *) 0x0
...

Indeed, there's no CU DIE in the test-case:
...
$ readelf -wi outputs/gdb.dwarf2/dw2-dummy-cu/dw2-dummy-cu
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x7 (32-bit)
   Version:       2
   Abbrev Offset: 0x0
   Pointer Size:  4
$
...

Fix this by handling reader.comp_unit_die == nullptr in
process_psymtab_comp_unit.

Update the test-case to trigger this PR, as per PR27920 - "[gdb/testsuite]
hardcoding -readnow skips testing of partial symbols".

Tested on x86_64-linux.

gdb/ChangeLog:

2021-05-27  Tom de Vries  <tdevries@suse.de>

	PR symtab/27919
	* dwarf2/read.c (process_psymtab_comp_unit):

gdb/testsuite/ChangeLog:

2021-05-27  Tom de Vries  <tdevries@suse.de>

	PR symtab/27919
	PR testsuite/27920
	* gdb.dwarf2/dw2-dummy-cu.exp: Use maint expand-symtabs instead of
	-readnow.
2021-05-27 15:22:38 +02:00
..
2021-03-13 09:41:05 -07:00
2021-05-17 14:16:07 -06:00
2021-05-17 14:16:07 -06:00
2021-03-06 09:26:40 -07:00
2021-03-06 09:26:40 -07:00
2021-03-20 17:23:40 -06:00
2021-03-20 17:23:40 -06:00
2021-05-17 14:16:07 -06:00
2021-05-17 13:07:25 -06:00
2021-03-06 09:26:39 -07:00
2021-03-28 10:43:15 -06:00
2021-03-18 12:08:41 -06:00
2021-03-31 09:48:56 -06:00