daily update
[deliverable/binutils-gdb.git] / gdb / amd64bsd-nat.c
index c75470c65ef5f7ba8e1c70f5461feaa18445587d..1cd9207486dff89b3193148581b1b40d26d4afe7 100644 (file)
@@ -1,12 +1,12 @@
 /* Native-dependent code for AMD64 BSD's.
 
 /* Native-dependent code for AMD64 BSD's.
 
-   Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,9 +15,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "inferior.h"
 
 #include "defs.h"
 #include "inferior.h"
@@ -34,6 +32,7 @@
 
 #include "amd64-tdep.h"
 #include "amd64-nat.h"
 
 #include "amd64-tdep.h"
 #include "amd64-nat.h"
+#include "amd64bsd-nat.h"
 #include "inf-ptrace.h"
 \f
 
 #include "inf-ptrace.h"
 \f
 
    for all registers (including the floating-point registers).  */
 
 static void
    for all registers (including the floating-point registers).  */
 
 static void
-amd64bsd_fetch_inferior_registers (struct regcache *regcache, int regnum)
+amd64bsd_fetch_inferior_registers (struct target_ops *ops,
+                                  struct regcache *regcache, int regnum)
 {
 {
-  if (regnum == -1 || amd64_native_gregset_supplies_p (regnum))
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+
+  if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
     {
       struct reg regs;
 
     {
       struct reg regs;
 
@@ -56,7 +58,7 @@ amd64bsd_fetch_inferior_registers (struct regcache *regcache, int regnum)
        return;
     }
 
        return;
     }
 
-  if (regnum == -1 || !amd64_native_gregset_supplies_p (regnum))
+  if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
     {
       struct fpreg fpregs;
 
     {
       struct fpreg fpregs;
 
@@ -72,9 +74,12 @@ amd64bsd_fetch_inferior_registers (struct regcache *regcache, int regnum)
    this for all registers (including the floating-point registers).  */
 
 static void
    this for all registers (including the floating-point registers).  */
 
 static void
-amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum)
+amd64bsd_store_inferior_registers (struct target_ops *ops,
+                                  struct regcache *regcache, int regnum)
 {
 {
-  if (regnum == -1 || amd64_native_gregset_supplies_p (regnum))
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+
+  if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
     {
       struct reg regs;
 
     {
       struct reg regs;
 
@@ -92,7 +97,7 @@ amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum)
        return;
     }
 
        return;
     }
 
-  if (regnum == -1 || !amd64_native_gregset_supplies_p (regnum))
+  if (regnum == -1 || !amd64_native_gregset_supplies_p (gdbarch, regnum))
     {
       struct fpreg fpregs;
 
     {
       struct fpreg fpregs;
 
@@ -121,3 +126,75 @@ amd64bsd_target (void)
   t->to_store_registers = amd64bsd_store_inferior_registers;
   return t;
 }
   t->to_store_registers = amd64bsd_store_inferior_registers;
   return t;
 }
+\f
+
+/* Support for debug registers.  */
+
+#ifdef HAVE_PT_GETDBREGS
+
+static unsigned long
+amd64bsd_dr_get (ptid_t ptid, int regnum)
+{
+  struct dbreg dbregs;
+
+  if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+             (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+    perror_with_name (_("Couldn't read debug registers"));
+
+  return DBREG_DRX ((&dbregs), regnum);
+}
+
+static void
+amd64bsd_dr_set (int regnum, unsigned long value)
+{
+  struct dbreg dbregs;
+
+  if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+    perror_with_name (_("Couldn't get debug registers"));
+
+  /* For some mysterious reason, some of the reserved bits in the
+     debug control register get set.  Mask these off, otherwise the
+     ptrace call below will fail.  */
+  DBREG_DRX ((&dbregs), 7) &= ~(0xffffffff0000fc00);
+
+  DBREG_DRX ((&dbregs), regnum) = value;
+
+  if (ptrace (PT_SETDBREGS, PIDGET (inferior_ptid),
+              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+    perror_with_name (_("Couldn't write debug registers"));
+}
+
+void
+amd64bsd_dr_set_control (unsigned long control)
+{
+  amd64bsd_dr_set (7, control);
+}
+
+void
+amd64bsd_dr_set_addr (int regnum, CORE_ADDR addr)
+{
+  gdb_assert (regnum >= 0 && regnum <= 4);
+
+  amd64bsd_dr_set (regnum, addr);
+}
+
+CORE_ADDR
+amd64bsd_dr_get_addr (int regnum)
+{
+  return amd64bsd_dr_get (inferior_ptid, regnum);
+}
+
+unsigned long
+amd64bsd_dr_get_status (void)
+{
+  return amd64bsd_dr_get (inferior_ptid, 6);
+}
+
+unsigned long
+amd64bsd_dr_get_control (void)
+{
+  return amd64bsd_dr_get (inferior_ptid, 7);
+}
+
+#endif /* PT_GETDBREGS */
This page took 0.025431 seconds and 4 git commands to generate.