gdbsupport: allow passing format string to scoped_debug_start_end
[deliverable/binutils-gdb.git] / gdb / amd64-obsd-tdep.c
index 7c79e44bdea93cbffd1d0863de12f3424fb4588e..cdb09d0272bcae309b6baa5e04d76a99255b1ab0 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for OpenBSD/amd64.
 
-   Copyright (C) 2003-2016 Free Software Foundation, Inc.
+   Copyright (C) 2003-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "obsd-tdep.h"
 #include "amd64-tdep.h"
 #include "i387-tdep.h"
+#include "gdbsupport/x86-xstate.h"
 #include "solib-svr4.h"
 #include "bsd-uthread.h"
 
-/* Support for core dumps.  */
-
-static void
-amd64obsd_supply_regset (const struct regset *regset,
-                        struct regcache *regcache, int regnum,
-                        const void *regs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-
-  gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE);
-
-  i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
-  amd64_supply_fxsave (regcache, regnum,
-                      ((const gdb_byte *)regs) + tdep->sizeof_gregset);
-}
-
-static const struct regset amd64obsd_combined_regset =
-  {
-    NULL, amd64obsd_supply_regset, NULL
-  };
-
-static void
-amd64obsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
-                                       iterate_over_regset_sections_cb *cb,
-                                       void *cb_data,
-                                       const struct regcache *regcache)
-{
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-
-  /* OpenBSD core dumps don't use seperate register sets for the
-     general-purpose and floating-point registers.  */
-
-  cb (".reg", tdep->sizeof_gregset + I387_SIZEOF_FXSAVE,
-      &amd64obsd_combined_regset, NULL, cb_data);
-}
-\f
-
 /* Support for signal handlers.  */
 
 /* Default page size.  */
@@ -115,7 +78,7 @@ amd64obsd_sigtramp_p (struct frame_info *this_frame)
 
   /* If we can't read the instructions at START_PC, return zero.  */
   buf = (gdb_byte *) alloca ((sizeof sigreturn) + 1);
-  if (!safe_frame_unwind_memory (this_frame, start_pc + 6, buf, buflen))
+  if (!safe_frame_unwind_memory (this_frame, start_pc + 6, {buf, buflen}))
     return 0;
 
   /* Check for sigreturn(2).  Depending on how the assembler encoded
@@ -143,11 +106,11 @@ amd64obsd_sigcontext_addr (struct frame_info *this_frame)
   /* The %rsp register points at `struct sigcontext' upon entry of a
      signal trampoline.  The relevant part of the trampoline is
 
-        call    *%rax
-        movq    %rsp, %rdi
-        pushq   %rdi
-        movq    $SYS_sigreturn,%rax
-        int     $0x80
+       call    *%rax
+       movq    %rsp, %rdi
+       pushq   %rdi
+       movq    $SYS_sigreturn,%rax
+       int     $0x80
 
      (see /usr/src/sys/arch/amd64/amd64/locore.S).  The `pushq'
      instruction clobbers %rsp, but its value is saved in `%rdi'.  */
@@ -258,7 +221,7 @@ static void
 amd64obsd_supply_uthread (struct regcache *regcache,
                          int regnum, CORE_ADDR addr)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp_addr = addr + AMD64OBSD_UTHREAD_RSP_OFFSET;
   CORE_ADDR sp = 0;
@@ -275,10 +238,10 @@ amd64obsd_supply_uthread (struct regcache *regcache,
       sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
 
       /* Adjust the stack pointer such that it looks as if we just
-         returned from _thread_machdep_switch.  */
+        returned from _thread_machdep_switch.  */
       offset = amd64obsd_uthread_reg_offset[AMD64_RIP_REGNUM] + 8;
       store_unsigned_integer (buf, 8, byte_order, sp + offset);
-      regcache_raw_supply (regcache, AMD64_RSP_REGNUM, buf);
+      regcache->raw_supply (AMD64_RSP_REGNUM, buf);
     }
 
   for (i = 0; i < ARRAY_SIZE (amd64obsd_uthread_reg_offset); i++)
