public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 06/15] Add "maint set dwarf synchronous"
Date: Sun, 29 Oct 2023 11:35:25 -0600	[thread overview]
Message-ID: <20231029173839.471514-7-tom@tromey.com> (raw)
In-Reply-To: <20231029173839.471514-1-tom@tromey.com>

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);
+}
 \f
 /* 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."), _("\
-- 
2.41.0


  parent reply	other threads:[~2023-10-29 17:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-29 17:35 [PATCH 00/15] Index DWARF in the background Tom Tromey
2023-10-29 17:35 ` [PATCH 01/15] Add thread-safety to gdb's BFD wrappers Tom Tromey
2023-10-29 17:35 ` [PATCH 02/15] Refactor complaint thread-safety approach Tom Tromey
2023-10-29 17:35 ` [PATCH 03/15] Add quick_symbol_functions::compute_main_name Tom Tromey
2023-10-29 17:35 ` [PATCH 04/15] Add gdb::task_group Tom Tromey
2023-10-29 17:35 ` [PATCH 05/15] Move cooked_index_storage to cooked-index.h Tom Tromey
2023-10-29 17:35 ` Tom Tromey [this message]
2023-10-29 17:50   ` [PATCH 06/15] Add "maint set dwarf synchronous" Eli Zaretskii
     [not found]     ` <87v89tfz40.fsf@tromey.com>
2023-11-23  6:08       ` Eli Zaretskii
2023-10-29 17:35 ` [PATCH 07/15] Change how cooked index waits for threads Tom Tromey
2023-10-29 17:35 ` [PATCH 08/15] Do more DWARF reading in the background Tom Tromey
2023-10-29 17:35 ` [PATCH 09/15] Simplify the public DWARF API Tom Tromey
2023-10-29 17:35 ` [PATCH 10/15] Remove two quick_symbol_functions methods Tom Tromey
2023-10-29 17:35 ` [PATCH 11/15] Change current_language to be a macro Tom Tromey
2023-10-29 17:35 ` [PATCH 12/15] Lazy language setting Tom Tromey
2023-10-29 17:35 ` [PATCH 13/15] Optimize lookup_minimal_symbol_text Tom Tromey
2023-10-29 17:35 ` [PATCH 14/15] Avoid language-based lookups in startup path Tom Tromey
2023-10-29 17:35 ` [PATCH 15/15] Back out some parallel_for_each features Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231029173839.471514-7-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).