Turn off threaded minsym demangling by default
authorChristian Biesinger <cbiesinger@google.com>
Tue, 19 Nov 2019 02:48:36 +0000 (20:48 -0600)
committerChristian Biesinger <cbiesinger@google.com>
Wed, 27 Nov 2019 21:38:23 +0000 (15:38 -0600)
Per discussion on gdb-patches with Joel, this patch turns off multihreaded
symbol loading by default. It can be turned on using:
  maint set worker-threads unlimited

To keep the behavior as close as possible to the old code, it still
calls symbol_set_names in the old place if n_worker_threads is 0.

gdb/ChangeLog:

2019-11-27  Christian Biesinger  <cbiesinger@google.com>

* maint.c (n_worker_threads): Default to 0.
(worker_threads_disabled): New function.
* maint.h (worker_threads_disabled): New function.
* minsyms.c (minimal_symbol_reader::record_full): Call symbol_set_names
here if worker_threads_disabled () is true.
(minimal_symbol_reader::install): Skip all threading if
worker_threads_disabled () is true.

Change-Id: I92ba4f6bbf07363189666327cad452d6b9c8e01d

gdb/ChangeLog
gdb/maint.c
gdb/maint.h
gdb/minsyms.c

index 64c8ab52cf1ddfbf252e2839e4273207e461eb6a..3033cf6455a8791e796c4c7c3ac8e7d914e534de 100644 (file)
@@ -1,3 +1,13 @@
+2019-11-27  Christian Biesinger  <cbiesinger@google.com>
+
+       * maint.c (n_worker_threads): Default to 0.
+       (worker_threads_disabled): New function.
+       * maint.h (worker_threads_disabled): New function.
+       * minsyms.c (minimal_symbol_reader::record_full): Call symbol_set_names
+       here if worker_threads_disabled () is true.
+       (minimal_symbol_reader::install): Skip all threading if
+       worker_threads_disabled () is true.
+
 2019-11-27  Christian Biesinger  <cbiesinger@google.com>
 
        * minsyms.c (add_minsym_to_hash_table): Use a previously computed
index 7ab3fdb64c167faf28e92339159daa57806594da..dbc949a61c0a69d7b0c7c5925942f6b3583d97f3 100644 (file)
@@ -845,7 +845,12 @@ maintenance_set_profile_cmd (const char *args, int from_tty,
 }
 #endif
 
-static int n_worker_threads = -1;
+static int n_worker_threads = 0;
+
+bool worker_threads_disabled ()
+{
+  return n_worker_threads == 0;
+}
 
 /* Update the thread pool for the desired number of threads.  */
 static void
index 827964d825324e1927f6544f956e7f62a0dd16b6..cbaf9deaa8832620d5ee49efdd2dd678d9fcec0e 100644 (file)
@@ -26,6 +26,8 @@ extern void set_per_command_time (int);
 
 extern void set_per_command_space (int);
 
+extern bool worker_threads_disabled ();
+
 /* Records a run time and space usage to be used as a base for
    reporting elapsed time or change in space.  */
 
index 94240c9955e1b873bf2e5d6234f6cd87a70a56bb..4f7260b3803fa0a89fc4b7bef6cec3885b2dcebe 100644 (file)
@@ -54,6 +54,7 @@
 #include <algorithm>
 #include "safe-ctype.h"
 #include "gdbsupport/parallel-for.h"
+#include "maint.h"
 
 #if CXX_STD_THREAD
 #include <mutex>
@@ -1137,6 +1138,15 @@ minimal_symbol_reader::record_full (gdb::string_view name,
   else
     msymbol->name = name.data ();
 
+  if (worker_threads_disabled ())
+    {
+      /* To keep our behavior as close as possible to the previous non-threaded
+        behavior for GDB 9.1, we call symbol_set_names here when threads
+        are disabled.  */
+      symbol_set_names (msymbol, msymbol->name, false, m_objfile->per_bfd);
+      msymbol->name_set = 1;
+    }
+
   SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
   MSYMBOL_SECTION (msymbol) = section;
 
@@ -1407,10 +1417,12 @@ minimal_symbol_reader::install ()
                     (msym, demangled_name,
                      &m_objfile->per_bfd->storage_obstack);
                   msym->name_set = 1;
-
-                  hash_values[idx].mangled_name_hash
-                    = fast_hash (msym->name, hash_values[idx].name_length);
                 }
+              /* This mangled_name_hash computation has to be outside of
+                 the name_set check, or symbol_set_names below will
+                 be called with an invalid hash value.  */
+              hash_values[idx].mangled_name_hash
+                = fast_hash (msym->name, hash_values[idx].name_length);
               hash_values[idx].minsym_hash
                 = msymbol_hash (msym->linkage_name ());
               /* We only use this hash code if the search name differs
This page took 0.03266 seconds and 4 git commands to generate.