Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/gnu make gdb53 work on m68k



details:   https://anonhg.NetBSD.org/src/rev/17a36d0f0094
branches:  trunk
changeset: 552282:17a36d0f0094
user:      cl <cl%NetBSD.org@localhost>
date:      Tue Sep 23 01:52:41 2003 +0000

description:
make gdb53 work on m68k
- fix elf core register access
- add elf abi detection

diffstat:

 gnu/dist/gdb/gdb/m68k-tdep.c       |  47 +++++++++++++++++++++++++++++++------
 gnu/dist/gdb/gdb/m68knbsd-nat.c    |   2 +-
 gnu/dist/gdb/gdb/m68knbsd-tdep.c   |  37 +++++++++++++++++++++++++++++-
 gnu/usr.bin/gdb53/arch/m68k/init.c |   2 +
 4 files changed, 78 insertions(+), 10 deletions(-)

diffs (172 lines):

diff -r a2ec86e1207c -r 17a36d0f0094 gnu/dist/gdb/gdb/m68k-tdep.c
--- a/gnu/dist/gdb/gdb/m68k-tdep.c      Tue Sep 23 01:11:48 2003 +0000
+++ b/gnu/dist/gdb/gdb/m68k-tdep.c      Tue Sep 23 01:52:41 2003 +0000
@@ -28,6 +28,7 @@
 #include "inferior.h"
 #include "regcache.h"
 #include "arch-utils.h"
+#include "osabi.h"
 
 
 #define P_LINKL_FP     0x480e
@@ -96,6 +97,12 @@
 #endif
 
 
+struct gdbarch_tdep
+  {
+    enum gdb_osabi osabi;
+  };
+
+
 void m68k_frame_init_saved_regs (struct frame_info *frame_info);
 
 
@@ -983,17 +990,29 @@
   };
   struct gdbarch_tdep *tdep = NULL;
   struct gdbarch *gdbarch;
+  enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
 
-  /* find a candidate among the list of pre-declared architectures. */
-  arches = gdbarch_list_lookup_by_info (arches, &info);
-  if (arches != NULL)
-    return (arches->gdbarch);
+  /* Try to determine the OS ABI of the object we are loading.  */
+  if (info.abfd != NULL)
+    {
+      osabi = gdbarch_lookup_osabi (info.abfd);
+    }
 
-#if 0
+  /* Find a candidate among extant architectures.  */
+  for (arches = gdbarch_list_lookup_by_info (arches, &info);
+       arches != NULL;
+       arches = gdbarch_list_lookup_by_info (arches->next, &info))
+    {
+      /* Make sure the ABI selection matches.  */
+      tdep = gdbarch_tdep (arches->gdbarch);
+      if (tdep && tdep->osabi == osabi)
+       return arches->gdbarch;
+    }
+
   tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
-#endif
- 
-  gdbarch = gdbarch_alloc (&info, 0);
+  gdbarch = gdbarch_alloc (&info, tdep);
+
+  tdep->osabi = osabi;
 
   set_gdbarch_long_double_format (gdbarch, &floatformat_m68881_ext);
   set_gdbarch_long_double_bit (gdbarch, 96);
@@ -1063,6 +1082,12 @@
   set_gdbarch_push_dummy_frame (gdbarch, m68k_push_dummy_frame);
   set_gdbarch_pop_frame (gdbarch, m68k_pop_frame);
 
+  /* Hook in OS ABI-specific overrides, if they have been registered.  */
+  if (osabi != GDB_OSABI_UNKNOWN)
+    {
+      gdbarch_init_osabi (info, gdbarch, osabi);
+    }
+
   return gdbarch;
 }
 
@@ -1097,7 +1122,13 @@
 static void
 m68k_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
+  if (tdep == NULL)
+    return;
+
+  fprintf_unfiltered (file, "m68k_dump_tdep: OS ABI = %s\n",
+                     gdbarch_osabi_name (tdep->osabi));
 }
 
 void
diff -r a2ec86e1207c -r 17a36d0f0094 gnu/dist/gdb/gdb/m68knbsd-nat.c
--- a/gnu/dist/gdb/gdb/m68knbsd-nat.c   Tue Sep 23 01:11:48 2003 +0000
+++ b/gnu/dist/gdb/gdb/m68knbsd-nat.c   Tue Sep 23 01:52:41 2003 +0000
@@ -239,7 +239,7 @@
   bfd_target_elf_flavour,               /* core_flavour */
   default_check_format,                 /* check_format */
   default_core_sniffer,                 /* core_sniffer */
-  fetch_core_registers,                 /* core_read_registers */
+  fetch_elfcore_registers,              /* core_read_registers */
   NULL                                  /* next */
 }; 
 
diff -r a2ec86e1207c -r 17a36d0f0094 gnu/dist/gdb/gdb/m68knbsd-tdep.c
--- a/gnu/dist/gdb/gdb/m68knbsd-tdep.c  Tue Sep 23 01:11:48 2003 +0000
+++ b/gnu/dist/gdb/gdb/m68knbsd-tdep.c  Tue Sep 23 01:52:41 2003 +0000
@@ -20,8 +20,16 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
-#include "gdbtypes.h"
+#include "gdbcore.h"
 #include "regcache.h"
+#include "target.h"
+#include "breakpoint.h"
+#include "value.h"
+#include "osabi.h"
+
+#include "nbsd-tdep.h"
+
+#include "solib-svr4.h"
 
 int
 m68knbsd_use_struct_convention (int gcc_p, struct type *type)
@@ -31,3 +39,30 @@
           || TYPE_LENGTH (type) == 4
           || TYPE_LENGTH (type) == 8);
 }
+
+static int
+m68knbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+{
+  /* FIXME: Need to add support for kernel-provided signal trampolines.  */
+  return (nbsd_pc_in_sigtramp (pc, func_name));
+}
+
+static void
+m68knbsd_init_abi (struct gdbarch_info info,
+                   struct gdbarch *gdbarch)
+{
+  /* Stop at main.  */
+  set_gdbarch_frame_chain_valid (gdbarch, generic_func_frame_chain_valid);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, m68knbsd_pc_in_sigtramp);
+
+  set_solib_svr4_fetch_link_map_offsets (gdbarch,
+                                nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
+}
+
+void
+_initialize_m68knbsd_tdep (void)
+{
+  gdbarch_register_osabi (bfd_arch_m68k, GDB_OSABI_NETBSD_ELF,
+                         m68knbsd_init_abi);
+}
diff -r a2ec86e1207c -r 17a36d0f0094 gnu/usr.bin/gdb53/arch/m68k/init.c
--- a/gnu/usr.bin/gdb53/arch/m68k/init.c        Tue Sep 23 01:11:48 2003 +0000
+++ b/gnu/usr.bin/gdb53/arch/m68k/init.c        Tue Sep 23 01:52:41 2003 +0000
@@ -26,6 +26,7 @@
 extern initialize_file_ftype _initialize_gdb_osabi;
 extern initialize_file_ftype _initialize_copying;
 extern initialize_file_ftype _initialize_m68k_tdep;
+extern initialize_file_ftype _initialize_m68knbsd_tdep;
 extern initialize_file_ftype _initialize_corelow;
 extern initialize_file_ftype _initialize_solib;
 extern initialize_file_ftype _initialize_svr4_solib;
@@ -111,6 +112,7 @@
   _initialize_gdb_osabi ();
   _initialize_copying ();
   _initialize_m68k_tdep ();
+  _initialize_m68knbsd_tdep ();
   _initialize_corelow ();
   _initialize_solib ();
   _initialize_svr4_solib ();



Home | Main Index | Thread Index | Old Index