[v4,9/9] gdb/jit: skip jit symbol lookup if already detected the symbols don't exist

Message ID b584152bd44e23cd166071a1386a717fd1727824.1595354298.git.tankut.baris.aktemur@intel.com
State New
Headers show
Series
  • Handling multiple JITers
Related show

Commit Message

H.J. Lu via Gdb-patches July 21, 2020, 6:06 p.m.
From: Simon Marchi <simon.marchi@polymtl.ca>


To detect whether an objfile is a JITer, we lookup JIT interface
symbols in the objfile.  If an objfile does not have these symbols, we
conclude that it is not a JITer.  An objfile that does not have the
symbols will never have them.  Therefore, once we do a lookup and find
out that the objfile does not have JIT symbols, just set a flag so
that we can skip symbol lookup for that objfile the next time we reset
JIT breakpoints.

gdb/ChangeLog:
2020-07-14  Simon Marchi  <simon.marchi@polymtl.ca>
	    Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* objfiles.h (struct objfile) <skip_jit_symbol_lookup>: New field.
	* jit.c (jit_breakpoint_re_set_internal): Use the
	`skip_jit_symbol_lookup` field.
---
 gdb/jit.c      | 15 +++++++++++++--
 gdb/objfiles.h |  6 ++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

-- 
2.17.1

Patch

diff --git a/gdb/jit.c b/gdb/jit.c
index 4fe2acc2f94..024c66e7add 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -893,19 +893,30 @@  jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
 {
   for (objfile *the_objfile : pspace->objfiles ())
     {
+      if (the_objfile->skip_jit_symbol_lookup)
+	continue;
+
       /* 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);
       if (reg_symbol.minsym == NULL
 	  || BMSYMBOL_VALUE_ADDRESS (reg_symbol) == 0)
-	continue;
+	{
+	  /* No need to repeat the lookup the next time.  */
+	  the_objfile->skip_jit_symbol_lookup = true;
+	  continue;
+	}
 
       bound_minimal_symbol desc_symbol
 	= lookup_minimal_symbol (jit_descriptor_name, NULL, the_objfile);
       if (desc_symbol.minsym == NULL
 	  || BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0)
-	continue;
+	{
+	  /* No need to repeat the lookup the next time.  */
+	  the_objfile->skip_jit_symbol_lookup = true;
+	  continue;
+	}
 
       jiter_objfile_data *objf_data
 	= get_jiter_objfile_data (reg_symbol.objfile);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 3fbc6da0796..549977ad257 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -706,6 +706,12 @@  struct objfile
   /* JIT-related data for this objfile, if the objfile is JITed;
      that is, it was produced by a JITer.  */
   std::unique_ptr<jited_objfile_data> jited_data = nullptr;
+
+  /* A flag that is set to true if the JIT interface symbols are not
+     found in this objfile, so that we can skip the symbol lookup the
+     next time.  If an objfile does not have the symbols, it will
+     never have them.  */
+  bool skip_jit_symbol_lookup = false;
 };
 
 /* A deleter for objfile.  */