gdb: add field::name / field::set_name
[binutils-gdb.git] / gdb / jit.c
index d10cc70222cb08870861a57d6ccb1be6ca662e6f..666262e2a05229b6e55dfbcff8d7b15449335291 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -74,6 +74,30 @@ show_jit_debug (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("JIT debugging is %s.\n"), value);
 }
 
+/* Implementation of the "maintenance info jit" command.  */
+
+static void
+maint_info_jit_cmd (const char *args, int from_tty)
+{
+  inferior *inf = current_inferior ();
+  bool printed_header = false;
+
+  /* Print a line for each JIT-ed objfile.  */
+  for (objfile *obj : inf->pspace->objfiles ())
+    {
+      if (obj->jited_data == nullptr)
+       continue;
+
+      if (!printed_header)
+       {
+         printf_filtered ("Base address of known JIT-ed objfiles:\n");
+         printed_header = true;
+       }
+
+      printf_filtered ("  %s\n", paddress (obj->arch (), obj->jited_data->addr));
+    }
+}
+
 struct jit_reader
 {
   jit_reader (struct gdb_reader_funcs *f, gdb_dlhandle_up &&h)
@@ -783,7 +807,7 @@ jit_breakpoint_deleted (struct breakpoint *b)
   if (b->type != bp_jit_event)
     return;
 
-  for (bp_location *iter = b->loc; iter != nullptr; iter = iter->next)
+  for (bp_location *iter : b->locations ())
     {
       for (objfile *objf : iter->pspace->objfiles ())
        {
@@ -807,6 +831,10 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
 {
   for (objfile *the_objfile : pspace->objfiles ())
     {
+      /* Skip separate debug objects.  */
+      if (the_objfile->separate_debug_objfile_backlink != nullptr)
+       continue;
+
       if (the_objfile->skip_jit_symbol_lookup)
        continue;
 
@@ -833,7 +861,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
        }
 
       jiter_objfile_data *objf_data
-       = get_jiter_objfile_data (reg_symbol.objfile);
+       = get_jiter_objfile_data (the_objfile);
       objf_data->register_code = reg_symbol.minsym;
       objf_data->descriptor = desc_symbol.minsym;
 
@@ -1044,6 +1072,7 @@ jit_frame_prev_register (struct frame_info *this_frame, void **cache, int reg)
 
 static const struct frame_unwind jit_frame_unwind =
 {
+  "jit",
   NORMAL_FRAME,
   default_frame_unwind_stop_reason,
   jit_frame_this_id,
@@ -1243,10 +1272,14 @@ _initialize_jit ()
                           show_jit_debug,
                           &setdebuglist, &showdebuglist);
 
-  gdb::observers::inferior_created.attach (jit_inferior_created_hook);
-  gdb::observers::inferior_execd.attach (jit_inferior_created_hook);
-  gdb::observers::inferior_exit.attach (jit_inferior_exit_hook);
-  gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted);
+  add_cmd ("jit", class_maintenance, maint_info_jit_cmd,
+          _("Print information about JIT-ed code objects."),
+          &maintenanceinfolist);
+
+  gdb::observers::inferior_created.attach (jit_inferior_created_hook, "jit");
+  gdb::observers::inferior_execd.attach (jit_inferior_created_hook, "jit");
+  gdb::observers::inferior_exit.attach (jit_inferior_exit_hook, "jit");
+  gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted, "jit");
 
   jit_gdbarch_data = gdbarch_data_register_pre_init (jit_gdbarch_data_init);
   if (is_dl_available ())