gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / sparc-sol2-tdep.c
index b1255b672d605257c1b111b7f123c718e0ea80a3..2df66d512cef6b9e18513b219a46bdb8f222c4e6 100644 (file)
@@ -1,7 +1,6 @@
 /* Target-dependent code for Solaris SPARC.
 
-   Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "objfiles.h"
 #include "osabi.h"
 #include "regcache.h"
+#include "regset.h"
 #include "target.h"
 #include "trad-frame.h"
 
-#include "gdb_assert.h"
-#include "gdb_string.h"
-
 #include "sol2-tdep.h"
 #include "sparc-tdep.h"
 #include "solib-svr4.h"
 
 /* From <sys/regset.h>.  */
-const struct sparc_gregset sparc32_sol2_gregset =
+const struct sparc_gregmap sparc32_sol2_gregmap =
 {
   32 * 4,                      /* %psr */
   33 * 4,                      /* %pc */
@@ -48,6 +45,58 @@ const struct sparc_gregset sparc32_sol2_gregset =
   1 * 4,                       /* %g1 */
   16 * 4,                      /* %l0 */
 };
+
+const struct sparc_fpregmap sparc32_sol2_fpregmap =
+{
+  0 * 4,                       /* %f0 */
+  33 * 4,                      /* %fsr */
+};
+
+static void
+sparc32_sol2_supply_core_gregset (const struct regset *regset,
+                                 struct regcache *regcache,
+                                 int regnum, const void *gregs, size_t len)
+{
+  sparc32_supply_gregset (&sparc32_sol2_gregmap, regcache, regnum, gregs);
+}
+
+static void
+sparc32_sol2_collect_core_gregset (const struct regset *regset,
+                                  const struct regcache *regcache,
+                                  int regnum, void *gregs, size_t len)
+{
+  sparc32_collect_gregset (&sparc32_sol2_gregmap, regcache, regnum, gregs);
+}
+
+static void
+sparc32_sol2_supply_core_fpregset (const struct regset *regset,
+                                  struct regcache *regcache,
+                                  int regnum, const void *fpregs, size_t len)
+{
+  sparc32_supply_fpregset (&sparc32_sol2_fpregmap, regcache, regnum, fpregs);
+}
+
+static void
+sparc32_sol2_collect_core_fpregset (const struct regset *regset,
+                                   const struct regcache *regcache,
+                                   int regnum, void *fpregs, size_t len)
+{
+  sparc32_collect_fpregset (&sparc32_sol2_fpregmap, regcache, regnum, fpregs);
+}
+
+static const struct regset sparc32_sol2_gregset =
+  {
+    NULL,
+    sparc32_sol2_supply_core_gregset,
+    sparc32_sol2_collect_core_gregset
+  };
+
+static const struct regset sparc32_sol2_fpregset =
+  {
+    NULL,
+    sparc32_sol2_supply_core_fpregset,
+    sparc32_sol2_collect_core_fpregset
+  };
 \f
 
 /* The Solaris signal trampolines reside in libc.  For normal signals,
@@ -57,7 +106,7 @@ const struct sparc_gregset sparc32_sol2_gregset =
    `ucontext_t', which has a member `uc_mcontext' that contains the
    saved registers.  Incidentally, the kernel passes the `ucontext_t'
    pointer as the third argument of the signal trampoline too, and
-   `sigacthandler' simply passes it on. However, if you link your
+   `sigacthandler' simply passes it on.  However, if you link your
    program with "-L/usr/ucblib -R/usr/ucblib -lucb", the function
    `ucbsigvechandler' will be used, which invokes the using the BSD
    convention, where the third argument is a pointer to an instance of
@@ -67,7 +116,7 @@ const struct sparc_gregset sparc32_sol2_gregset =
    ignore this.  */
 
 int
