binutils-gdb/gdb/dwarf2
Simon Marchi 4ebe487749 Pass correct die_reader_specs in cutu_reader::init_tu_and_read_dwo_dies
Running anything with the fission.exp board fails since commit
c0ab21c22b ("Replace init_cutu_and_read_dies with a class").
GDB crashes while reading the DWARF info.  cu is NULL in
read_signatured_type:

    Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
    0x000055555780663e in read_signatured_type
    sig_type=0x6210000c3600) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22782
    22782         gdb_assert (cu->die_hash == NULL);
    (top-gdb) bt
    #0  0x000055555780663e in read_signatured_type (sig_type=0x6210000c3600) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22782
    #1  0x00005555578062dd in load_full_type_unit (per_cu=0x6210000c3600) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22758
    #2  0x00005555577c5fb7 in queue_and_load_dwo_tu (slot=0x60600007fc00, info=0x6210000c34e0) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:12674
    #3  0x0000555559934232 in htab_traverse_noresize (htab=0x60b000063670, callback=0x5555577c5e61 <queue_and_load_dwo_tu(void**, void*)>, info=0x6210000c34e0)
        at /home/simark/src/binutils-gdb/libiberty/hashtab.c:775
    #4  0x00005555577c6252 in queue_and_load_all_dwo_tus (per_cu=0x6210000c34e0) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:12701
    #5  0x000055555777ebd8 in dw2_do_instantiate_symtab (per_cu=0x6210000c34e0, skip_partial=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:2371
    #6  0x000055555777eea2 in dw2_instantiate_symtab (per_cu=0x6210000c34e0, skip_partial=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:2395
    #7  0x0000555557786ab6 in dw2_lookup_symbol (objfile=0x614000007240, block_index=GLOBAL_BLOCK, name=0x602000025310 "main", domain=VAR_DOMAIN)
        at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:3539

After creating the reader object, the reader.cu field should not be
NULL.  By checking the commit previous to the faulty one mentioned
above, I noticed that the cu field is normally set by
init_cu_die_reader, called from read_cutu_die_from_dwo, itself called
from cutu_reader::init_tu_and_read_dwo_dies, itself called from
cutu_reader's constructor.

However, cutu_reader::init_tu_and_read_dwo_dies calls
read_cutu_die_from_dwo, passing a pointer to a local `die_reader_specs`
variable.  So it's the `cu` field of that object that gets set.
cutu_reader itself is a `die_reader_specs` (it inherits from it), and
the intention was most likely to pass `this` to read_cutu_die_from_dwo.
This way, the fields of the cutu_reader object, which
read_signatured_type will use, are set.

With this, I am able to use:

  make check RUNTESTFLAGS='--target_board=fission'

and it looks much better.  There are still some failures to be
investigated, but that's the usual state of the testsuite.

gdb/ChangeLog:

	* dwarf2/read.c (cutu_reader::init_tu_and_read_dwo_dies): Remove
	reader variable, pass `this` to read_cutu_die_from_dwo.
2020-02-28 10:07:46 -05:00
..
abbrev.c Minor simplification in abbrev_table::read 2020-02-08 13:43:24 -07:00
abbrev.h Use htab_up in abbrev_table 2020-02-08 13:43:24 -07:00
attribute.c Change attr_form_is_block to be a method 2020-02-08 13:40:57 -07:00
attribute.h Change attr_form_is_block to be a method 2020-02-08 13:40:57 -07:00
comp-unit.c Convert read_address to a method on comp_unit_head 2020-02-08 13:43:24 -07:00
comp-unit.h Convert read_address to a method on comp_unit_head 2020-02-08 13:43:24 -07:00
expr.c Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
expr.h Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
frame-tailcall.c Return unique_xmalloc_ptr from call_site_find_chain 2020-02-14 12:38:04 -07:00
frame-tailcall.h Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
frame.c Move the frame data to the BFD when possible 2020-02-12 15:51:58 -07:00
frame.h Don't forward-declare struct objfile in dwarf2/frame.h 2020-02-11 17:57:46 -07:00
index-cache.c Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
index-cache.h Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
index-common.c Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
index-common.h Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
index-write.c Remove casts from dwarf2/index-write.c 2020-02-26 15:49:50 -07:00
index-write.h Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
leb.c Move read_offset_1 to leb.c 2020-02-08 13:43:24 -07:00
leb.h Move two more functions to dwarf2/leb.h 2020-02-08 13:43:24 -07:00
line-header.c Move DWARF line_header to new file 2020-02-08 13:43:24 -07:00
line-header.h Move DWARF line_header to new file 2020-02-08 13:43:24 -07:00
loc.c Make dwarf2_compile_expr_to_ax static 2020-02-22 13:49:56 -07:00
loc.h Move more declarations from dwarf2/loc.h to dwarf2/read.h 2020-02-26 09:36:44 -05:00
read.c Pass correct die_reader_specs in cutu_reader::init_tu_and_read_dwo_dies 2020-02-28 10:07:46 -05:00
read.h Move more declarations from dwarf2/loc.h to dwarf2/read.h 2020-02-26 09:36:44 -05:00
section.c
section.h Convert dwarf2_section_size to a method 2020-02-08 13:43:24 -07:00