This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Hardware watchpoints for UnixWare; based on snapshot 20010627


Uses new i386-nat.c generic watchpoint support.

Interface between procfs.c and i386v42-nat.c is unclean,
but I don't see how to do it better.

Code in i386v42-nat.c is pretty much a straight copy of
i386-linux-nat.c, using procfs to touch the debug regs
instead of ptrace.

-- 
John Hughes <john@Calva.COM>
 
--- ./config/i386/i386v42mp.mh.orig	Tue Mar 20 03:37:55 2001
+++ ./config/i386/i386v42mp.mh	Thu Jun 28 16:01:54 2001
@@ -15,5 +15,5 @@
 # continuation character (backslash) to extend a commented line.  As a
 # consequence, make considers subsequent tab-indented lines to be
 # some sort of error.
-NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o solib.o solib-svr4.o solib-legacy.o procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o uw-thread.o
+NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o i386v42mp-nat.o i386-nat.o solib.o solib-svr4.o solib-legacy.o procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o uw-thread.o
 
--- ./config/i386/nm-i386v42mp.h.orig	Tue Mar  6 09:21:28 2001
+++ ./config/i386/nm-i386v42mp.h	Thu Jun 28 17:57:48 2001
@@ -20,4 +20,26 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#define I386_USE_GENERIC_WATCHPOINTS
+
+#include "i386/nm-i386.h"
 #include "nm-sysv4.h"
+
+/* Provide access to the i386 hardware debugging registers.  */
+
+extern void i386v42mp_dr_set_control (unsigned long control);
+#define I386_DR_LOW_SET_CONTROL(control) \
+  i386v42mp_dr_set_control (control)
+
+extern void i386v42mp_dr_set_addr (int regnum, CORE_ADDR addr);
+#define I386_DR_LOW_SET_ADDR(regnum, addr) \
+  i386v42mp_dr_set_addr (regnum, addr)
+
+extern void i386v42mp_dr_reset_addr (int regnum);
+#define I386_DR_LOW_RESET_ADDR(regnum) \
+  i386v42mp_dr_reset_addr (regnum)
+
+extern unsigned long i386v42mp_dr_get_status (void);
+#define I386_DR_LOW_GET_STATUS() \
+  i386v42mp_dr_get_status ()
+
--- ./procfs.c.orig	Tue May 15 02:03:36 2001
+++ ./procfs.c	Thu Jun 28 15:35:28 2001
@@ -2860,6 +2860,45 @@
 #endif
 }
 
+
+#ifdef UNIXWARE
+
+/* Messy debug register interface for UW7 */
+
+pfamily_t *
+proc_family (ptid)
+    ptid_t ptid;
+{
+  procinfo *pi;
+  pi = find_procinfo_or_die (PIDGET (ptid), 0);
+  return &pi->prstatus.pr_lwp.pr_family;
+}
+
+#include <sys/uio.h>
+
+int
+proc_command (ptid, cmd, buf, len)
+    ptid_t ptid;
+    int cmd;
+    void *buf;
+    int len;
+{
+  procinfo *pi;
+  int res;
+  struct iovec iov [2];
+
+  pi = find_procinfo_or_die (PIDGET (ptid), 0);
+
+  iov [0].iov_len = sizeof cmd;
+  iov [0].iov_base = &cmd;
+  iov [1].iov_len = len;
+  iov [1].iov_base = buf;
+  
+  return writev (pi->ctl_fd, iov, 2);
+}
+
+#endif
+
 /*
  * Function: proc_iterate_over_mappings
  *
--- ./i386v42mp-nat.c.orig	Fri Jun 29 10:00:54 2001
+++ ./i386v42mp-nat.c	Thu Jun 28 18:11:49 2001
@@ -0,0 +1,99 @@
+/* Native-dependent code for SVR4.2mp Unix running on i386's, for GDB.
+   Copyright 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001
+   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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "value.h"
+#include "inferior.h"
+#include "regcache.h"
+#include "gdb_assert.h"
+
+#include <sys/procfs.h>
+#include <sys/debugreg.h>
+
+/* Hardware watchpoint support.  */
+
+/* Eurgh: */
+
+extern pfamily_t *proc_family ();
+extern int proc_command ();
+
+/* Pass the address ADDR to the inferior in the I'th debug register. */
+
+static void
+i386v42mp_dr_set (int regnum, unsigned long value)
+{
+  pfamily_t *family = proc_family (inferior_ptid);
+
+  if (!family)
+    {
+      perror_with_name ("Couldn't read debug registers");
+      return;
+    }
+  
+  family->pf_dbreg.debugreg[regnum] = value;
+  
+  if (proc_command (inferior_ptid, PCSDBREG, 
+		    &family->pf_dbreg, sizeof family->pf_dbreg) == -1)
+    {
+      perror_with_name ("Couldn't set debug registers");
+    }
+}
+
+/* Get the value of the DR6 debug status register from the inferior. */
+static unsigned long
+i386v42mp_dr_get (int regnum)
+{
+  pfamily_t *family = proc_family (inferior_ptid);
+  if (!family)
+    {
+      perror_with_name ("Couldn't read debug registers");
+      return 0;
+    }
+  return family->pf_dbreg.debugreg [regnum];
+}
+
+void
+i386v42mp_dr_set_control (unsigned long control)
+{
+  i386v42mp_dr_set (DR_CONTROL, control);
+}
+
+void
+i386v42mp_dr_set_addr (int regnum, CORE_ADDR addr)
+{
+  gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
+
+  i386v42mp_dr_set (DR_FIRSTADDR + regnum, addr);
+}
+
+void
+i386v42mp_dr_reset_addr (int regnum)
+{
+  gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
+
+  i386v42mp_dr_set (DR_FIRSTADDR + regnum, 0L);
+}
+
+unsigned long
+i386v42mp_dr_get_status (void)
+{
+  return i386v42mp_dr_get (DR_STATUS);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]