2012-02-09 Valery Khromov <valery.khromov@gmail.com>
authorPedro Alves <palves@redhat.com>
Thu, 9 Feb 2012 16:06:44 +0000 (16:06 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 9 Feb 2012 16:06:44 +0000 (16:06 +0000)
PR gdb/12953
* Makefile.in (HFILES_NO_SRCDIR): Add amd64bsd-nat.h.
* amd64bsd-nat.c: Add support for debug registers (adapted from
i386bsd-nat.c).
[HAVE_PT_GETDBREGS] (amd64bsd_dr_get, amd64bsd_dr_set)
(amd64bsd_dr_set_control, amd64bsd_dr_set_addr)
(amd64bsd_dr_get_addr, amd64bsd_dr_get_status)
(amd64bsd_dr_get_control): New functions.
* amd64bsd-nat.h: New file (adapted from i386bsd-nat.h).
* amd64fbsd-nat.c: Include "amd64bsd-nat.h", "i386-nat.h".
[HAVE_PT_GETDBREGS] (_initialize_amd64fbsd_nat): Add hardware
watchpoints initialization.
* config/i386/fbsd64.mh (NATDEPFILES): Add i386-nat.o.

gdb/ChangeLog
gdb/Makefile.in
gdb/amd64bsd-nat.c
gdb/amd64bsd-nat.h [new file with mode: 0644]
gdb/amd64fbsd-nat.c
gdb/config/i386/fbsd64.mh

index 8da3f73037e6514f0d131b2c42b33d588809fd1d..ffe0946a29d39999a8e8c0626a5d74cc399b398b 100644 (file)
@@ -1,3 +1,19 @@
+2012-02-09  Valery Khromov  <valery.khromov@gmail.com>
+
+       PR gdb/12953
+       * Makefile.in (HFILES_NO_SRCDIR): Add amd64bsd-nat.h.
+       * amd64bsd-nat.c: Add support for debug registers (adapted from
+       i386bsd-nat.c).
+       [HAVE_PT_GETDBREGS] (amd64bsd_dr_get, amd64bsd_dr_set)
+       (amd64bsd_dr_set_control, amd64bsd_dr_set_addr)
+       (amd64bsd_dr_get_addr, amd64bsd_dr_get_status)
+       (amd64bsd_dr_get_control): New functions.
+       * amd64bsd-nat.h: New file (adapted from i386bsd-nat.h).
+       * amd64fbsd-nat.c: Include "amd64bsd-nat.h", "i386-nat.h".
+       [HAVE_PT_GETDBREGS] (_initialize_amd64fbsd_nat): Add hardware
+       watchpoints initialization.
+       * config/i386/fbsd64.mh (NATDEPFILES): Add i386-nat.o.
+
 2012-02-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * gdb-gdb.py (StructMainTypePrettyPrinter) <struct_field_img>: Print
index 38c93c9fcd6c87cc15988e6a776ab57c9af1621a..9f30a6182e42c7bf1b81fba60a25ea5f2244c10f 100644 (file)
@@ -761,7 +761,7 @@ common/gdb_signals.h common/gdb_thread_db.h common/i386-xstate.h \
 common/linux-ptrace.h \
 proc-utils.h arm-tdep.h ax-gdb.h ppcnbsd-tdep.h        \
 cli-out.h gdb_expat.h breakpoint.h infcall.h obsd-tdep.h \
-exec.h m32r-tdep.h osabi.h gdbcore.h solib-som.h \
+exec.h m32r-tdep.h osabi.h gdbcore.h solib-som.h amd64bsd-nat.h \
 i386bsd-nat.h xml-support.h xml-tdesc.h alphabsd-tdep.h gdb_obstack.h \
 ia64-tdep.h ada-lang.h varobj.h frv-tdep.h nto-tdep.h serial.h \
 c-lang.h d-lang.h frame.h event-loop.h block.h cli/cli-setshow.h       \
index b7283e9f614dafd2c9c03643e38ab97de79bae48..74d470d42033410ef1c31ad61d32773a2a416145 100644 (file)
@@ -125,3 +125,75 @@ amd64bsd_target (void)
   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 */
diff --git a/gdb/amd64bsd-nat.h b/gdb/amd64bsd-nat.h
new file mode 100644 (file)
index 0000000..bbceedc
--- /dev/null
@@ -0,0 +1,35 @@
+/* Native-dependent code for AMD64 BSD's.
+
+   Copyright (C) 2011-2012 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
+   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,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef AMD64BSD_NAT_H
+#define AMD64BSD_NAT_H
+
+/* Low level amd64 debug register functions.  */
+
+extern void amd64bsd_dr_set_control (unsigned long control);
+
+extern void amd64bsd_dr_set_addr (int regnum, CORE_ADDR addr);
+
+extern CORE_ADDR amd64bsd_dr_get_addr (int regnum);
+
+extern unsigned long amd64bsd_dr_get_status (void);
+
+extern unsigned long amd64bsd_dr_get_control (void);
+
+#endif /* amd64bsd-nat.h */
index 79c52956fd5cd7999c87b1a6bb66711678ad6e21..ab2431cf7fad643a0c9eed8ba5db2079642587ce 100644 (file)
@@ -33,6 +33,8 @@
 #include "fbsd-nat.h"
 #include "amd64-tdep.h"
 #include "amd64-nat.h"
+#include "amd64bsd-nat.h"
+#include "i386-nat.h"
 \f
 
 /* Offset in `struct reg' where MEMBER is stored.  */
@@ -154,6 +156,20 @@ _initialize_amd64fbsd_nat (void)
 
   /* Add some extra features to the common *BSD/i386 target.  */
   t = amd64bsd_target ();
+
+#ifdef HAVE_PT_GETDBREGS
+
+  i386_use_watchpoints (t);
+
+  i386_dr_low.set_control = amd64bsd_dr_set_control;
+  i386_dr_low.set_addr = amd64bsd_dr_set_addr;
+  i386_dr_low.get_addr = amd64bsd_dr_get_addr;
+  i386_dr_low.get_status = amd64bsd_dr_get_status;
+  i386_dr_low.get_control = amd64bsd_dr_get_control;
+  i386_set_debug_register_length (8);
+
+#endif /* HAVE_PT_GETDBREGS */
+
   t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
   t->to_find_memory_regions = fbsd_find_memory_regions;
   t->to_make_corefile_notes = fbsd_make_corefile_notes;
index 2266defe6b40ae1f81ec32e2d3c022669824ab59..3f43727311fcada27c5542608b0ef5a0033d8a69 100644 (file)
@@ -1,6 +1,6 @@
 # Host: FreeBSD/amd64
 NATDEPFILES= fork-child.o inf-ptrace.o \
        fbsd-nat.o amd64-nat.o amd64bsd-nat.o amd64fbsd-nat.o \
-       bsd-kvm.o
+       bsd-kvm.o i386-nat.o
 
 LOADLIBES= -lkvm
This page took 0.031435 seconds and 4 git commands to generate.