]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* arch-utils.c (gdbarch_info_fill): Also try core_bfd.
authorDaniel Jacobowitz <drow@false.org>
Mon, 10 Sep 2007 21:14:11 +0000 (21:14 +0000)
committerDaniel Jacobowitz <drow@false.org>
Mon, 10 Sep 2007 21:14:11 +0000 (21:14 +0000)
* corelow.c (core_read_description): New.
(init_core_ops): Set to_read_description.
* gdbarch.sh: Add gdbarch_core_read_description.
* mips-linux-tdep.c (mips_linux_core_read_description): New.
(mips_linux_init_abi): Call set_gdbarch_core_read_description.
* mips-tdep.c (mips_tdesc_gp32, mips_tdesc_gp64): New.
(mips_register_g_packet_guesses): Use them.
(_initialize_mips_tdep): Initialize them.
* mips-tdep.h (mips_tdesc_gp32, mips_tdesc_gp64): Declare.
* gdbarch.h, gdbarch.c: Regenerated.

gdb/ChangeLog
gdb/arch-utils.c
gdb/corelow.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/mips-linux-tdep.c
gdb/mips-tdep.c
gdb/mips-tdep.h

index 5ea94cc5a070ed845f4f1ea92d51bf3d5151494c..1d6d0147e9238a05fe16ff05b50656e9081e7c5c 100644 (file)
@@ -1,3 +1,17 @@
+2007-09-10  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * arch-utils.c (gdbarch_info_fill): Also try core_bfd.
+       * corelow.c (core_read_description): New.
+       (init_core_ops): Set to_read_description.
+       * gdbarch.sh: Add gdbarch_core_read_description.
+       * mips-linux-tdep.c (mips_linux_core_read_description): New.
+       (mips_linux_init_abi): Call set_gdbarch_core_read_description.
+       * mips-tdep.c (mips_tdesc_gp32, mips_tdesc_gp64): New.
+       (mips_register_g_packet_guesses): Use them.
+       (_initialize_mips_tdep): Initialize them.
+       * mips-tdep.h (mips_tdesc_gp32, mips_tdesc_gp64): Declare.
+       * gdbarch.h, gdbarch.c: Regenerated.
+
 2007-09-10  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * infrun.c (stepping_past_breakpoint): New global variable.
index 0a02d306f2faa892281caf2723a6bb11c97a6570..b9e9151a1a4e0ad3a265aca5dbcfcd519f179e8f 100644 (file)
@@ -661,6 +661,8 @@ gdbarch_info_fill (struct gdbarch_info *info)
   /* Check for the current file.  */
   if (info->abfd == NULL)
     info->abfd = exec_bfd;
+  if (info->abfd == NULL)
+    info->abfd = core_bfd;
 
   /* Check for the current target description.  */
   if (info->target_desc == NULL)
index 408e95ac62f4b36656fe306839e35b7fd37e3773..af80dc37ff69315bfbe728d398f0393b8f3d9d18 100644 (file)
@@ -635,6 +635,20 @@ core_file_thread_alive (ptid_t tid)
   return 1;
 }
 
+/* Ask the current architecture what it knows about this core file.
+   That will be used, in turn, to pick a better architecture.  This
+   wrapper could be avoided if targets got a chance to specialize
+   core_ops.  */
+
+static const struct target_desc *
+core_read_description (struct target_ops *target)
+{
+  if (gdbarch_core_read_description_p (current_gdbarch))
+    return gdbarch_core_read_description (current_gdbarch, target, core_bfd);
+
+  return NULL;
+}
+
 /* Fill in core_ops with its defined operations and properties.  */
 
 static void
@@ -656,6 +670,7 @@ init_core_ops (void)
   core_ops.to_remove_breakpoint = ignore;
   core_ops.to_create_inferior = find_default_create_inferior;
   core_ops.to_thread_alive = core_file_thread_alive;
+  core_ops.to_read_description = core_read_description;
   core_ops.to_stratum = core_stratum;
   core_ops.to_has_memory = 1;
   core_ops.to_has_stack = 1;
index e4bcaca2c8b70669d8637d759afd73af8ceb4cc1..685a87ee1287c41aa7588b0f6214d5db53ce6736 100644 (file)
@@ -230,6 +230,7 @@ struct gdbarch
   int vbit_in_delta;
   gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
   gdbarch_overlay_update_ftype *overlay_update;
