From patchwork Sun Nov 12 20:25:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 79659 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 2A3613858C27 for ; Sun, 12 Nov 2023 20:25:54 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 433353858D37 for ; Sun, 12 Nov 2023 20:25:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 433353858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 433353858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699820736; cv=none; b=llR1UoUxZm8pAvaKi0GhsGyhFJxQ2JX49CU9pGAayKR0MjxgHN39G18orJc8pInRMxahmeUACNX0jtwWhJPuAFDze6P2FFkqHXy5sZ3EHuV6ncSsEQJkk+St5/BGuUy9amnWa5BXbz/5x5Z/O8y7AUI9SDL4TCHIw9ZogcUtZNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699820736; c=relaxed/simple; bh=fvWE3ncz3SoFGVuX86RjIctNXvpZlTuNjBKQzAc3/KE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=NHg/wpe5CJE4pIUAL/voxFn9RGWXv+0m7aaOfCGXHiM47pcHruw2oJ8H0ie1swD0llSO8yCpVggrbMVG1/71yi6Rr623ZTe59FVYLecyxkckJA6grwnRerLnhfyqefKg3QuO+tUhEHsne/jFunX8f38YDp616e87++nXvcyYePk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5007a.ext.cloudfilter.net ([10.0.29.141]) by cmsmtp with ESMTPS id 2DrQr9SJxWcCI2H1SrP2hm; Sun, 12 Nov 2023 20:25:34 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 2H1RrFT1cqkaT2H1Rr2jpK; Sun, 12 Nov 2023 20:25:33 +0000 X-Authority-Analysis: v=2.4 cv=bY547cDB c=1 sm=1 tr=0 ts=655134bd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=9B1M5sQIhCA5ud6T798A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LULsNFR1/Pjdw6RLQ8mLw8HQsgKizU3c2CdS+rhw/vY=; b=itP0iHkyx6pryfvOOsirkiQ9sc Y0/Vfe7MNdTiuAyLh8sK3Gi8bwzz/3oH8ZoKYCb1+7q1XDg12ky1Mn/aD25uf3KMeSKTHp5we8We8 m+oN+DRPf9nCxZgkaQ5uOSpLl; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:34540 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1r2H1Q-000cUU-2x for gdb-patches@sourceware.org; Sun, 12 Nov 2023 13:25:32 -0700 From: Tom Tromey Date: Sun, 12 Nov 2023 13:25:46 -0700 Subject: [PATCH v2 09/18] Add "maint set dwarf synchronous" MIME-Version: 1.0 Message-Id: <20231112-t-bg-dwarf-reading-v2-9-70fb170012ba@tromey.com> References: <20231112-t-bg-dwarf-reading-v2-0-70fb170012ba@tromey.com> In-Reply-To: <20231112-t-bg-dwarf-reading-v2-0-70fb170012ba@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.77.73 X-Source-L: No X-Exim-ID: 1r2H1Q-000cUU-2x X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:34540 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBRMr1D7AxLReeslEbzV3c5kVlCJ07Lq9pmFssj7oMHPjxD8KM889BDikjKgwAjadti0vItwTAzFkyxlJ/thoIMciWSRFqAz9OV3C3rCI3OoRrBT9LVU DRc4ljNSD0mAEwJKddtyCOBdnwFYQtMN5nZ6dXDeew/spJsDnyPxi027pfeNJ7Uga3MOZHlK8Nsy3/b2x/2g9JZfoFhfy0gugyQ= X-Spam-Status: No, score=-3024.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org For testing, it's sometimes convenient to be able to request that DWARF reading be done synchronously. This patch adds a new "maint" setting for this purpose. --- gdb/NEWS | 3 +++ gdb/doc/gdb.texinfo | 14 ++++++++++++++ gdb/dwarf2/read.c | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 3851114a9f7..ef87509c48b 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -9,6 +9,9 @@ * GDB index now contains information about the main function. This speeds up startup when it is being used for some large binaries. +* DWARF reading is now done in the background, resulting in faster startup. + This can be controlled using "maint set dwarf synchronous". + * Changed commands disassemble diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 2cd565ed5b4..36a83e94528 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -41700,6 +41700,20 @@ compilation units will be stored in memory longer, and more total memory will be used. Setting it to zero disables caching, which will slow down @value{GDBN} startup, but reduce memory consumption. +@kindex maint set dwarf synchronous +@kindex maint show dwarf synchronous +@item maint set dwarf synchronous +@itemx maint show dwarf synchronous +Control whether DWARF is read asynchronously. + +By default, the DWARF reader is mostly asynchronous with respect to +the rest of @value{GDBN}. That is, the bulk of the reading is done in +the background, and @value{GDBN} will only pause for completion of +this task when absolutely necessary. + +When this setting is enabled, @value{GDBN} will instead wait for DWARF +processing to complete before continuing. + @kindex maint set dwarf unwinders @kindex maint show dwarf unwinders @item maint set dwarf unwinders diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 58d13e880fd..7669af36b37 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -741,6 +741,16 @@ show_dwarf_max_cache_age (struct ui_file *file, int from_tty, "DWARF compilation units is %s.\n"), value); } + +/* Wait for DWARF reading to be complete. */ +static bool dwarf_synchronous = false; +static void +show_dwarf_synchronous (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + gdb_printf (file, _("Whether DWARF reading is synchronous is %s.\n"), + value); +} /* local function prototypes */ @@ -21941,6 +21951,19 @@ caching, which can slow down startup."), &set_dwarf_cmdlist, &show_dwarf_cmdlist); + add_setshow_boolean_cmd ("synchronous", class_obscure, + &dwarf_synchronous, _("\ +Set whether DWARF is read synchronously."), _("\ +Show DWARF is read synchronously."), _("\ +By default, DWARF information is read in worker threads,\n\ +and gdb will not generally wait for this process to complete.\n\ +Enabling this setting will cause the DWARF reader to always wait\n\ +for completion before gdb can proceed."), + nullptr, + show_dwarf_synchronous, + &set_dwarf_cmdlist, + &show_dwarf_cmdlist); + add_setshow_zuinteger_cmd ("dwarf-read", no_class, &dwarf_read_debug, _("\ Set debugging of the DWARF reader."), _("\ Show debugging of the DWARF reader."), _("\