@@ -287,13 +250,13 @@ amd64obsd_supply_uthread (struct regcache *regcache,
          && (regnum == -1 || regnum == i))
        {
          /* Fetch stack pointer from thread structure (if we didn't
-             do so already).  */
+            do so already).  */
          if (sp == 0)
            sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
 
          /* Read the saved register from the stack frame.  */
          read_memory (sp + amd64obsd_uthread_reg_offset[i], buf, 8);
-         regcache_raw_supply (regcache, i, buf);
+         regcache->raw_supply (i, buf);
        }
     }
 }
@@ -302,7 +265,7 @@ static void
 amd64obsd_collect_uthread (const struct regcache *regcache,
                           int regnum, CORE_ADDR addr)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp_addr = addr + AMD64OBSD_UTHREAD_RSP_OFFSET;
   CORE_ADDR sp = 0;
@@ -316,16 +279,16 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
       int offset;
 
       /* Calculate the stack pointer (frame pointer) that will be
-         stored into the thread structure.  */
+        stored into the thread structure.  */
       offset = amd64obsd_uthread_reg_offset[AMD64_RIP_REGNUM] + 8;
-      regcache_raw_collect (regcache, AMD64_RSP_REGNUM, buf);
+      regcache->raw_collect (AMD64_RSP_REGNUM, buf);
       sp = extract_unsigned_integer (buf, 8, byte_order) - offset;
 
       /* Store the stack pointer.  */
       write_memory_unsigned_integer (sp_addr, 8, byte_order, sp);
 
       /* The stack pointer was (potentially) modified.  Make sure we
-         build a proper stack frame.  */
+        build a proper stack frame.  */
       regnum = -1;
     }
 
@@ -335,12 +298,12 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
          && (regnum == -1 || regnum == i))
        {
          /* Fetch stack pointer from thread structure (if we didn't
-             calculate it already).  */
+            calculate it already).  */
          if (sp == 0)
            sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
 
          /* Write the register into the stack frame.  */
-         regcache_raw_collect (regcache, i, buf);
+         regcache->raw_collect (i, buf);
          write_memory (sp + amd64obsd_uthread_reg_offset[i], buf, 8);
        }
     }
@@ -457,7 +420,8 @@ amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-  amd64_init_abi (info, gdbarch);
+  amd64_init_abi (info, gdbarch,
+                 amd64_target_description (X86_XSTATE_SSE_MASK, true));
   obsd_init_abi (info, gdbarch);
 
   /* Initialize general-purpose register set details.  */
@@ -484,31 +448,13 @@ amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   frame_unwind_prepend_unwinder (gdbarch, &amd64obsd_trapframe_unwind);
 }
 
-/* Traditional (a.out) NetBSD-style core dumps.  */
-
-static void
-amd64obsd_core_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
-{
-  amd64obsd_init_abi (info, gdbarch);
-
-  set_gdbarch_iterate_over_regset_sections
-    (gdbarch, amd64obsd_iterate_over_regset_sections);
-}
-\f
-
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-void _initialize_amd64obsd_tdep (void);
-
+void _initialize_amd64obsd_tdep ();
 void
-_initialize_amd64obsd_tdep (void)
+_initialize_amd64obsd_tdep ()
 {
   /* The OpenBSD/amd64 native dependent code makes this assumption.  */
   gdb_assert (ARRAY_SIZE (amd64obsd_r_reg_offset) == AMD64_NUM_GREGS);
 
   gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
-                         GDB_OSABI_OPENBSD_ELF, amd64obsd_init_abi);
-
-  /* OpenBSD uses traditional (a.out) NetBSD-style core dumps.  */
-  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
-                         GDB_OSABI_NETBSD_AOUT, amd64obsd_core_init_abi);
+                         GDB_OSABI_OPENBSD, amd64obsd_init_abi);
 }
This page took 0.028781 seconds and 4 git commands to generate.