From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id F12DD3851C30 for ; Sun, 31 May 2020 04:16:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F12DD3851C30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 16B0F1E072; Sun, 31 May 2020 00:16:53 -0400 (EDT) Subject: Re: [PATCH v2 00/42] Share DWARF partial symtabs between objfiles To: Tom de Vries , Pedro Alves , Simon Marchi , Tom Tromey , Simon Marchi via Gdb-patches References: <20200512210913.5593-1-simon.marchi@efficios.com> <875zcn1xwp.fsf@tromey.com> <5032927f-877b-100b-c3a7-55c78d3a7d7a@redhat.com> <058f6a56-4690-cfd8-ede4-a9bbafc85e1a@efficios.com> <28656eeb-c0b3-c601-f05c-14cfe5493a7e@redhat.com> <63f4d428-b0ec-26de-0265-31002b61f4dd@simark.ca> From: Simon Marchi Message-ID: Date: Sun, 31 May 2020 00:16:52 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2020 04:16:55 -0000 On 2020-05-29 6:23 a.m., Tom de Vries wrote: > Seeing the repetition of file command in the cmd.gdb file (and how > commenting out one of them made the test pass), I started suspecting > this patch series, and wondered if I could reproduce the same or similar > problems on master using a test-suite hack: > ... > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 444cea01c3..fa2a999525 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -4823,7 +4823,12 @@ proc gdb_load_shlib { file } { > # > proc gdb_load { arg } { > if { $arg != "" } { > - return [gdb_file_cmd $arg] > + set res [gdb_file_cmd $arg] > + if { $res != 0 } { > + return $res > + } > + set res [gdb_file_cmd $arg] > + return $res > } > return 0 > } > ... > > And indeed, quite a few failures showed up. I picked one: > gdb.base/langs.exp. > > So, on master, after this patch series, with target board > cc-with-gdb-index, we have: > ... > Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/langs.exp ... > FAIL: gdb.base/langs.exp: up to foo in langs.exp > FAIL: gdb.base/langs.exp: show language at foo in langs.exp > FAIL: gdb.base/langs.exp: up to cppsub_ in langs.exp > FAIL: gdb.base/langs.exp: show language at cppsub_ in langs.exp > FAIL: gdb.base/langs.exp: up to fsub in langs.exp > FAIL: gdb.base/langs.exp: show language at fsub in langs.exp I'm looking at this failure right now because it's easier to tackle. I think I see the problem. In the index case, we never set per_bfd->partial_symtabs, like we do at the end of dwarf2_build_psymtabs for the non-index case. Then, for the second objfile using the same BFD, we never take that per_bfd->partial_symtabs to install it in objfile->partial_symtabs, like we do in the beginning of dwarf2_build_psymtabs. So objfile->partial_symtabs->psymtabs_addrmap stays NULL, and all pc -> symbol lookups fail. See this proof of concept fix, which sets per_bfd->partial_symtabs in dwarf2_read_gdb_index (when parsing the first objfile), and reads it back in dwarf2_initialize_objfile (when parsing the second objfile). The same will need to be done for debug_names. >From d5334c2c61408c4cd815eb54898f442502d5fd66 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 31 May 2020 00:10:33 -0400 Subject: [PATCH] the fix --- gdb/dwarf2/read.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4724738363b..85fd41745f4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3068,6 +3068,7 @@ dwarf2_read_gdb_index offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; struct dwz_file *dwz; struct objfile *objfile = per_objfile->objfile; + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; gdb::array_view main_index_contents = get_gdb_index_contents (objfile, per_objfile->per_bfd); @@ -3138,6 +3139,9 @@ dwarf2_read_gdb_index per_objfile->per_bfd->quick_file_names_table = create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ()); + gdb_assert (per_bfd->partial_symtabs == nullptr); + per_bfd->partial_symtabs = objfile->partial_symtabs; + return 1; } @@ -5981,6 +5985,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) if (per_bfd->index_table != nullptr) { *index_kind = dw_index_kind::GDB_INDEX; + per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs; per_objfile->resize_symtabs (); return true; } -- 2.26.2