]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add "maint set dwarf synchronous"
authorTom Tromey <tom@tromey.com>
Sat, 21 Oct 2023 21:22:09 +0000 (15:22 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 9 Jan 2024 01:40:21 +0000 (18:40 -0700)
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.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
gdb/NEWS
gdb/doc/gdb.texinfo
gdb/dwarf2/read.c

index 11cd6c0663e2ee7b368b128ecfdedd0e62d6e507..96a27be0fb2bdd45affe738046b94f1484fbff06 100644 (file)
--- 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
index 4ada257d25676617d9ed9bd4e39d690b212de8ab..8e5922f81cdc29f8fe2c95067481d3538937187a 100644 (file)
@@ -41833,6 +41833,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
index eef0b066a72cf068bce9716c25e6cfff7f977c3f..507b1526b89e95d9f6c9e82c054aa0cb97163725 100644 (file)
@@ -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);
+}
 \f
 /* local function prototypes */
 
@@ -21938,6 +21950,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."), _("\