]> Git Repo - binutils.git/blobdiff - gdb/procfs.c
Fri Apr 29 14:26:35 1994 Stan Shebs ([email protected])
[binutils.git] / gdb / procfs.c
index 86d7bb7706fe7949e15ca7399e41ee10557094ea..1a23a9b502d6c7aeb08a85342ffc36e52d0f57e8 100644 (file)
@@ -2315,27 +2315,22 @@ wait_again:
        case PR_FAULTED:
          switch (what)
            {
-           case FLTPRIV:
-           case FLTILL:
-             statval = (SIGILL << 8) | 0177;
-             break;
-           case FLTBPT:
-           case FLTTRACE:
+#ifdef FLTWATCH
+           case FLTWATCH:
              statval = (SIGTRAP << 8) | 0177;
              break;
-           case FLTSTACK:
-           case FLTACCESS:
-           case FLTBOUNDS:
-             statval = (SIGSEGV << 8) | 0177;
-             break;
-           case FLTIOVF:
-           case FLTIZDIV:
-           case FLTFPE:
-             statval = (SIGFPE << 8) | 0177;
+#endif
+#ifdef FLTKWATCH
+           case FLTKWATCH:
+             statval = (SIGTRAP << 8) | 0177;
              break;
-           case FLTPAGE:               /* Recoverable page fault */
+#endif
            default:
-             error ("PIOCWSTOP, unknown why %d, what %d", why, what);
+             /* Use the signal which the kernel assigns.  This is better than
+                trying to second-guess it from the fault.  In fact, I suspect
+                that FLTACCESS can be either SIGSEGV or SIGBUS.  */
+             statval = ((pi->prstatus.pr_info.si_signo) << 8) | 0177;
+             break;
            }
          break;
        default:
@@ -3452,8 +3447,8 @@ procfs_create_inferior (exec_file, allargs, env)
 
       char *p;
       char *p1;
-      /* FIXME-maybe: might want "set path" command to replace putenv hack
-        in set_in_environ.  */
+      /* FIXME-maybe: might want "set path" command so user can change what
+        path is used from within GDB.  */
       char *path = getenv ("PATH");
       int len;
       struct stat statbuf;
@@ -3528,6 +3523,68 @@ procfs_can_run ()
 {
   return(1);
 }
+#ifdef TARGET_CAN_USE_HARDWARE_WATCHPOINT
+\f
+/* Insert a watchpoint */
+int
+procfs_set_watchpoint(pid, addr, len, rw)
+     int               pid;
+     CORE_ADDR         addr;
+     int               len;
+     int               rw;
+{
+  struct procinfo      *pi;
+  prwatch_t            wpt;
+
+  pi = find_procinfo (pid == -1 ? inferior_pid : pid, 0);
+  wpt.pr_vaddr = (caddr_t)addr;
+  wpt.pr_size = len;
+  wpt.pr_wflags = ((rw & 1) ? MA_READ : 0) | ((rw & 2) ? MA_WRITE : 0);
+  if (ioctl (pi->fd, PIOCSWATCH, &wpt) < 0)
+    {
+      if (errno == E2BIG)
+       return -1;
+      /* Currently it sometimes happens that the same watchpoint gets
+        deleted twice - don't die in this case (FIXME please) */
+      if (errno == ESRCH && len == 0)
+       return 0;
+      print_sys_errmsg (pi->pathname, errno);
+      error ("PIOCSWATCH failed");
+    }
+  return 0;
+}
+
+int
+procfs_stopped_by_watchpoint(pid)
+    int                        pid;
+{
+  struct procinfo      *pi;
+  short                what;
+  short                why;
+
+  pi = find_procinfo (pid == -1 ? inferior_pid : pid, 0);
+  if (pi->prstatus.pr_flags & (PR_STOPPED | PR_ISTOP))
+    {
+      why = pi->prstatus.pr_why;
+      what = pi->prstatus.pr_what;
+      if (why == PR_FAULTED 
+#if defined (FLTWATCH) && defined (FLTKWATCH)
+         && (what == FLTWATCH) || (what == FLTKWATCH)
+#else
+#ifdef FLTWATCH
+         && (what == FLTWATCH) 
+#endif
+#ifdef FLTKWATCH
+         && (what == FLTKWATCH)
+#endif
+#endif
+         )
+       return what;
+    }
+  return 0;
+}
+#endif
+
 \f
 struct target_ops procfs_ops = {
   "procfs",                    /* to_shortname */
This page took 0.027858 seconds and 4 git commands to generate.