-sparc_sol2_pc_in_sigtramp (CORE_ADDR pc, char *name)
+sparc_sol2_pc_in_sigtramp (CORE_ADDR pc, const char *name)
 {
   return (name && (strcmp (name, "sigacthandler") == 0
                   || strcmp (name, "ucbsigvechandler") == 0
@@ -83,7 +132,7 @@ sparc32_sol2_sigtramp_frame_cache (struct frame_info *this_frame,
   int regnum;
 
   if (*this_cache)
-    return *this_cache;
+    return (struct sparc_frame_cache *) *this_cache;
 
   cache = sparc_frame_cache (this_frame, this_cache);
   gdb_assert (cache == *this_cache);
@@ -93,7 +142,8 @@ sparc32_sol2_sigtramp_frame_cache (struct frame_info *this_frame,
   /* The third argument is a pointer to an instance of `ucontext_t',
      which has a member `uc_mcontext' that contains the saved
      registers.  */
-  regnum = (cache->frameless_p ? SPARC_O2_REGNUM : SPARC_I2_REGNUM);
+  regnum =
+    (cache->copied_regs_mask & 0x04) ? SPARC_I2_REGNUM : SPARC_O2_REGNUM;
   mcontext_addr = get_frame_register_unsigned (this_frame, regnum) + 40;
 
   cache->saved_regs[SPARC32_PSR_REGNUM].addr = mcontext_addr + 0 * 4;
@@ -152,7 +202,7 @@ sparc32_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
                                     void **this_cache)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
-  char *name;
+  const char *name;
 
   find_pc_partial_function (pc, &name, NULL, NULL);
   if (sparc_sol2_pc_in_sigtramp (pc, name))
@@ -164,6 +214,7 @@ sparc32_sol2_sigtramp_frame_sniffer (const struct frame_unwind *self,
 static const struct frame_unwind sparc32_sol2_sigtramp_frame_unwind =
 {
   SIGTRAMP_FRAME,
+  default_frame_unwind_stop_reason,
   sparc32_sol2_sigtramp_frame_this_id,
   sparc32_sol2_sigtramp_frame_prev_register,
   NULL,
@@ -172,8 +223,8 @@ static const struct frame_unwind sparc32_sol2_sigtramp_frame_unwind =
 
 /* Unglobalize NAME.  */
 
-char *
-sparc_sol2_static_transform_name (char *name)
+const char *
+sparc_sol2_static_transform_name (const char *name)
 {
   /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop,
      SunPRO) convert file static variables into global values, a
@@ -183,17 +234,17 @@ sparc_sol2_static_transform_name (char *name)
      globalization prefix is followed by the function name (nested
      static variables within a function are supposed to generate a
      warning message, and are left alone).  The procedure is
-     documented in the Stabs Interface Manual, which is distrubuted
+     documented in the Stabs Interface Manual, which is distributed
      with the compilers, although version 4.0 of the manual seems to
      be incorrect in some places, at least for SPARC.  The
      globalization prefix is encoded into an N_OPT stab, with the form
      "G=<prefix>".  The globalization prefix always seems to start
-     with a dollar sign '$'; a dot '.' is used as a seperator.  So we
+     with a dollar sign '$'; a dot '.' is used as a separator.  So we
      simply strip everything up until the last dot.  */
 
   if (name[0] == '$')
     {
-      char *p = strrchr (name, '.');
+      const char *p = strrchr (name, '.');
       if (p)
         return p + 1;
     }
@@ -207,6 +258,12 @@ sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
+  tdep->gregset = &sparc32_sol2_gregset;
+  tdep->sizeof_gregset = 152;
+
+  tdep->fpregset = &sparc32_sol2_fpregset;
+  tdep->sizeof_fpregset = 400;
+
   /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO)
      compiler puts out 0 instead of the address in N_SO stabs.  Starting with
      SunPRO 3.0, the compiler does this for N_FUN stabs too.  */
@@ -232,17 +289,13 @@ sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   frame_unwind_append_unwinder (gdbarch, &sparc32_sol2_sigtramp_frame_unwind);
 
-  /* Solaris encodes the pid of the inferior in regset section
-     names.  */
-  set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
+  /* How to print LWP PTIDs from core files.  */
+  set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
 }
-\f
-
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-void _initialize_sparc_sol2_tdep (void);
 
+void _initialize_sparc_sol2_tdep ();
 void
-_initialize_sparc_sol2_tdep (void)
+_initialize_sparc_sol2_tdep ()
 {
   gdbarch_register_osabi (bfd_arch_sparc, 0,
                          GDB_OSABI_SOLARIS, sparc32_sol2_init_abi);
This page took 0.03509 seconds and 4 git commands to generate.