From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 2E451384D262 for ; Thu, 23 Nov 2023 05:32:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E451384D262 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 2E451384D262 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700717528; cv=none; b=Wxe2jQhBpav1AvDRElI+71gX6lWOO0eq9B03SDQN43TmqZWDYQrXV7PhZIcZYWYOPzRqzV/Vew/0HN31Ci9XWnXfgI676uNlbDlLeE7ipMOtPiA4PlFRdcWUIQomsyA8j2UyTKHBmjbDlfsDhZ7GCYFNXM0B5gBMqgH57jabSqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700717528; c=relaxed/simple; bh=rjlYh4Q1U7zTeTVj/GqUggM1HfBpx9ITJZ3becjFyEU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=CAVgYWO2o/nVbb4TbkwpCuq6JzDwRgDSUVkf9PiHDwBJoSaoqE2toMMl3LB69T/O6gtHX4Q5HFNhRiyJfU8GN001MhrmpIAbXdUTSreiTrYD2rHFMUA7LkDBVkHqMF1Kqi8we7JZum2a49U9YfZKvbcpFWWtGTtCBYJrnzNYaiI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTPS id 61YRrX4ULgpyE62Jord5qB; Thu, 23 Nov 2023 05:32:04 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 62JnrFt8whDny62Jor2LSV; Thu, 23 Nov 2023 05:32:04 +0000 X-Authority-Analysis: v=2.4 cv=fda+dmcF c=1 sm=1 tr=0 ts=655ee3d4 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=NI_dxE7nwc98NY2lJkgA: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=AcYh4COohA8gKgBpY9QQEPfm8wMTECO9PlKGr9/7ZaM=; b=UEtA+HAcfxnDZevqBPEa8DBbbA NRhdNunN8oqQ/ER814cT2gw6oogJMxYZm3d+nOgD7SLZvovG1eV6CpCH68EcJoXrXZXrblKIXR/iv rA2bdIWpfaeXXSszOCsBPEvtQ; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:46354 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 1r62Jn-003TGR-1R for gdb-patches@sourceware.org; Wed, 22 Nov 2023 22:32:03 -0700 From: Tom Tromey Date: Wed, 22 Nov 2023 22:32:18 -0700 Subject: [PATCH v3 09/18] Add "maint set dwarf synchronous" MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231122-t-bg-dwarf-reading-v3-9-fc3180de63c4@tromey.com> References: <20231122-t-bg-dwarf-reading-v3-0-fc3180de63c4@tromey.com> In-Reply-To: <20231122-t-bg-dwarf-reading-v3-0-fc3180de63c4@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: 1r62Jn-003TGR-1R 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]:46354 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLdvnRlft2YytlIxZCh1xD7CHv6Df9rLCXSlqI7k43kaCJmJTv0vhtTr2/GXpKzyGQiP1CH6CvlwPHc21eH3n209zSse5ZRvOmj/WZq//0xQrCI9CAHu sLl+tOhQOEZaRBLMPvws3wImjxP17s7fCwGOaGrJz4udv13hjD20n2hUwjqvV4mP/vFBVtfOWttTBLxb68UhyJZoEoUTfEl4iUE= X-Spam-Status: No, score=-3024.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: 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 | 4 ++++ gdb/doc/gdb.texinfo | 18 ++++++++++++++++++ gdb/dwarf2/read.c | 27 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 1073e38dfc6..cd210f32d32 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -9,6 +9,10 @@ * GDB index now contains information about the main function. This speeds up startup when it is being used for some large binaries. +* On hosts where threading is available, 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 e4c00143fd1..e4a89ba38b7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -41710,6 +41710,24 @@ 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. + +On hosts where threading is available, 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. + +On hosts without threading, or where worker threads have been disabled +at runtime, this setting has no effect, as DWARF reading is always +done on the main thread, and is therefore always synchronous. + @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 68144918adf..5d25b3f2422 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -736,6 +736,18 @@ show_dwarf_max_cache_age (struct ui_file *file, int from_tty, "DWARF compilation units is %s.\n"), value); } + +/* When true, wait for DWARF reading to be complete. */ +static bool dwarf_synchronous = false; + +/* "Show" callback for "maint set dwarf synchronous". */ +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 */ @@ -21885,6 +21897,21 @@ 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 whether DWARF is read synchronously."), _("\ +By default, DWARF information is read in worker threads,\n\ +and gdb will not generally wait for the reading to complete\n\ +before continuing with other work, for example presenting a\n\ +prompt to the user.\n\ +Enabling this setting will cause the DWARF reader to always wait\n\ +for debug info processing to be finished 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."), _("\ -- 2.41.0