From patchwork Sun Oct 29 17:35:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78686 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 2BC1E3875436 for ; Sun, 29 Oct 2023 17:39:58 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 081193861859 for ; Sun, 29 Oct 2023 17:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 081193861859 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 081193861859 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698601113; cv=none; b=ikFhTL7yu/NHkXZFD+ubYczcS1cZcCFimUqclNwDYX3Zzo1ausqXPrqkffy6LCGMC+h3RMahRE1aF8qLE2t41sHLJGLg21Ooli+J7KE/W5Ii+x6okYgp5ZzQawlDFMKY5jM75657JP7O9d5+Rq2btKIk+E7JUWYEwkfh35LShpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698601113; c=relaxed/simple; bh=HwXMlPqd3t+aCnl0E1gYIgEZF0MYYWZsdN28QM0u3OY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GtdQ/I+dSFGLsIsLo4+b1BEPCvx+zwKHMxjLtMmg7tqMQIkLp7Dce7ChhOBjaydiXnBTBAtYYhp2ubMTgOV8R+Nd2RcY/uV1czYvwaI6iOtq4WtcxvjJWAxDZvrtYxNXCjPxiHh4m+AuZt9Z/g2SEZmsZv4nuLA+kKpUeA03Psw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTPS id x52Jq0pQPhqFdx9k2qYvB6; Sun, 29 Oct 2023 17:38:26 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id x9k1qPgK3wuSEx9k1qrxWj; Sun, 29 Oct 2023 17:38:25 +0000 X-Authority-Analysis: v=2.4 cv=evvMc6lX c=1 sm=1 tr=0 ts=653e9891 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=bhdUkHdE2iEA:10 a=Qbun_eYptAEA:10 a=9B1M5sQIhCA5ud6T798A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=Rj2ypseyCe2zLFCQypAJZxP7i4j47Wcfp+aafvFKXxo=; b=Rsdb4MjxbzOrFAwxPC9gsWqkzs 6S+DB/aBeSmPLvu2I494tr0kqQrMEPuQvVEaLo6Kox/ZJQYKZrk/9VPm/DOaT2SVVgkAsYtMb17fO vK3/SgvNuGRdG4AT4LnqpZ23x; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:47464 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1qx9k1-000nk4-0V; Sun, 29 Oct 2023 11:38:25 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 06/15] Add "maint set dwarf synchronous" Date: Sun, 29 Oct 2023 11:35:25 -0600 Message-ID: <20231029173839.471514-7-tom@tromey.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231029173839.471514-1-tom@tromey.com> References: <20231029173839.471514-1-tom@tromey.com> MIME-Version: 1.0 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: 1qx9k1-000nk4-0V X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net (localhost.localdomain) [97.122.77.73]:47464 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfPHODzpoHUm56QWvWj6KAVG2MfTLgWBC5uftMk8qVjcf5TvPEphaO2A96PD2Gt/QYZntDKP1gK4NduXFlAYSO/9BdYHK8SUbd5hw9pZx+DPdcCB3t0BN KlzfNg65V8XWqILCePv6HLZk5BhKKgKdaIe9McYEPdFSI5C5IKZAistRXnTdrlDXi0ekAMNgI2J9nGmr5kFUA0fYSU6P/5AG9zM= X-Spam-Status: No, score=-3024.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, 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: , 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 95663433f1c..088651a359b 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". + * Python API ** New function gdb.notify_mi(NAME, DATA), that emits custom diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index db1a82ec838..78fe5a27ff5 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -41692,6 +41692,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 e8cd4496395..8ee6c6d4762 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -739,6 +739,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 */ @@ -21899,6 +21909,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."), _("\