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 D70A73951C68 for ; Wed, 10 Jun 2020 03:43:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D70A73951C68 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 2C9D91E797; Tue, 9 Jun 2020 23:43:19 -0400 (EDT) Subject: Re: [PATCH v2 00/42] Share DWARF partial symtabs between objfiles To: Tom de Vries , Simon Marchi , Pedro Alves , 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> <2eefe6e4-567b-9742-0d66-e5a76771203d@simark.ca> From: Simon Marchi Message-ID: <14342819-b0a1-12d1-8b35-e53500c5a67d@simark.ca> Date: Tue, 9 Jun 2020 23:43:18 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <2eefe6e4-567b-9742-0d66-e5a76771203d@simark.ca> 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: Wed, 10 Jun 2020 03:43:21 -0000 On 2020-06-04 2:04 p.m., Simon Marchi wrote: > On 2020-06-04 1:55 p.m., Tom de Vries wrote: >> I've also tested this with the gdb_cmd_file-twice patch with these two >> target boards, and everything looks good. > > Thanks for testing. >> [ FWIW, the gdb.base/index-cache.exp with the gdb_cmd_file-twice patch >> and native is still there. ] > > I'll take a look at that now. Just an update. I haven't had much time to take a look, but the problem seems simple. The sequence of events is: 1. Load binary, create psymtabs, fill per-bfd 2. Because index-cache is on, generate index in the cache 3. Load binary a second time, in dwarf2_initialize_objfile we check: was an index already loaded for this BFD? No, so we try to read the index and fill the per-bfd. However, the per-bfd's comp units vector was already filled when creating psymtabs. The assert is there because it doesn't make sense to read an index for a per_bfd that already has comp units, it means either some psymtabs were created for it or another index was already read. So this is a situation I hadn't accounted for: a BFD for which we have built the partial symtabs the first time, but has an index the second time. We probably just need a check for psymtabs in dwarf2_initialize_objfile, something like the patch below. I included the change to lib/gdb.exp just to make it easier to test / reproduce the issue, but it won't be included in the final patch, a proper test will be included instead. >From a3d0d98961fb26fa8582efeb0f078e6231269380 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 9 Jun 2020 23:38:00 -0400 Subject: [PATCH] gdb: fix loading file twice with index-cache on Change-Id: I458c6f05abb1a05fd3d177e9c9002225e0deee0c --- gdb/dwarf2/read.c | 7 +++++++ gdb/testsuite/lib/gdb.exp | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 97d1771a6295..27ce9092cd31 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5997,6 +5997,13 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) return true; } + if (per_bfd->partial_symtabs != nullptr) + { + /* Partial symbols were already read, the objfile/per_objfile + initialization will be completed in dwarf2_build_psymtabs. */ + return false; + } + if (dwarf2_read_debug_names (per_objfile)) { *index_kind = dw_index_kind::DEBUG_NAMES; diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 9a0620a2bf18..103e883ed417 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4820,7 +4820,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 } -- 2.27.0