public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 17/18] Avoid language-based lookups in startup path
Date: Sun, 12 Nov 2023 13:25:54 -0700	[thread overview]
Message-ID: <20231112-t-bg-dwarf-reading-v2-17-70fb170012ba@tromey.com> (raw)
In-Reply-To: <20231112-t-bg-dwarf-reading-v2-0-70fb170012ba@tromey.com>

The previous patches are nearly enough to enable background DWARF
reading.  However, this hack in language_defn::get_symbol_name_matcher
causes an early computation of current_language:

  /* If currently in Ada mode, and the lookup name is wrapped in
     '<...>', hijack all symbol name comparisons using the Ada
     matcher, which handles the verbatim matching.  */
  if (current_language->la_language == language_ada
      && lookup_name.ada ().verbatim_p ())
    return current_language->get_symbol_name_matcher_inner (lookup_name);

I considered various options here -- reversing the order of the
checks, or promoting the verbatim mode to not be a purely Ada feature
-- but in the end found that the few calls to this during startup
could be handled more directly.

In the JIT code, and in create_exception_master_breakpoint_hook, gdb
is really looking for a certain kind of symbol (text or data) using a
linkage name.  Changing the lookup here is clearer and probably more
efficient as well.

In create_std_terminate_master_breakpoint, the lookup can't really be
done by linkage name (it would require relying on a certain mangling
scheme, and also may trip over versioned symbols) -- but we know that
this spot is C++-specific, and so the language ought to be temporarily
set to C++ here.

After this patch, the "file" case is much faster:

    (gdb) file /tmp/gdb
    2023-10-23 13:16:54.456 - command started
    Reading symbols from /tmp/gdb...
    2023-10-23 13:16:54.520 - command finished
    Command execution time: 0.225906 (cpu), 0.064313 (wall)
---
 gdb/breakpoint.c | 4 +++-
 gdb/jit.c        | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index fe09dbcbeee..0ff36108682 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3733,6 +3733,8 @@ create_std_terminate_master_breakpoint (void)
   const char *const func_name = "std::terminate()";
 
   scoped_restore_current_program_space restore_pspace;
+  scoped_restore_current_language save_language;
+  set_language (language_cplus);
 
   for (struct program_space *pspace : program_spaces)
     {
@@ -3845,7 +3847,7 @@ create_exception_master_breakpoint_hook (objfile *objfile)
     {
       struct bound_minimal_symbol debug_hook;
 
-      debug_hook = lookup_minimal_symbol (func_name, NULL, objfile);
+      debug_hook = lookup_minimal_symbol_text (func_name, objfile);
       if (debug_hook.minsym == NULL)
 	{
 	  bp_objfile_data->exception_msym.minsym = &msym_not_found;
diff --git a/gdb/jit.c b/gdb/jit.c
index 9e8325ab803..9e256173dd6 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -880,7 +880,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
       /* Lookup the registration symbol.  If it is missing, then we
 	 assume we are not attached to a JIT.  */
       bound_minimal_symbol reg_symbol
-	= lookup_minimal_symbol (jit_break_name, nullptr, the_objfile);
+	= lookup_minimal_symbol_text (jit_break_name, the_objfile);
       if (reg_symbol.minsym == NULL
 	  || reg_symbol.value_address () == 0)
 	{
@@ -890,7 +890,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
 	}
 
       bound_minimal_symbol desc_symbol
-	= lookup_minimal_symbol (jit_descriptor_name, NULL, the_objfile);
+	= lookup_minimal_symbol_linkage (jit_descriptor_name, the_objfile);
       if (desc_symbol.minsym == NULL
 	  || desc_symbol.value_address () == 0)
 	{

-- 
2.41.0


  parent reply	other threads:[~2023-11-12 20:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 20:25 [PATCH v2 00/18] Index DWARf in the background Tom Tromey
2023-11-12 20:25 ` [PATCH v2 01/18] Don't use objfile::intern in DWO code Tom Tromey
2023-11-12 20:25 ` [PATCH v2 02/18] Pre-read DWZ section data Tom Tromey
2023-11-12 20:25 ` [PATCH v2 03/18] Add a couple of bfd_cache_close calls Tom Tromey
2023-11-12 20:25 ` [PATCH v2 04/18] Add thread-safety to gdb's BFD wrappers Tom Tromey
2023-11-12 20:25 ` [PATCH v2 05/18] Refactor complaint thread-safety approach Tom Tromey
2023-11-12 20:25 ` [PATCH v2 06/18] Add quick_symbol_functions::compute_main_name Tom Tromey
2023-11-12 20:25 ` [PATCH v2 07/18] Add gdb::task_group Tom Tromey
2023-11-12 20:25 ` [PATCH v2 08/18] Move cooked_index_storage to cooked-index.h Tom Tromey
2023-11-12 20:25 ` [PATCH v2 09/18] Add "maint set dwarf synchronous" Tom Tromey
2023-11-13 13:43   ` Eli Zaretskii
2023-11-12 20:25 ` [PATCH v2 10/18] Change how cooked index waits for threads Tom Tromey
2023-11-12 20:25 ` [PATCH v2 11/18] Do more DWARF reading in the background Tom Tromey
2023-11-13  7:15   ` Tom de Vries
2023-11-13 17:56     ` John Baldwin
2023-11-13 19:39       ` Tom de Vries
2023-11-14 17:31         ` John Baldwin
2023-11-21 14:24           ` Tom Tromey
2023-11-12 20:25 ` [PATCH v2 12/18] Simplify the public DWARF API Tom Tromey
2023-11-12 20:25 ` [PATCH v2 13/18] Remove two quick_symbol_functions methods Tom Tromey
2023-11-12 20:25 ` [PATCH v2 14/18] Change current_language to be a macro Tom Tromey
2023-11-12 20:25 ` [PATCH v2 15/18] Lazy language setting Tom Tromey
2023-11-12 20:25 ` [PATCH v2 16/18] Optimize lookup_minimal_symbol_text Tom Tromey
2023-11-12 20:25 ` Tom Tromey [this message]
2023-11-12 20:25 ` [PATCH v2 18/18] 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=20231112-t-bg-dwarf-reading-v2-17-70fb170012ba@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).