From patchwork Tue Nov 19 03:00:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36024 Received: (qmail 125855 invoked by alias); 19 Nov 2019 03:00:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 125817 invoked by uid 89); 19 Nov 2019 03:00:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Nov 2019 03:00:39 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id C87C12041E; Mon, 18 Nov 2019 22:00:37 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 75845202D0; Mon, 18 Nov 2019 22:00:32 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 5CAF52816F; Mon, 18 Nov 2019 22:00:32 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Mon, 18 Nov 2019 22:00:32 -0500 From: "Christian Biesinger (Code Review)" To: gdb-patches@sourceware.org Cc: Christian Biesinger Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Turn off threaded minsym demangling by default X-Gerrit-Change-Id: I92ba4f6bbf07363189666327cad452d6b9c8e01d X-Gerrit-Change-Number: 687 X-Gerrit-ChangeURL: X-Gerrit-Commit: 2c648e5b5e8668b9cb8d9c28a1e84913da007176 References: Reply-To: cbiesinger@google.com, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/687 ...................................................................... Turn off threaded minsym demangling by default 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-18 Christian Biesinger * 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 --- M gdb/maint.c M gdb/maint.h M gdb/minsyms.c 3 files changed, 47 insertions(+), 30 deletions(-) diff --git a/gdb/maint.c b/gdb/maint.c index fce1a1c..3e14c3e 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -845,7 +845,12 @@ } #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 diff --git a/gdb/maint.h b/gdb/maint.h index 827964d..cbaf9de 100644 --- a/gdb/maint.h +++ b/gdb/maint.h @@ -26,6 +26,8 @@ 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. */ diff --git a/gdb/minsyms.c b/gdb/minsyms.c index f9d1172..b59b96d 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -53,6 +53,7 @@ #include "gdbsupport/symbol.h" #include #include "safe-ctype.h" +#include "maint.h" #include "gdbsupport/parallel-for.h" #if CXX_STD_THREAD @@ -1139,6 +1140,12 @@ 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); + SET_MSYMBOL_VALUE_ADDRESS (msymbol, address); MSYMBOL_SECTION (msymbol) = section; @@ -1364,43 +1371,46 @@ m_objfile->per_bfd->minimal_symbol_count = mcount; m_objfile->per_bfd->msymbols = std::move (msym_holder); + if (!worker_threads_disabled ()) + { #if CXX_STD_THREAD - /* Mutex that is used when modifying or accessing the demangled - hash table. */ - std::mutex demangled_mutex; + /* Mutex that is used when modifying or accessing the demangled + hash table. */ + std::mutex demangled_mutex; #endif - msymbols = m_objfile->per_bfd->msymbols.get (); - gdb::parallel_for_each - (&msymbols[0], &msymbols[mcount], - [&] (minimal_symbol *start, minimal_symbol *end) - { - for (minimal_symbol *msym = start; msym < end; ++msym) + msymbols = m_objfile->per_bfd->msymbols.get (); + gdb::parallel_for_each + (&msymbols[0], &msymbols[mcount], + [&] (minimal_symbol *start, minimal_symbol *end) { - if (!msym->name_set) + for (minimal_symbol *msym = start; msym < end; ++msym) { - /* This will be freed later, by symbol_set_names. */ - char *demangled_name - = symbol_find_demangled_name (msym, msym->name); - symbol_set_demangled_name - (msym, demangled_name, - &m_objfile->per_bfd->storage_obstack); - msym->name_set = 1; + if (!msym->name_set) + { + /* This will be freed later, by symbol_set_names. */ + char *demangled_name + = symbol_find_demangled_name (msym, msym->name); + symbol_set_demangled_name + (msym, demangled_name, + &m_objfile->per_bfd->storage_obstack); + msym->name_set = 1; + } } - } - { - /* To limit how long we hold the lock, we only acquire it here - and not while we demangle the names above. */ -#if CXX_STD_THREAD - std::lock_guard guard (demangled_mutex); -#endif - for (minimal_symbol *msym = start; msym < end; ++msym) { - symbol_set_names (msym, msym->name, false, - m_objfile->per_bfd); + /* To limit how long we hold the lock, we only acquire it here + and not while we demangle the names above. */ +#if CXX_STD_THREAD + std::lock_guard guard (demangled_mutex); +#endif + for (minimal_symbol *msym = start; msym < end; ++msym) + { + symbol_set_names (msym, msym->name, false, + m_objfile->per_bfd); + } } - } - }); + }); + } build_minimal_symbol_hash_tables (m_objfile); }