* config/tc-hppa.c: Fix comment typos.
[deliverable/binutils-gdb.git] / gdb / procfs.c
index 55e0496bc78573bfd7635a54d6bc6fbb4af283c2..a92b849706004e906096cc083c6ef54174f03359 100644 (file)
@@ -1,5 +1,8 @@
 /* Machine independent support for SVR4 /proc (process file system) for GDB.
-   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
+   Inc.
+
    Written by Michael Snyder at Cygnus Solutions.
    Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
 
@@ -39,9 +42,11 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include <sys/syscall.h>
 #endif
 #include <sys/errno.h>
-#include <sys/wait.h>
+#include "gdb_wait.h"
 #include <signal.h>
 #include <ctype.h>
+#include "gdb_assert.h"
+#include "inflow.h"
 
 /* 
  * PROCFS.C
@@ -136,6 +141,8 @@ static int proc_find_memory_regions (int (*) (CORE_ADDR,
 
 static char * procfs_make_note_section (bfd *, int *);
 
+static int procfs_can_use_hw_breakpoint (int, int, int);
+
 struct target_ops procfs_ops;          /* the target vector */
 
 static void
@@ -168,6 +175,7 @@ init_procfs_ops (void)
   procfs_ops.to_terminal_inferior   = terminal_inferior;
   procfs_ops.to_terminal_ours_for_output = terminal_ours_for_output;
   procfs_ops.to_terminal_ours       = terminal_ours;
+  procfs_ops.to_terminal_save_ours  = terminal_save_ours;
   procfs_ops.to_terminal_info       = child_terminal_info;
 
   procfs_ops.to_find_new_threads    = procfs_find_new_threads;
@@ -183,6 +191,7 @@ init_procfs_ops (void)
   procfs_ops.to_has_thread_control  = tc_schedlock;
   procfs_ops.to_find_memory_regions = proc_find_memory_regions;
   procfs_ops.to_make_corefile_notes = procfs_make_note_section;
+  procfs_ops.to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
   procfs_ops.to_magic               = OPS_MAGIC;
 }
 
@@ -2837,6 +2846,19 @@ proc_parent_pid (procinfo *pi)
 }
 
 
+/* Convert a target address (a.k.a. CORE_ADDR) into a host address
+   (a.k.a void pointer)!  */
+
+static void *
+procfs_address_to_host_pointer (CORE_ADDR addr)
+{
+  void *ptr;
+
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
+  ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
+  return ptr;
+}
+
 /*
  * Function: proc_set_watchpoint
  *
@@ -2859,10 +2881,13 @@ proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
   prwatch_t *pwatch;
 
   pwatch            = (prwatch_t *) &arg.watch;
+  /* NOTE: cagney/2003-02-01: Even more horrible hack.  Need to
+     convert a target address into something that can be stored in a
+     native data structure.  */
 #ifdef PCAGENT /* Horrible hack: only defined on Solaris 2.6+ */
-  pwatch->pr_vaddr  = (uintptr_t) address_to_host_pointer (addr);
+  pwatch->pr_vaddr  = (uintptr_t) procfs_address_to_host_pointer (addr);
 #else
-  pwatch->pr_vaddr  = (caddr_t) address_to_host_pointer (addr);
+  pwatch->pr_vaddr  = (caddr_t) procfs_address_to_host_pointer (addr);
 #endif
   pwatch->pr_size   = len;
   pwatch->pr_wflags = wflags;
@@ -3623,6 +3648,9 @@ do_detach (int signo)
        if (!proc_clear_current_fault (pi))
          proc_warn (pi, "do_detach, clear_current_fault", __LINE__);
 
+       if (signo == 0 && !proc_clear_current_signal (pi))
+         proc_warn (pi, "do_detach, clear_current_signal", __LINE__);
+
        if (!proc_set_run_on_last_close (pi))
          proc_warn (pi, "do_detach, set_rlc", __LINE__);
       }
@@ -3677,8 +3705,8 @@ procfs_fetch_registers (int regno)
     {
       if ((regno >= 0 && regno < FP0_REGNUM) ||
          regno == PC_REGNUM  ||
-         (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
-         regno == FP_REGNUM  ||
+         (DEPRECATED_NPC_REGNUM >= 0 && regno == DEPRECATED_NPC_REGNUM) ||
+         regno == DEPRECATED_FP_REGNUM  ||
          regno == SP_REGNUM)
        return;                 /* not a floating point register */
 
@@ -3751,8 +3779,8 @@ procfs_store_registers (int regno)
     {
       if ((regno >= 0 && regno < FP0_REGNUM) ||
          regno == PC_REGNUM  ||
-         (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
-         regno == FP_REGNUM  ||
+         (DEPRECATED_NPC_REGNUM >= 0 && regno == DEPRECATED_NPC_REGNUM) ||
+         regno == DEPRECATED_FP_REGNUM  ||
          regno == SP_REGNUM)
        return;                 /* not a floating point register */
 
@@ -4582,8 +4610,6 @@ procfs_can_run (void)
 static void
 procfs_stop (void)
 {
-  extern pid_t inferior_process_group;
-
   kill (-inferior_process_group, SIGINT);
 }
 
@@ -5138,6 +5164,38 @@ procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag,
   return 0;
 }
 
+/* Return non-zero if we can set a hardware watchpoint of type TYPE.  TYPE
+   is one of bp_hardware_watchpoint, bp_read_watchpoint, bp_write_watchpoint,
+   or bp_hardware_watchpoint.  CNT is the number of watchpoints used so
+   far.
+   
+   Note:  procfs_can_use_hw_breakpoint() is not yet used by all
+   procfs.c targets due to the fact that some of them still define
+   TARGET_CAN_USE_HARDWARE_WATCHPOINT.  */
+
+static int
+procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
+{
+#ifndef TARGET_HAS_HARDWARE_WATCHPOINTS
+  return 0;
+#else
+  /* Due to the way that proc_set_watchpoint() is implemented, host
+     and target pointers must be of the same size.  If they are not,
+     we can't use hardware watchpoints.  This limitation is due to the
+     fact that proc_set_watchpoint() calls
+     procfs_address_to_host_pointer(); a close inspection of
+     procfs_address_to_host_pointer will reveal that an internal error
+     will be generated when the host and target pointer sizes are
+     different.  */
+  if (sizeof (void *) != TYPE_LENGTH (builtin_type_void_data_ptr))
+    return 0;
+
+  /* Other tests here???  */
+
+  return 1;
+#endif
+}
+
 /*
  * Function: stopped_by_watchpoint
  *
@@ -5431,8 +5489,7 @@ proc_find_memory_regions (int (*func) (CORE_ADDR,
  */
 
 static char *
-mappingflags (flags)
-     long flags;
+mappingflags (long flags)
 {
   static char asciiflags[8];
 
@@ -5462,7 +5519,6 @@ mappingflags (flags)
  * Callback function, does the actual work for 'info proc mappings'.
  */
 
-/* ARGSUSED */
 static int
 info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
 {
This page took 0.0265840000000001 seconds and 4 git commands to generate.