+  gdbarch_core_read_description_ftype *core_read_description;
 };
 
 
@@ -352,6 +353,7 @@ struct gdbarch startup_gdbarch =
   0,  /* vbit_in_delta */
   0,  /* skip_permanent_breakpoint */
   0,  /* overlay_update */
+  0,  /* core_read_description */
   /* startup_gdbarch() */
 };
 
@@ -599,6 +601,7 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
   /* Skip verify of vbit_in_delta, invalid_p == 0 */
   /* Skip verify of skip_permanent_breakpoint, has predicate */
   /* Skip verify of overlay_update, has predicate */
+  /* Skip verify of core_read_description, has predicate */
   buf = ui_file_xstrdup (log, &dummy);
   make_cleanup (xfree, buf);
   if (strlen (buf) > 0)
@@ -713,6 +716,12 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: convert_register_p = <0x%lx>\n",
                       (long) current_gdbarch->convert_register_p);
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_core_read_description_p() = %d\n",
+                      gdbarch_core_read_description_p (current_gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: core_read_description = <0x%lx>\n",
+                      (long) current_gdbarch->core_read_description);
   fprintf_unfiltered (file,
                       "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n",
                       gdbarch_core_xfer_shared_libraries_p (current_gdbarch));
@@ -3001,6 +3010,30 @@ set_gdbarch_overlay_update (struct gdbarch *gdbarch,
   gdbarch->overlay_update = overlay_update;
 }
 
+int
+gdbarch_core_read_description_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->core_read_description != NULL;
+}
+
+const struct target_desc *
+gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->core_read_description != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_core_read_description called\n");
+  return gdbarch->core_read_description (gdbarch, target, abfd);
+}
+
+void
+set_gdbarch_core_read_description (struct gdbarch *gdbarch,
+                                   gdbarch_core_read_description_ftype core_read_description)
+{
+  gdbarch->core_read_description = core_read_description;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
index a573bde124420d2a4222fb004b168d23793241fa..95a2391ccc6ce681f8d39af6ee00612a875c8a2b 100644 (file)
@@ -687,6 +687,12 @@ typedef void (gdbarch_overlay_update_ftype) (struct obj_section *osect);
 extern void gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect);
 extern void set_gdbarch_overlay_update (struct gdbarch *gdbarch, gdbarch_overlay_update_ftype *overlay_update);
 
+extern int gdbarch_core_read_description_p (struct gdbarch *gdbarch);
+
+typedef const struct target_desc * (gdbarch_core_read_description_ftype) (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
+extern const struct target_desc * gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
+extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_core_read_description_ftype *core_read_description);
+
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
index 2307425c1decbc2fe8431537dcd8b876f22e2eaf..89682a3994067ff6d942ef6595eaf7d40480df9a 100755 (executable)
@@ -652,6 +652,8 @@ F::void:skip_permanent_breakpoint:struct regcache *regcache:regcache
 
 # Refresh overlay mapped state for section OSECT.
 F::void:overlay_update:struct obj_section *osect:osect
+
+M::const struct target_desc *:core_read_description:struct target_ops *target, bfd *abfd:target, abfd
 EOF
 }
 
index 96d1492a746a2eee764e72b517b9a21b93037d1f..9efe3fbb24ae5032caf5108024236d57efa7f71b 100644 (file)
@@ -573,6 +573,28 @@ static struct core_fns regset_core_fns =
   NULL                                 /* next */
 };
 
