gdb/jit: move cached_code_address and jit_breakpoint to jiter_objfile_data
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 22 Jul 2020 13:56:07 +0000 (15:56 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 22 Jul 2020 13:56:07 +0000 (15:56 +0200)
This is in preparation for allowing more than one JITer objfile per
program space.  Once we do that, each JITer objfile will have its own
JIT breakpoint (on the __jit_debug_register_code function it provides).
The cached_code_address field is just the runtime / relocated address of
that symbol.

Since they are going to become JITer-objfile-specific and not
program-space-specific, move these fields from jit_program_space_data to
jiter_objfile_data.

gdb/ChangeLog:
2020-07-22  Simon Marchi  <simon.marchi@polymtl.ca>

* jit.h (struct jiter_objfile_data) <cached_code_address,
jit_breakpoint>: Move to here from ...
* jit.c (jit_program_space_data): ... here.
(jiter_objfile_data::~jiter_objfile_data): Update.
(jit_breakpoint_deleted): Update.
(jit_breakpoint_re_set_internal): Update.

gdb/ChangeLog
gdb/jit.c
gdb/jit.h

index 5d1a843d2b38432e4fa642571bcc1db2caf3e438..3a3866a44f75ffdbc1ede8776b5ce2a6052b47a5 100644 (file)
@@ -1,3 +1,12 @@
+2020-07-22  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * jit.h (struct jiter_objfile_data) <cached_code_address,
+       jit_breakpoint>: Move to here from ...
+       * jit.c (jit_program_space_data): ... here.
+       (jiter_objfile_data::~jiter_objfile_data): Update.
+       (jit_breakpoint_deleted): Update.
+       (jit_breakpoint_re_set_internal): Update.
+
 2020-07-22  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * jit.c (jiter_objfile_data::~jiter_objfile_data): Remove some
index 9ac282ae534084d61879767331e3e803560c83ce..562c76330cb84d3f70cbf389a2e54c363762db43 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -248,17 +248,6 @@ struct jit_program_space_data
      symbols.  */
 
   struct objfile *objfile = nullptr;
-
-  /* If this program space has __jit_debug_register_code, this is the
-     cached address from the minimal symbol.  This is used to detect
-     relocations requiring the breakpoint to be re-created.  */
-
-  CORE_ADDR cached_code_address = 0;
-
-  /* This is the JIT event breakpoint, or NULL if it has not been
-     set.  */
-
-  struct breakpoint *jit_breakpoint = nullptr;
 };
 
 static program_space_key<jit_program_space_data> jit_program_space_key;
@@ -273,11 +262,9 @@ jiter_objfile_data::~jiter_objfile_data ()
   gdb_assert (ps_data != nullptr);
   gdb_assert (ps_data->objfile == this->objfile);
 
-  ps_data->objfile = NULL;
-  if (ps_data->jit_breakpoint != NULL)
-    delete_breakpoint (ps_data->jit_breakpoint);
-
-  ps_data->cached_code_address = 0;
+  ps_data->objfile = nullptr;
+  if (this->jit_breakpoint != nullptr)
+    delete_breakpoint (this->jit_breakpoint);
 }
 
 /* Fetch the jiter_objfile_data associated with OBJF.  If no data exists
@@ -924,10 +911,16 @@ jit_breakpoint_deleted (struct breakpoint *b)
       struct jit_program_space_data *ps_data;
 
       ps_data = jit_program_space_key.get (iter->pspace);
-      if (ps_data != NULL && ps_data->jit_breakpoint == iter->owner)
+      if (ps_data != nullptr && ps_data->objfile != nullptr)
        {
-         ps_data->cached_code_address = 0;
-         ps_data->jit_breakpoint = NULL;
+         objfile *objf = ps_data->objfile;
+         jiter_objfile_data *jiter_data = objf->jiter_data.get ();
+
+         if (jiter_data->jit_breakpoint == iter->owner)
+           {
+             jiter_data->cached_code_address = 0;
+             jiter_data->jit_breakpoint = nullptr;
+           }
        }
     }
 }
@@ -976,16 +969,16 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch,
                        "breakpoint_addr = %s\n",
                        paddress (gdbarch, addr));
 
-  if (ps_data->cached_code_address == addr)
+  if (objf_data->cached_code_address == addr)
     return true;
 
   /* Delete the old breakpoint.  */
-  if (ps_data->jit_breakpoint != NULL)
-    delete_breakpoint (ps_data->jit_breakpoint);
+  if (objf_data->jit_breakpoint != nullptr)
+    delete_breakpoint (objf_data->jit_breakpoint);
 
   /* Put a breakpoint in the registration symbol.  */
-  ps_data->cached_code_address = addr;
-  ps_data->jit_breakpoint = create_jit_event_breakpoint (gdbarch, addr);
+  objf_data->cached_code_address = addr;
+  objf_data->jit_breakpoint = create_jit_event_breakpoint (gdbarch, addr);
 
   return true;
 }
index fcef78d49916bcdcc910e5b2115629737b1cbff5..b78c35d518478ea6f75245ceb7de3c800a2fb18d 100644 (file)
--- a/gdb/jit.h
+++ b/gdb/jit.h
@@ -86,6 +86,14 @@ struct jiter_objfile_data
 
   /* Symbol for __jit_debug_descriptor.  */
   minimal_symbol *descriptor = nullptr;
+
+  /* This is the relocated address of the __jit_debug_register_code function
+     provided by this objfile.  This is used to detect relocations changes
+     requiring the breakpoint to be re-created.  */
+  CORE_ADDR cached_code_address = 0;
+
+  /* This is the JIT event breakpoint, or nullptr if it has been deleted.  */
+  breakpoint *jit_breakpoint = nullptr;
 };
 
 /* An objfile that is the product of JIT compilation and was registered