From patchwork Mon Oct 2 12:50:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 76953 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17A723881D1F for ; Mon, 2 Oct 2023 12:52:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17A723881D1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696251170; bh=61vE4O9ByYZRpO+UtlWC5voP8rzsHEzXvswOktKkHlI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=hzgIO0LSx1HVsmS//x+hvtR1hFcsPDvHFm2sBh3MlzMM507Dgcteam/b8ckbEHYF6 hzWxOS1/EMLzqPhDM7/FkfTaTmN1UPp5T1+lFwJtIvKxS6Z1ousd2yVeE3E6np3BpM TvmsxXsz1NnJTVpgBu+9C/RivWaevjFYjmyflFQw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 72AFD3856243 for ; Mon, 2 Oct 2023 12:50:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72AFD3856243 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6716D1F854 for ; Mon, 2 Oct 2023 12:50:47 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 55BCF139C2 for ; Mon, 2 Oct 2023 12:50:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OIz6E6e8GmVZMgAAMHmgww (envelope-from ) for ; Mon, 02 Oct 2023 12:50:47 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 11/13] [gdb/symtab] Don't defer backward refs, inter-cu intra-shard case Date: Mon, 2 Oct 2023 14:50:49 +0200 Message-Id: <20231002125051.29911-12-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231002125051.29911-1-tdevries@suse.de> References: <20231002125051.29911-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Consider the test-case gdb.dwarf2/backward-spec-inter-cu.exp with debug_handle_deferred_entries: ... $ gdb -q -batch -iex "maint set worker-threads 0" backward-spec-inter-cu: handle_deferred_entries, intra-shard case parent map 0x00000000000000c8 0x3254a80 (0xc7) 0x00000000000000d3 0x0 0x00000000000000e1 0x2935500 (deferred) 0x00000000000000e2 0x0 parent valid map 0x000000000000002e 0x1 0x0000000000000045 0x0 0x0000000000000062 0x1 0x0000000000000084 0x0 0x00000000000000be 0x1 0x00000000000000d4 0x0 0x00000000000000e1 0x1 0x00000000000000eb 0x0 0x0000000000000123 0x1 0x00000000000002ae 0x0 Resolve deferred: 0xe1 -> 0xcb: 0xc7 handle_deferred_entries, inter-shard case 0x00000000000000c8 0x3254a80 (0xc7) 0x00000000000000d3 0x0 0x00000000000000e1 0x2935500 (deferred) 0x00000000000000e2 0x0 ... It has a backward inter-cu, intra-shard dependency, which is first deferred and then resolved in the intra-shard case. However, we can handle this more optimally: we can not defer and resolve immediately, because by the time that we process 0xe1, 0xcb is already processed by the same shard, and consequently present in the parent map. Fix this by not deferring dependencies that are present in the shard's parent map, such that we have instead: ... handle_deferred_entries, intra-shard case parent map 0x00000000000000c8 0x3d36cb0 (0xc7) 0x00000000000000d3 0x0 parent valid map 0x000000000000002e 0x1 0x0000000000000045 0x0 0x0000000000000062 0x1 0x0000000000000084 0x0 0x00000000000000be 0x1 0x00000000000000d4 0x0 0x00000000000000e1 0x1 0x00000000000000eb 0x0 0x0000000000000123 0x1 0x00000000000002ae 0x0 handle_deferred_entries, inter-shard case 0x00000000000000c8 0x3d36cb0 (0xc7) 0x00000000000000d3 0x0 ... Tested on x86_64-linux. --- gdb/dwarf2/read.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index fca83aed5f7..6f218f172a9 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4701,6 +4701,12 @@ class cooked_index_storage m_index->set_parent_valid (start, end); } + /* Return true if find_parents can be relied upon. */ + bool parent_valid (CORE_ADDR addr) + { + return m_index->parent_valid (addr); + } + private: /* Hash function for a cutu_reader. */ @@ -4855,6 +4861,12 @@ class cooked_indexer { m_index_storage->set_parent_valid (start, end); } + + /* Return true if find_parents can be relied upon. */ + bool parent_valid (CORE_ADDR addr) + { + return m_index_storage->parent_valid (addr); + } }; /* Subroutine of dwarf2_build_psymtabs_hard to simplify it. @@ -16391,7 +16403,11 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, const gdb_byte *new_info_ptr = (new_reader->buffer + to_underlying (origin_offset)); - if ((new_reader->cu != reader->cu + CORE_ADDR origin_addr = form_addr (origin_offset, origin_is_dwz, + reader->cu->per_cu->is_debug_types); + + if (((new_reader->cu != reader->cu + && !parent_valid (origin_addr)) || (new_reader->cu == reader->cu && new_info_ptr > watermark_ptr)) && *parent_entry == nullptr)