+static const struct target_desc *
+mips_linux_core_read_description (struct gdbarch *gdbarch,
+                                 struct target_ops *target,
+                                 bfd *abfd)
+{
+  asection *section = bfd_get_section_by_name (abfd, ".reg");
+  if (! section)
+    return NULL;
+
+  switch (bfd_section_size (abfd, section))
+    {
+    case sizeof (mips_elf_gregset_t):
+      return mips_tdesc_gp32;
+
+    case sizeof (mips64_elf_gregset_t):
+      return mips_tdesc_gp64;
+
+    default:
+      return NULL;
+    }
+}
+
 
 /* Check the code at PC for a dynamic linker lazy resolution stub.
    Because they aren't in the .plt section, we pattern-match on the
@@ -1160,6 +1182,9 @@ mips_linux_init_abi (struct gdbarch_info info,
 
   set_gdbarch_write_pc (gdbarch, mips_linux_write_pc);
 
+  set_gdbarch_core_read_description (gdbarch,
+                                    mips_linux_core_read_description);
+
   if (tdesc_data)
     {
       const struct tdesc_feature *feature;
index db4d9efb0bb9aab3a13711603231210b800ee5d8..acd4991102416650310223164c10b64f05829fec 100644 (file)
@@ -165,6 +165,9 @@ static int mips_debug = 0;
 #define PROPERTY_GP32 "internal: transfers-32bit-registers"
 #define PROPERTY_GP64 "internal: transfers-64bit-registers"
 
+struct target_desc *mips_tdesc_gp32;
+struct target_desc *mips_tdesc_gp64;
+
 /* MIPS specific per-architecture information */
 struct gdbarch_tdep
 {
@@ -4866,30 +4869,16 @@ global_mips_abi (void)
 static void
 mips_register_g_packet_guesses (struct gdbarch *gdbarch)
 {
-  static struct target_desc *tdesc_gp32, *tdesc_gp64;
-
-  if (tdesc_gp32 == NULL)
-    {
-      /* Create feature sets with the appropriate properties.  The values
-        are not important.  */
-
-      tdesc_gp32 = allocate_target_description ();
-      set_tdesc_property (tdesc_gp32, PROPERTY_GP32, "");
-
-      tdesc_gp64 = allocate_target_description ();
-      set_tdesc_property (tdesc_gp64, PROPERTY_GP64, "");
-    }
-
   /* If the size matches the set of 32-bit or 64-bit integer registers,
      assume that's what we've got.  */
-  register_remote_g_packet_guess (gdbarch, 38 * 4, tdesc_gp32);
-  register_remote_g_packet_guess (gdbarch, 38 * 8, tdesc_gp64);
+  register_remote_g_packet_guess (gdbarch, 38 * 4, mips_tdesc_gp32);
+  register_remote_g_packet_guess (gdbarch, 38 * 8, mips_tdesc_gp64);
 
   /* If the size matches the full set of registers GDB traditionally
      knows about, including floating point, for either 32-bit or
      64-bit, assume that's what we've got.  */
-  register_remote_g_packet_guess (gdbarch, 90 * 4, tdesc_gp32);
-  register_remote_g_packet_guess (gdbarch, 90 * 8, tdesc_gp64);
+  register_remote_g_packet_guess (gdbarch, 90 * 4, mips_tdesc_gp32);
+  register_remote_g_packet_guess (gdbarch, 90 * 8, mips_tdesc_gp64);
 
   /* Otherwise we don't have a useful guess.  */
 }
@@ -5696,6 +5685,14 @@ _initialize_mips_tdep (void)
 
   mips_pdr_data = register_objfile_data ();
 
+  /* Create feature sets with the appropriate properties.  The values
+     are not important.  */
+  mips_tdesc_gp32 = allocate_target_description ();
+  set_tdesc_property (mips_tdesc_gp32, PROPERTY_GP32, "");
+
+  mips_tdesc_gp64 = allocate_target_description ();
+  set_tdesc_property (mips_tdesc_gp64, PROPERTY_GP64, "");
+
   /* Add root prefix command for all "set mips"/"show mips" commands */
   add_prefix_cmd ("mips", no_class, set_mips_command,
                  _("Various MIPS specific commands."),
index ec3a611e5a06d49c1d794b3ce1659cece740e991..bb2a0d04bdf914698b07ade33571385e415e1627 100644 (file)
@@ -102,4 +102,9 @@ extern int mips_pc_is_mips16 (bfd_vma memaddr);
 /* Return the currently configured (or set) saved register size. */
 extern unsigned int mips_abi_regsize (struct gdbarch *gdbarch);
 
+/* Target descriptions which only indicate the size of general
+   registers.  */
+extern struct target_desc *mips_tdesc_gp32;
+extern struct target_desc *mips_tdesc_gp64;
+
 #endif /* MIPS_TDEP_H */