From patchwork Fri Feb 28 05:25:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 38344 Received: (qmail 39703 invoked by alias); 28 Feb 2020 05:25:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 38789 invoked by uid 89); 28 Feb 2020 05:25:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_SOFTFAIL autolearn=ham version=3.3.1 spammy=var_domain, hashtab.c, hashtabc, UD:hashtab.c X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Feb 2020 05:25:32 +0000 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id FYhRRxdYDcH9MRyF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 28 Feb 2020 00:25:30 -0500 (EST) Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 09742441B21; Fri, 28 Feb 2020 00:25:30 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] Pass correct die_reader_specs in cutu_reader::init_tu_and_read_dwo_dies Date: Fri, 28 Feb 2020 00:25:29 -0500 Message-Id: <20200228052529.11834-1-simon.marchi@efficios.com> MIME-Version: 1.0 Running anything with the fission.exp board fails since commit c0ab21c22bb ("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 , 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. --- gdb/dwarf2/read.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f52b1dd315..07cee58c1f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6774,7 +6774,6 @@ cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu, int use_existing_cu) { struct signatured_type *sig_type; - struct die_reader_specs reader; /* Verify we can do the following downcast, and that we have the data we need. */ @@ -6802,7 +6801,7 @@ cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu, if (read_cutu_die_from_dwo (this_cu, sig_type->dwo_unit, NULL /* stub_comp_unit_die */, sig_type->dwo_unit->dwo_file->comp_dir, - &reader, &info_ptr, + this, &info_ptr, &comp_unit_die, &m_dwo_abbrev_table) == 0) {