2004-02-25 Roland McGrath <roland@redhat.com>
[deliverable/binutils-gdb.git] / gdb / hppah-nat.c
index 4aec8eef92f15368caa13c4f9f66750a83775c44..ea4015a8d3201ed9aa0112763414140eef25013b 100644 (file)
@@ -1,5 +1,6 @@
 /* Native support code for HPUX PA-RISC.
 /* Native support code for HPUX PA-RISC.
-   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1998, 1999
+   Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
    Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
 #include "target.h"
 #include <sys/ptrace.h>
 #include "gdbcore.h"
 #include "target.h"
 #include <sys/ptrace.h>
 #include "gdbcore.h"
-#include <wait.h>
+#include "gdb_wait.h"
+#include "regcache.h"
+#include "gdb_string.h"
 #include <signal.h>
 
 #include <signal.h>
 
-extern CORE_ADDR text_end;
+extern int hpux_has_forked (int pid, int *childpid);
+extern int hpux_has_vforked (int pid, int *childpid);
+extern int hpux_has_execd (int pid, char **execd_pathname);
+extern int hpux_has_syscall_event (int pid, enum target_waitkind *kind,
+                                  int *syscall_id);
 
 
-static void fetch_register PARAMS ((int));
+static CORE_ADDR text_end;
 
 void
 
 void
-fetch_inferior_registers (regno)
-     int regno;
+deprecated_hpux_text_end (struct target_ops *exec_ops)
+{
+  struct section_table *p;
+
+  /* Set text_end to the highest address of the end of any readonly
+     code section.  */
+  /* FIXME: The comment above does not match the code.  The code
+     checks for sections with are either code *or* readonly.  */
+  text_end = (CORE_ADDR) 0;
+  for (p = exec_ops->to_sections; p < exec_ops->to_sections_end; p++)
+    if (bfd_get_section_flags (p->bfd, p->the_bfd_section)
+       & (SEC_CODE | SEC_READONLY))
+      {
+       if (text_end < p->endaddr)
+         text_end = p->endaddr;
+      }
+}
+
+
+static void fetch_register (int);
+
+void
+fetch_inferior_registers (int regno)
 {
   if (regno == -1)
     for (regno = 0; regno < NUM_REGS; regno++)
 {
   if (regno == -1)
     for (regno = 0; regno < NUM_REGS; regno++)
@@ -46,58 +74,132 @@ fetch_inferior_registers (regno)
     fetch_register (regno);
 }
 
     fetch_register (regno);
 }
 
+/* Our own version of the offsetof macro, since we can't assume ANSI C.  */
+#define HPPAH_OFFSETOF(type, member) ((int) (&((type *) 0)->member))
+
 /* Store our register values back into the inferior.
    If REGNO is -1, do this for all registers.
    Otherwise, REGNO specifies which register (so we can save time).  */
 
 void
 /* Store our register values back into the inferior.
    If REGNO is -1, do this for all registers.
    Otherwise, REGNO specifies which register (so we can save time).  */
 
 void
-store_inferior_registers (regno)
-     int regno;
+store_inferior_registers (int regno)
 {
 {
-  register unsigned int regaddr;
+  unsigned int regaddr;
   char buf[80];
   char buf[80];
-  register int i;
+  int i;
   unsigned int offset = U_REGS_OFFSET;
   int scratch;
 
   if (regno >= 0)
     {
   unsigned int offset = U_REGS_OFFSET;
   int scratch;
 
   if (regno >= 0)
     {
+      unsigned int addr, len, offset;
+
       if (CANNOT_STORE_REGISTER (regno))
        return;
       if (CANNOT_STORE_REGISTER (regno))
        return;
-      regaddr = register_addr (regno, offset);
-      errno = 0;
-      if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
+
+      offset = 0;
+      len = DEPRECATED_REGISTER_RAW_SIZE (regno);
+
+      /* Requests for register zero actually want the save_state's
+        ss_flags member.  As RM says: "Oh, what a hack!"  */
+      if (regno == 0)
+       {
+         save_state_t ss;
+         addr = HPPAH_OFFSETOF (save_state_t, ss_flags);
+         len = sizeof (ss.ss_flags);
+
+         /* Note that ss_flags is always an int, no matter what
+            DEPRECATED_REGISTER_RAW_SIZE(0) says.  Assuming all HP-UX
+            PA machines are big-endian, put it at the least
+            significant end of the value, and zap the rest of the
+            buffer.  */
+         offset = DEPRECATED_REGISTER_RAW_SIZE (0) - len;
+       }
+
+      /* Floating-point registers come from the ss_fpblock area.  */
+      else if (regno >= FP0_REGNUM)
+       addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock) 
+               + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (FP0_REGNUM)));
+
+      /* Wide registers come from the ss_wide area.
+        I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
+        between ss_wide and ss_narrow than to use the raw register size.
+        But checking ss_flags would require an extra ptrace call for
+        every register reference.  Bleah.  */
+      else if (len == 8)
+       addr = (HPPAH_OFFSETOF (save_state_t, ss_wide) 
+               + DEPRECATED_REGISTER_BYTE (regno));
+
+      /* Narrow registers come from the ss_narrow area.  Note that
+        ss_narrow starts with gr1, not gr0.  */
+      else if (len == 4)
+       addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
+               + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (1)));
+      else
+       internal_error (__FILE__, __LINE__,
+                       "hppah-nat.c (write_register): unexpected register size");
+
+#ifdef GDB_TARGET_IS_HPPA_20W
+      /* Unbelieveable.  The PC head and tail must be written in 64bit hunks
+        or we will get an error.  Worse yet, the oddball ptrace/ttrace
+        layering will not allow us to perform a 64bit register store.
+
+        What a crock.  */
+      if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM && len == 8)
        {
        {
-         scratch = *(int *) &registers[REGISTER_BYTE (regno)] | 0x3;
-         call_ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
-                      scratch);
+         CORE_ADDR temp;
+
+         temp = *(CORE_ADDR *)&deprecated_registers[DEPRECATED_REGISTER_BYTE (regno)];
+
+         /* Set the priv level (stored in the low two bits of the PC.  */
+         temp |= 0x3;
+
+         ttrace_write_reg_64 (PIDGET (inferior_ptid), (CORE_ADDR)addr,
+                              (CORE_ADDR)&temp);
+
+         /* If we fail to write the PC, give a true error instead of
+            just a warning.  */
          if (errno != 0)
            {
          if (errno != 0)
            {
-             /* Error, even if attached.  Failing to write these two
-                registers is pretty serious.  */
-             sprintf (buf, "writing register number %d", regno);
-             perror_with_name (buf);
+             char *err = safe_strerror (errno);
+             char *msg = alloca (strlen (err) + 128);
+             sprintf (msg, "writing `%s' register: %s",
+                       REGISTER_NAME (regno), err);
+             perror_with_name (msg);
            }
            }
+         return;
        }
        }
-      else
-       for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
-         {
-           errno = 0;
-           call_ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
-                        *(int *) &registers[REGISTER_BYTE (regno) + i]);
-           if (errno != 0)
-             {
-               /* Warning, not error, in case we are attached; sometimes the
-                  kernel doesn't let us at the registers.  */
-               char *err = safe_strerror (errno);
-               char *msg = alloca (strlen (err) + 128);
-               sprintf (msg, "writing register %s: %s",
-                        REGISTER_NAME (regno), err);
+
+      /* Another crock.  HPUX complains if you write a nonzero value to
+        the high part of IPSW.  What will it take for HP to catch a
+        clue about building sensible interfaces?  */
+     if (regno == IPSW_REGNUM && len == 8)
+       *(int *)&deprecated_registers[DEPRECATED_REGISTER_BYTE (regno)] = 0;
+#endif
+
+      for (i = 0; i < len; i += sizeof (int))
+       {
+         errno = 0;
+         call_ptrace (PT_WUREGS, PIDGET (inferior_ptid),
+                      (PTRACE_ARG3_TYPE) addr + i,
+                      *(int *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (regno) + i]);
+         if (errno != 0)
+           {
+             /* Warning, not error, in case we are attached; sometimes
+                the kernel doesn't let us at the registers. */
+             char *err = safe_strerror (errno);
+             char *msg = alloca (strlen (err) + 128);
+             sprintf (msg, "writing `%s' register: %s",
+                       REGISTER_NAME (regno), err);
+             /* If we fail to write the PC, give a true error instead of
+                just a warning.  */
+             if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
+               perror_with_name (msg);
+             else
                warning (msg);
                warning (msg);
-               return;
-             }
-           regaddr += sizeof (int);
-         }
+             return;
+           }
+       }
     }
   else
     for (regno = 0; regno < NUM_REGS; regno++)
     }
   else
     for (regno = 0; regno < NUM_REGS; regno++)
@@ -105,20 +207,16 @@ store_inferior_registers (regno)
 }
 
 
 }
 
 
-/* Our own version of the offsetof macro, since we can't assume ANSI C.  */
-#define HPPAH_OFFSETOF(type, member) ((int) (&((type *) 0)->member))
-
 /* Fetch a register's value from the process's U area.  */
 static void
 /* Fetch a register's value from the process's U area.  */
 static void
-fetch_register (regno)
-     int regno;
+fetch_register (int regno)
 {
 {
-  char buf[MAX_REGISTER_RAW_SIZE];
+  char buf[MAX_REGISTER_SIZE];
   unsigned int addr, len, offset;
   int i;
 
   offset = 0;
   unsigned int addr, len, offset;
   int i;
 
   offset = 0;
-  len = REGISTER_RAW_SIZE (regno);
+  len = DEPRECATED_REGISTER_RAW_SIZE (regno);
 
   /* Requests for register zero actually want the save_state's
      ss_flags member.  As RM says: "Oh, what a hack!"  */
 
   /* Requests for register zero actually want the save_state's
      ss_flags member.  As RM says: "Oh, what a hack!"  */
@@ -129,17 +227,17 @@ fetch_register (regno)
       len = sizeof (ss.ss_flags);
 
       /* Note that ss_flags is always an int, no matter what
       len = sizeof (ss.ss_flags);
 
       /* Note that ss_flags is always an int, no matter what
-        REGISTER_RAW_SIZE(0) says.  Assuming all HP-UX PA machines
-        are big-endian, put it at the least significant end of the
-        value, and zap the rest of the buffer.  */
-      offset = REGISTER_RAW_SIZE (0) - len;
+        DEPRECATED_REGISTER_RAW_SIZE(0) says.  Assuming all HP-UX PA
+        machines are big-endian, put it at the least significant end
+        of the value, and zap the rest of the buffer.  */
+      offset = DEPRECATED_REGISTER_RAW_SIZE (0) - len;
       memset (buf, 0, sizeof (buf));
     }
 
   /* Floating-point registers come from the ss_fpblock area.  */
   else if (regno >= FP0_REGNUM)
     addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock) 
       memset (buf, 0, sizeof (buf));
     }
 
   /* Floating-point registers come from the ss_fpblock area.  */
   else if (regno >= FP0_REGNUM)
     addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock) 
-           + (REGISTER_BYTE (regno) - REGISTER_BYTE (FP0_REGNUM)));
+           + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (FP0_REGNUM)));
 
   /* Wide registers come from the ss_wide area.
      I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
 
   /* Wide registers come from the ss_wide area.
      I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
@@ -148,16 +246,17 @@ fetch_register (regno)
      every register reference.  Bleah.  */
   else if (len == 8)
     addr = (HPPAH_OFFSETOF (save_state_t, ss_wide) 
      every register reference.  Bleah.  */
   else if (len == 8)
     addr = (HPPAH_OFFSETOF (save_state_t, ss_wide) 
-           + REGISTER_BYTE (regno));
+           + DEPRECATED_REGISTER_BYTE (regno));
 
   /* Narrow registers come from the ss_narrow area.  Note that
      ss_narrow starts with gr1, not gr0.  */
   else if (len == 4)
     addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
 
   /* Narrow registers come from the ss_narrow area.  Note that
      ss_narrow starts with gr1, not gr0.  */
   else if (len == 4)
     addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
-           + (REGISTER_BYTE (regno) - REGISTER_BYTE (1)));
+           + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (1)));
 
   else
 
   else
-    fatal ("hppa-nat.c (fetch_register): unexpected register size");
+    internal_error (__FILE__, __LINE__,
+                   "hppa-nat.c (fetch_register): unexpected register size");
 
   for (i = 0; i < len; i += sizeof (int))
     {
 
   for (i = 0; i < len; i += sizeof (int))
     {
@@ -165,7 +264,7 @@ fetch_register (regno)
       /* Copy an int from the U area to buf.  Fill the least
          significant end if len != raw_size.  */
       * (int *) &buf[offset + i] =
       /* Copy an int from the U area to buf.  Fill the least
          significant end if len != raw_size.  */
       * (int *) &buf[offset + i] =
-         call_ptrace (PT_RUREGS, inferior_pid,
+         call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) addr + i, 0);
       if (errno != 0)
        {
                       (PTRACE_ARG3_TYPE) addr + i, 0);
       if (errno != 0)
        {
@@ -197,21 +296,18 @@ fetch_register (regno)
    Returns the length copied, which is either the LEN argument or zero.
    This xfer function does not do partial moves, since child_ops
    doesn't allow memory operations to cross below us in the target stack
    Returns the length copied, which is either the LEN argument or zero.
    This xfer function does not do partial moves, since child_ops
    doesn't allow memory operations to cross below us in the target stack
-   anyway.  */
+   anyway.  TARGET is ignored.  */
 
 int
 
 int
-child_xfer_memory (memaddr, myaddr, len, write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int write;
-     struct target_ops *target;        /* ignored */
+child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+                  struct mem_attrib *mem,
+                  struct target_ops *target)
 {
 {
-  register int i;
+  int i;
   /* Round starting address down to longword boundary.  */
   /* Round starting address down to longword boundary.  */
-  register CORE_ADDR addr = memaddr & - (CORE_ADDR)(sizeof (int));
+  CORE_ADDR addr = memaddr & - (CORE_ADDR)(sizeof (int));
   /* Round ending address up; get number of longwords that makes.  */
   /* Round ending address up; get number of longwords that makes.  */
-  register int count
+  int count
   = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
 
   /* Allocate buffer of that many longwords.
   = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
 
   /* Allocate buffer of that many longwords.
@@ -222,7 +318,7 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
      this (in effect) would pile up all those alloca requests until a call
      to alloca was made from a point higher than this routine in the
      call chain.  */
      this (in effect) would pile up all those alloca requests until a call
      to alloca was made from a point higher than this routine in the
      call chain.  */
-  register int *buffer = (int *) xmalloc (count * sizeof (int));
+  int *buffer = (int *) xmalloc (count * sizeof (int));
 
   if (write)
     {
 
   if (write)
     {
@@ -231,14 +327,15 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
        {
          /* Need part of initial word -- fetch it.  */
          buffer[0] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
        {
          /* Need part of initial word -- fetch it.  */
          buffer[0] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-                                  inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+                                  PIDGET (inferior_ptid),
+                                  (PTRACE_ARG3_TYPE) addr, 0);
        }
 
       if (count > 1)           /* FIXME, avoid if even boundary */
        {
          buffer[count - 1]
            = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
        }
 
       if (count > 1)           /* FIXME, avoid if even boundary */
        {
          buffer[count - 1]
            = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-                          inferior_pid,
+                          PIDGET (inferior_ptid),
                           (PTRACE_ARG3_TYPE) (addr
                                               + (count - 1) * sizeof (int)),
                           0);
                           (PTRACE_ARG3_TYPE) (addr
                                               + (count - 1) * sizeof (int)),
                           0);
@@ -260,7 +357,7 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
          errno = 0;
          pt_request = (addr < text_end) ? PT_WIUSER : PT_WDUSER;
          pt_status = call_ptrace (pt_request,
          errno = 0;
          pt_request = (addr < text_end) ? PT_WIUSER : PT_WDUSER;
          pt_status = call_ptrace (pt_request,
-                                  inferior_pid,
+                                  PIDGET (inferior_ptid),
                                   (PTRACE_ARG3_TYPE) addr,
                                   buffer[i]);
 
                                   (PTRACE_ARG3_TYPE) addr,
                                   buffer[i]);
 
@@ -272,14 +369,14 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
              errno = 0;
              pt_request = (pt_request == PT_WIUSER) ? PT_WDUSER : PT_WIUSER;
              pt_status = call_ptrace (pt_request,
              errno = 0;
              pt_request = (pt_request == PT_WIUSER) ? PT_WDUSER : PT_WIUSER;
              pt_status = call_ptrace (pt_request,
-                                      inferior_pid,
+                                      PIDGET (inferior_ptid),
                                       (PTRACE_ARG3_TYPE) addr,
                                       buffer[i]);
 
              /* No, we still fail.  Okay, time to punt. */
              if ((pt_status == -1) && errno)
                {
                                       (PTRACE_ARG3_TYPE) addr,
                                       buffer[i]);
 
              /* No, we still fail.  Okay, time to punt. */
              if ((pt_status == -1) && errno)
                {
-                 free (buffer);
+                 xfree (buffer);
                  return 0;
                }
            }
                  return 0;
                }
            }
@@ -292,10 +389,11 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
        {
          errno = 0;
          buffer[i] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
        {
          errno = 0;
          buffer[i] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-                                  inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+                                  PIDGET (inferior_ptid),
+                                  (PTRACE_ARG3_TYPE) addr, 0);
          if (errno)
            {
          if (errno)
            {
-             free (buffer);
+             xfree (buffer);
              return 0;
            }
          QUIT;
              return 0;
            }
          QUIT;
@@ -304,80 +402,148 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
       /* Copy appropriate bytes out of the buffer.  */
       memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
     }
       /* Copy appropriate bytes out of the buffer.  */
       memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
     }
-  free (buffer);
+  xfree (buffer);
   return len;
 }
 
   return len;
 }
 
+char *saved_child_execd_pathname = NULL;
+int saved_vfork_pid;
+enum {
+  STATE_NONE,
+  STATE_GOT_CHILD,
+  STATE_GOT_EXEC,
+  STATE_GOT_PARENT,
+  STATE_FAKE_EXEC
+} saved_vfork_state = STATE_NONE;
 
 
-void
-child_post_follow_inferior_by_clone ()
+int
+child_follow_fork (int follow_child)
 {
 {
-  int status;
+  ptid_t last_ptid;
+  struct target_waitstatus last_status;
+  int has_vforked;
+  int parent_pid, child_pid;
+
+  get_last_target_status (&last_ptid, &last_status);
+  has_vforked = (last_status.kind == TARGET_WAITKIND_VFORKED);
+  parent_pid = ptid_get_pid (last_ptid);
+  child_pid = last_status.value.related_pid;
+
+  /* At this point, if we are vforking, breakpoints were already
+     detached from the child in child_wait; and the child has already
+     called execve().  If we are forking, both the parent and child
+     have breakpoints inserted.  */
+
+  if (! follow_child)
+    {
+      if (! has_vforked)
+       {
+         detach_breakpoints (child_pid);
+#ifdef SOLIB_REMOVE_INFERIOR_HOOK
+         SOLIB_REMOVE_INFERIOR_HOOK (child_pid);
+#endif
+       }
 
 
-  /* This function is used when following both the parent and child
-     of a fork.  In this case, the debugger clones itself.  The original
-     debugger follows the parent, the clone follows the child.  The
-     original detaches from the child, delivering a SIGSTOP to it to
-     keep it from running away until the clone can attach itself.
+      /* Detach from the child. */
+      printf_unfiltered ("Detaching after fork from %s\n",
+                        target_pid_to_str (pid_to_ptid (child_pid)));
+      hppa_require_detach (child_pid, 0);
+
+      /* The parent and child of a vfork share the same address space.
+        Also, on some targets the order in which vfork and exec events
+        are received for parent in child requires some delicate handling
+        of the events.
+
+        For instance, on ptrace-based HPUX we receive the child's vfork
+        event first, at which time the parent has been suspended by the
+        OS and is essentially untouchable until the child's exit or second
+        exec event arrives.  At that time, the parent's vfork event is
+        delivered to us, and that's when we see and decide how to follow
+        the vfork.  But to get to that point, we must continue the child
+        until it execs or exits.  To do that smoothly, all breakpoints
+        must be removed from the child, in case there are any set between
+        the vfork() and exec() calls.  But removing them from the child
+        also removes them from the parent, due to the shared-address-space
+        nature of a vfork'd parent and child.  On HPUX, therefore, we must
+        take care to restore the bp's to the parent before we continue it.
+        Else, it's likely that we may not stop in the expected place.  (The
+        worst scenario is when the user tries to step over a vfork() call;
+        the step-resume bp must be restored for the step to properly stop
+        in the parent after the call completes!)
+
+        Sequence of events, as reported to gdb from HPUX:
+
+        Parent        Child           Action for gdb to take
+        -------------------------------------------------------
+        1                VFORK               Continue child
+        2                EXEC
+        3                EXEC or EXIT
+        4  VFORK
+
+        Now that the child has safely exec'd or exited, we must restore
+        the parent's breakpoints before we continue it.  Else, we may
+        cause it run past expected stopping points.  */
+
+      if (has_vforked)
+       reattach_breakpoints (parent_pid);
+    }
+  else
+    {
+      /* Needed to keep the breakpoint lists in sync.  */
+      if (! has_vforked)
+       detach_breakpoints (child_pid);
 
 
-     At this point, the clone has attached to the child.  Because of
-     the SIGSTOP, we must now deliver a SIGCONT to the child, or it
-     won't behave properly. */
-  status = kill (inferior_pid, SIGCONT);
-}
+      /* Before detaching from the parent, remove all breakpoints from it. */
+      remove_breakpoints ();
 
 
+      /* Also reset the solib inferior hook from the parent. */
+#ifdef SOLIB_REMOVE_INFERIOR_HOOK
+      SOLIB_REMOVE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+#endif
 
 
-void
-child_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child)
-     int parent_pid;
-     int followed_parent;
-     int child_pid;
-     int followed_child;
-{
-  /* Are we a debugger that followed the parent of a vfork?  If so,
-     then recall that the child's vfork event was delivered to us
-     first.  And, that the parent was suspended by the OS until the
-     child's exec or exit events were received.
-
-     Upon receiving that child vfork, then, we were forced to remove
-     all breakpoints in the child and continue it so that it could
-     reach the exec or exit point.
-
-     But also recall that the parent and child of a vfork share the
-     same address space.  Thus, removing bp's in the child also
-     removed them from the parent.
-
-     Now that the child has safely exec'd or exited, we must restore
-     the parent's breakpoints before we continue it.  Else, we may
-     cause it run past expected stopping points. */
-  if (followed_parent)
-    {
-      reattach_breakpoints (parent_pid);
+      /* Detach from the parent. */
+      target_detach (NULL, 1);
+
+      /* Attach to the child. */
+      printf_unfiltered ("Attaching after fork to %s\n",
+                        target_pid_to_str (pid_to_ptid (child_pid)));
+      hppa_require_attach (child_pid);
+      inferior_ptid = pid_to_ptid (child_pid);
+
+      /* If we vforked, then we've also execed by now.  The exec will be
+        reported momentarily.  follow_exec () will handle breakpoints, so
+        we don't have to..  */
+      if (!has_vforked)
+       follow_inferior_reset_breakpoints ();
     }
 
     }
 
-  /* Are we a debugger that followed the child of a vfork?  If so,
-     then recall that we don't actually acquire control of the child
-     until after it has exec'd or exited.  */
-  if (followed_child)
+  if (has_vforked)
     {
     {
-      /* If the child has exited, then there's nothing for us to do.
-         In the case of an exec event, we'll let that be handled by
-         the normal mechanism that notices and handles exec events, in
-         resume(). */
+      /* If we followed the parent, don't try to follow the child's exec.  */
+      if (saved_vfork_state != STATE_GOT_PARENT
+         && saved_vfork_state != STATE_FAKE_EXEC)
+       fprintf_unfiltered (gdb_stdout,
+                           "hppa: post follow vfork: confused state\n");
+
+      if (! follow_child || saved_vfork_state == STATE_GOT_PARENT)
+       saved_vfork_state = STATE_NONE;
+      else
+       return 1;
     }
     }
+  return 0;
 }
 
 /* Format a process id, given PID.  Be sure to terminate
    this with a null--it's going to be printed via a "%s".  */
 char *
 }
 
 /* Format a process id, given PID.  Be sure to terminate
    this with a null--it's going to be printed via a "%s".  */
 char *
-hppa_pid_to_str (pid)
-     pid_t pid;
+child_pid_to_str (ptid_t ptid)
 {
   /* Static because address returned */
   static char buf[30];
 {
   /* Static because address returned */
   static char buf[30];
+  pid_t pid = PIDGET (ptid);
 
 
-  /* Extra NULLs for paranoia's sake */
-  sprintf (buf, "process %d\0\0\0\0", pid);
+  /* Extra NUL for paranoia's sake */
+  sprintf (buf, "process %d%c", pid, '\0');
 
   return buf;
 }
 
   return buf;
 }
@@ -388,18 +554,235 @@ hppa_pid_to_str (pid)
    Note: This is a core-gdb tid, not the actual system tid.
    See infttrace.c for details.  */
 char *
    Note: This is a core-gdb tid, not the actual system tid.
    See infttrace.c for details.  */
 char *
-hppa_tid_to_str (tid)
-     pid_t tid;
+hppa_tid_to_str (ptid_t ptid)
 {
   /* Static because address returned */
   static char buf[30];
 {
   /* Static because address returned */
   static char buf[30];
+  /* This seems strange, but when I did the ptid conversion, it looked
+     as though a pid was always being passed.  - Kevin Buettner  */
+  pid_t tid = PIDGET (ptid);
 
   /* Extra NULLs for paranoia's sake */
 
   /* Extra NULLs for paranoia's sake */
-  sprintf (buf, "system thread %d\0\0\0\0", tid);
+  sprintf (buf, "system thread %d%c", tid, '\0');
 
   return buf;
 }
 
 
   return buf;
 }
 
+/*## */
+/* Enable HACK for ttrace work.  In
+ * infttrace.c/require_notification_of_events,
+ * this is set to 0 so that the loop in child_wait
+ * won't loop.
+ */
+int not_same_real_pid = 1;
+/*## */
+
+/* Wait for child to do something.  Return pid of child, or -1 in case
+   of error; store status through argument pointer OURSTATUS.  */
+
+ptid_t
+child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
+{
+  int save_errno;
+  int status;
+  char *execd_pathname = NULL;
+  int exit_status;
+  int related_pid;
+  int syscall_id;
+  enum target_waitkind kind;
+  int pid;
+
+  if (saved_vfork_state == STATE_FAKE_EXEC)
+    {
+      saved_vfork_state = STATE_NONE;
+      ourstatus->kind = TARGET_WAITKIND_EXECD;
+      ourstatus->value.execd_pathname = saved_child_execd_pathname;
+      return inferior_ptid;
+    }
+
+  do
+    {
+      set_sigint_trap ();      /* Causes SIGINT to be passed on to the
+                                  attached process. */
+      set_sigio_trap ();
+
+      pid = ptrace_wait (inferior_ptid, &status);
+
+      save_errno = errno;
+
+      clear_sigio_trap ();
+
+      clear_sigint_trap ();
+
+      if (pid == -1)
+       {
+         if (save_errno == EINTR)
+           continue;
+
+         fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
+                             safe_strerror (save_errno));
+
+         /* Claim it exited with unknown signal.  */
+         ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
+         ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
+         return pid_to_ptid (-1);
+       }
+
+      /* Did it exit?
+       */
+      if (target_has_exited (pid, status, &exit_status))
+       {
+         /* ??rehrauer: For now, ignore this. */
+         continue;
+       }
+
+      if (!target_thread_alive (pid_to_ptid (pid)))
+       {
+         ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
+         return pid_to_ptid (pid);
+       }
+
+      if (hpux_has_forked (pid, &related_pid))
+       {
+         /* Ignore the parent's fork event.  */
+         if (pid == PIDGET (inferior_ptid))
+           {
+             ourstatus->kind = TARGET_WAITKIND_IGNORE;
+             return inferior_ptid;
+           }
+
+         /* If this is the child's fork event, report that the
+            process has forked.  */
+         if (related_pid == PIDGET (inferior_ptid))
+           {
+             ourstatus->kind = TARGET_WAITKIND_FORKED;
+             ourstatus->value.related_pid = pid;
+             return inferior_ptid;
+           }
+       }
+
+      if (hpux_has_vforked (pid, &related_pid))
+       {
+         if (pid == PIDGET (inferior_ptid))
+           {
+             if (saved_vfork_state == STATE_GOT_CHILD)
+               saved_vfork_state = STATE_GOT_PARENT;
+             else if (saved_vfork_state == STATE_GOT_EXEC)
+               saved_vfork_state = STATE_FAKE_EXEC;
+             else
+               fprintf_unfiltered (gdb_stdout,
+                                   "hppah: parent vfork: confused\n");
+           }
+         else if (related_pid == PIDGET (inferior_ptid))
+           {
+             if (saved_vfork_state == STATE_NONE)
+               saved_vfork_state = STATE_GOT_CHILD;
+             else
+               fprintf_unfiltered (gdb_stdout,
+                                   "hppah: child vfork: confused\n");
+           }
+         else
+           fprintf_unfiltered (gdb_stdout,
+                               "hppah: unknown vfork: confused\n");
+
+         if (saved_vfork_state == STATE_GOT_CHILD)
+           {
+             child_post_startup_inferior (pid_to_ptid (pid));
+             detach_breakpoints (pid);
+#ifdef SOLIB_REMOVE_INFERIOR_HOOK
+             SOLIB_REMOVE_INFERIOR_HOOK (pid);
+#endif
+             child_resume (pid_to_ptid (pid), 0, TARGET_SIGNAL_0);
+             ourstatus->kind = TARGET_WAITKIND_IGNORE;
+             return pid_to_ptid (related_pid);
+           }
+         else if (saved_vfork_state == STATE_FAKE_EXEC)
+           {
+             ourstatus->kind = TARGET_WAITKIND_VFORKED;
+             ourstatus->value.related_pid = related_pid;
+             return pid_to_ptid (pid);
+           }
+         else
+           {
+             /* We saw the parent's vfork, but we haven't seen the exec yet.
+                Wait for it, for simplicity's sake.  It should be pending.  */
+             saved_vfork_pid = related_pid;
+             ourstatus->kind = TARGET_WAITKIND_IGNORE;
+             return pid_to_ptid (pid);
+           }
+       }
+
+      if (hpux_has_execd (pid, &execd_pathname))
+       {
+         /* On HP-UX, events associated with a vforking inferior come in
+            threes: a vfork event for the child (always first), followed
+            a vfork event for the parent and an exec event for the child.
+            The latter two can come in either order.  Make sure we get
+            both.  */
+         if (saved_vfork_state != STATE_NONE)
+           {
+             if (saved_vfork_state == STATE_GOT_CHILD)
+               {
+                 saved_vfork_state = STATE_GOT_EXEC;
+                 /* On HP/UX with ptrace, the child must be resumed before
+                    the parent vfork event is delivered.  A single-step
+                    suffices.  */
+                 if (RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK ())
+                   target_resume (pid_to_ptid (pid), 1, TARGET_SIGNAL_0);
+                 ourstatus->kind = TARGET_WAITKIND_IGNORE;
+               }
+             else if (saved_vfork_state == STATE_GOT_PARENT)
+               {
+                 saved_vfork_state = STATE_FAKE_EXEC;
+                 ourstatus->kind = TARGET_WAITKIND_VFORKED;
+                 ourstatus->value.related_pid = saved_vfork_pid;
+               }
+             else
+               fprintf_unfiltered (gdb_stdout,
+                                   "hppa: exec: unexpected state\n");
+
+             saved_child_execd_pathname = execd_pathname;
+
+             return inferior_ptid;
+           }
+         
+         /* Are we ignoring initial exec events?  (This is likely because
+            we're in the process of starting up the inferior, and another
+            (older) mechanism handles those.)  If so, we'll report this
+            as a regular stop, not an exec.
+          */
+         if (inferior_ignoring_startup_exec_events)
+           {
+             inferior_ignoring_startup_exec_events--;
+           }
+         else
+           {
+             ourstatus->kind = TARGET_WAITKIND_EXECD;
+             ourstatus->value.execd_pathname = execd_pathname;
+             return pid_to_ptid (pid);
+           }
+       }
+
+      /* All we must do with these is communicate their occurrence
+         to wait_for_inferior...
+       */
+      if (hpux_has_syscall_event (pid, &kind, &syscall_id))
+       {
+         ourstatus->kind = kind;
+         ourstatus->value.syscall_id = syscall_id;
+         return pid_to_ptid (pid);
+       }
+
+      /*##  } while (pid != PIDGET (inferior_ptid)); ## *//* Some other child died or stopped */
+/* hack for thread testing */
+    }
+  while ((pid != PIDGET (inferior_ptid)) && not_same_real_pid);
+/*## */
+
+  store_waitstatus (ourstatus, status);
+  return pid_to_ptid (pid);
+}
+
 #if !defined (GDB_NATIVE_HPUX_11)
 
 /* The following code is a substitute for the infttrace.c versions used
 #if !defined (GDB_NATIVE_HPUX_11)
 
 /* The following code is a substitute for the infttrace.c versions used
@@ -424,8 +807,6 @@ startup_semaphore_t;
 
 static startup_semaphore_t startup_semaphore;
 
 
 static startup_semaphore_t startup_semaphore;
 
-extern int parent_attach_all PARAMS ((int, PTRACE_ARG3_TYPE, int));
-
 #ifdef PT_SETTRC
 /* This function causes the caller's process to be traced by its
    parent.  This is intended to be called after GDB forks itself,
 #ifdef PT_SETTRC
 /* This function causes the caller's process to be traced by its
    parent.  This is intended to be called after GDB forks itself,
@@ -447,10 +828,7 @@ extern int parent_attach_all PARAMS ((int, PTRACE_ARG3_TYPE, int));
    child_acknowledge_created_inferior.)  */
 
 int
    child_acknowledge_created_inferior.)  */
 
 int
-parent_attach_all (pid, addr, data)
-     int pid;
-     PTRACE_ARG3_TYPE addr;
-     int data;
+parent_attach_all (int pid, PTRACE_ARG3_TYPE addr, int data)
 {
   int pt_status = 0;
 
 {
   int pt_status = 0;
 
@@ -487,8 +865,7 @@ parent_attach_all (pid, addr, data)
 #endif
 
 int
 #endif
 
 int
-hppa_require_attach (pid)
-     int pid;
+hppa_require_attach (int pid)
 {
   int pt_status;
   CORE_ADDR pc;
 {
   int pt_status;
   CORE_ADDR pc;
@@ -521,9 +898,7 @@ hppa_require_attach (pid)
 }
 
 int
 }
 
 int
-hppa_require_detach (pid, signal)
-     int pid;
-     int signal;
+hppa_require_detach (int pid, int signal)
 {
   errno = 0;
   call_ptrace (PT_DETACH, pid, (PTRACE_ARG3_TYPE) 1, signal);
 {
   errno = 0;
   call_ptrace (PT_DETACH, pid, (PTRACE_ARG3_TYPE) 1, signal);
@@ -536,77 +911,48 @@ hppa_require_detach (pid, signal)
    dummy versions, which perform no useful work.  */
 
 void
    dummy versions, which perform no useful work.  */
 
 void
-hppa_enable_page_protection_events (pid)
-     int pid;
+hppa_enable_page_protection_events (int pid)
 {
 }
 
 void
 {
 }
 
 void
-hppa_disable_page_protection_events (pid)
-     int pid;
+hppa_disable_page_protection_events (int pid)
 {
 }
 
 int
 {
 }
 
 int
-hppa_insert_hw_watchpoint (pid, start, len, type)
-     int pid;
-     CORE_ADDR start;
-     LONGEST len;
-     int type;
+hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
 {
   error ("Hardware watchpoints not implemented on this platform.");
 }
 
 int
 {
   error ("Hardware watchpoints not implemented on this platform.");
 }
 
 int
-hppa_remove_hw_watchpoint (pid, start, len, type)
-     int pid;
-     CORE_ADDR start;
-     LONGEST len;
-     enum bptype type;
+hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
 {
   error ("Hardware watchpoints not implemented on this platform.");
 }
 
 int
 {
   error ("Hardware watchpoints not implemented on this platform.");
 }
 
 int
-hppa_can_use_hw_watchpoint (type, cnt, ot)
-     enum bptype type;
-     int cnt;
-     enum bptype ot;
+hppa_can_use_hw_watchpoint (int type, int cnt, int ot)
 {
   return 0;
 }
 
 int
 {
   return 0;
 }
 
 int
-hppa_range_profitable_for_hw_watchpoint (pid, start, len)
-     int pid;
-     CORE_ADDR start;
-     LONGEST len;
+hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len)
 {
   error ("Hardware watchpoints not implemented on this platform.");
 }
 
 char *
 {
   error ("Hardware watchpoints not implemented on this platform.");
 }
 
 char *
-hppa_pid_or_tid_to_str (id)
-     pid_t id;
+hppa_pid_or_tid_to_str (ptid_t id)
 {
   /* In the ptrace world, there are only processes. */
 {
   /* In the ptrace world, there are only processes. */
-  return hppa_pid_to_str (id);
-}
-
-/* This function has no meaning in a non-threaded world.  Thus, we
-   return 0 (FALSE).  See the use of "hppa_prepare_to_proceed" in
-   hppa-tdep.c. */
-
-pid_t
-hppa_switched_threads (pid)
-     pid_t pid;
-{
-  return (pid_t) 0;
+  return child_pid_to_str (id);
 }
 
 void
 }
 
 void
-hppa_ensure_vforking_parent_remains_stopped (pid)
-     int pid;
+hppa_ensure_vforking_parent_remains_stopped (int pid)
 {
   /* This assumes that the vforked parent is presently stopped, and
      that the vforked child has just delivered its first exec event.
 {
   /* This assumes that the vforked parent is presently stopped, and
      that the vforked child has just delivered its first exec event.
@@ -618,18 +964,19 @@ hppa_ensure_vforking_parent_remains_stopped (pid)
 }
 
 int
 }
 
 int
-hppa_resume_execd_vforking_child_to_get_parent_vfork ()
+hppa_resume_execd_vforking_child_to_get_parent_vfork (void)
 {
   return 1;                    /* Yes, the child must be resumed. */
 }
 
 void
 {
   return 1;                    /* Yes, the child must be resumed. */
 }
 
 void
-require_notification_of_events (pid)
-     int pid;
+require_notification_of_events (int pid)
 {
 #if defined(PT_SET_EVENT_MASK)
   int pt_status;
   ptrace_event_t ptrace_events;
 {
 #if defined(PT_SET_EVENT_MASK)
   int pt_status;
   ptrace_event_t ptrace_events;
+  int nsigs;
+  int signum;
 
   /* Instruct the kernel as to the set of events we wish to be
      informed of.  (This support does not exist before HPUX 10.0.
 
   /* Instruct the kernel as to the set of events we wish to be
      informed of.  (This support does not exist before HPUX 10.0.
@@ -641,7 +988,29 @@ require_notification_of_events (pid)
      the kernel to keep certain signals hidden from us, we do it
      by calling sigdelset (ptrace_events.pe_signals, signal) for
      each such signal here, before doing PT_SET_EVENT_MASK.  */
      the kernel to keep certain signals hidden from us, we do it
      by calling sigdelset (ptrace_events.pe_signals, signal) for
      each such signal here, before doing PT_SET_EVENT_MASK.  */
-  sigemptyset (&ptrace_events.pe_signals);
+  /* RM: The above comment is no longer true. We start with ignoring
+     all signals, and then add the ones we are interested in. We could
+     do it the other way: start by looking at all signals and then
+     deleting the ones that we aren't interested in, except that
+     multiple gdb signals may be mapped to the same host signal
+     (eg. TARGET_SIGNAL_IO and TARGET_SIGNAL_POLL both get mapped to
+     signal 22 on HPUX 10.20) We want to be notified if we are
+     interested in either signal.  */
+  sigfillset (&ptrace_events.pe_signals);
+
+  /* RM: Let's not bother with signals we don't care about */
+  nsigs = (int) TARGET_SIGNAL_LAST;
+  for (signum = nsigs; signum > 0; signum--)
+    {
+      if ((signal_stop_state (signum)) ||
+         (signal_print_state (signum)) ||
+         (!signal_pass_state (signum)))
+       {
+         if (target_signal_to_host_p (signum))
+           sigdelset (&ptrace_events.pe_signals,
+                      target_signal_to_host (signum));
+       }
+    }
 
   ptrace_events.pe_set_event = 0;
 
 
   ptrace_events.pe_set_event = 0;
 
@@ -666,8 +1035,7 @@ require_notification_of_events (pid)
 }
 
 void
 }
 
 void
-require_notification_of_exec_events (pid)
-     int pid;
+require_notification_of_exec_events (int pid)
 {
 #if defined(PT_SET_EVENT_MASK)
   int pt_status;
 {
 #if defined(PT_SET_EVENT_MASK)
   int pt_status;
@@ -708,8 +1076,7 @@ require_notification_of_exec_events (pid)
    ID of the child process, after the debugger has forked.  */
 
 void
    ID of the child process, after the debugger has forked.  */
 
 void
-child_acknowledge_created_inferior (pid)
-     int pid;
+child_acknowledge_created_inferior (int pid)
 {
   /* We need a memory home for a constant.  */
   int tc_magic_parent = PT_VERSION;
 {
   /* We need a memory home for a constant.  */
   int tc_magic_parent = PT_VERSION;
@@ -756,22 +1123,19 @@ child_acknowledge_created_inferior (pid)
 }
 
 void
 }
 
 void
-child_post_startup_inferior (pid)
-     int pid;
+child_post_startup_inferior (ptid_t ptid)
 {
 {
-  require_notification_of_events (pid);
+  require_notification_of_events (PIDGET (ptid));
 }
 
 void
 }
 
 void
-child_post_attach (pid)
-     int pid;
+child_post_attach (int pid)
 {
   require_notification_of_events (pid);
 }
 
 int
 {
   require_notification_of_events (pid);
 }
 
 int
-child_insert_fork_catchpoint (pid)
-     int pid;
+child_insert_fork_catchpoint (int pid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
@@ -785,8 +1149,7 @@ child_insert_fork_catchpoint (pid)
 }
 
 int
 }
 
 int
-child_remove_fork_catchpoint (pid)
-     int pid;
+child_remove_fork_catchpoint (int pid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
@@ -800,8 +1163,7 @@ child_remove_fork_catchpoint (pid)
 }
 
 int
 }
 
 int
-child_insert_vfork_catchpoint (pid)
-     int pid;
+child_insert_vfork_catchpoint (int pid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
@@ -815,8 +1177,7 @@ child_insert_vfork_catchpoint (pid)
 }
 
 int
 }
 
 int
-child_remove_vfork_catchpoint (pid)
-     int pid;
+child_remove_vfork_catchpoint (int pid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
@@ -830,9 +1191,7 @@ child_remove_vfork_catchpoint (pid)
 }
 
 int
 }
 
 int
-child_has_forked (pid, childpid)
-     int pid;
-     int *childpid;
+hpux_has_forked (int pid, int *childpid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_GET_PROCESS_STATE)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_GET_PROCESS_STATE)
@@ -863,9 +1222,7 @@ child_has_forked (pid, childpid)
 }
 
 int
 }
 
 int
-child_has_vforked (pid, childpid)
-     int pid;
-     int *childpid;
+hpux_has_vforked (int pid, int *childpid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_GET_PROCESS_STATE)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_GET_PROCESS_STATE)
@@ -897,15 +1254,7 @@ child_has_vforked (pid, childpid)
 }
 
 int
 }
 
 int
-child_can_follow_vfork_prior_to_exec ()
-{
-  /* ptrace doesn't allow this. */
-  return 0;
-}
-
-int
-child_insert_exec_catchpoint (pid)
-     int pid;
+child_insert_exec_catchpoint (int pid)
 {
   /* This request is only available on HPUX 10.0 and later.   */
 #if !defined(PT_SET_EVENT_MASK)
 {
   /* This request is only available on HPUX 10.0 and later.   */
 #if !defined(PT_SET_EVENT_MASK)
@@ -920,8 +1269,7 @@ child_insert_exec_catchpoint (pid)
 }
 
 int
 }
 
 int
-child_remove_exec_catchpoint (pid)
-     int pid;
+child_remove_exec_catchpoint (int pid)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_SET_EVENT_MASK)
@@ -936,9 +1284,7 @@ child_remove_exec_catchpoint (pid)
 }
 
 int
 }
 
 int
-child_has_execd (pid, execd_pathname)
-     int pid;
-     char **execd_pathname;
+hpux_has_execd (int pid, char **execd_pathname)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_GET_PROCESS_STATE)
 {
   /* This request is only available on HPUX 10.0 and later.  */
 #if !defined(PT_GET_PROCESS_STATE)
@@ -971,16 +1317,13 @@ child_has_execd (pid, execd_pathname)
 }
 
 int
 }
 
 int
-child_reported_exec_events_per_exec_call ()
+child_reported_exec_events_per_exec_call (void)
 {
   return 2;                    /* ptrace reports the event twice per call. */
 }
 
 int
 {
   return 2;                    /* ptrace reports the event twice per call. */
 }
 
 int
-child_has_syscall_event (pid, kind, syscall_id)
-     int pid;
-     enum target_waitkind *kind;
-     int *syscall_id;
+hpux_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
 {
   /* This request is only available on HPUX 10.30 and later, via
      the ttrace interface.  */
 {
   /* This request is only available on HPUX 10.30 and later, via
      the ttrace interface.  */
@@ -991,8 +1334,7 @@ child_has_syscall_event (pid, kind, syscall_id)
 }
 
 char *
 }
 
 char *
-child_pid_to_exec_file (pid)
-     int pid;
+child_pid_to_exec_file (int pid)
 {
   static char exec_file_buffer[1024];
   int pt_status;
 {
   static char exec_file_buffer[1024];
   int pt_status;
@@ -1000,8 +1342,8 @@ child_pid_to_exec_file (pid)
   char four_chars[4];
   int name_index;
   int i;
   char four_chars[4];
   int name_index;
   int i;
-  int saved_inferior_pid;
-  boolean done;
+  ptid_t saved_inferior_ptid;
+  int done;
 
 #ifdef PT_GET_PROCESS_PATHNAME
   /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
 
 #ifdef PT_GET_PROCESS_PATHNAME
   /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
@@ -1022,19 +1364,19 @@ child_pid_to_exec_file (pid)
   name_index = 0;
   done = 0;
 
   name_index = 0;
   done = 0;
 
-  /* On the chance that pid != inferior_pid, set inferior_pid
-     to pid, so that (grrrr!) implicit uses of inferior_pid get
+  /* On the chance that pid != inferior_ptid, set inferior_ptid
+     to pid, so that (grrrr!) implicit uses of inferior_ptid get
      the right id.  */
 
      the right id.  */
 
-  saved_inferior_pid = inferior_pid;
-  inferior_pid = pid;
+  saved_inferior_ptid = inferior_ptid;
+  inferior_ptid = pid_to_ptid (pid);
 
   /* Try to grab a null-terminated string. */
   while (!done)
     {
       if (target_read_memory (top_of_stack, four_chars, 4) != 0)
        {
 
   /* Try to grab a null-terminated string. */
   while (!done)
     {
       if (target_read_memory (top_of_stack, four_chars, 4) != 0)
        {
-         inferior_pid = saved_inferior_pid;
+         inferior_ptid = saved_inferior_ptid;
          return NULL;
        }
       for (i = 0; i < 4; i++)
          return NULL;
        }
       for (i = 0; i < 4; i++)
@@ -1049,16 +1391,16 @@ child_pid_to_exec_file (pid)
 
   if (exec_file_buffer[0] == '\0')
     {
 
   if (exec_file_buffer[0] == '\0')
     {
-      inferior_pid = saved_inferior_pid;
+      inferior_ptid = saved_inferior_ptid;
       return NULL;
     }
 
       return NULL;
     }
 
-  inferior_pid = saved_inferior_pid;
+  inferior_ptid = saved_inferior_ptid;
   return exec_file_buffer;
 }
 
 void
   return exec_file_buffer;
 }
 
 void
-pre_fork_inferior ()
+pre_fork_inferior (void)
 {
   int status;
 
 {
   int status;
 
@@ -1084,8 +1426,7 @@ pre_fork_inferior ()
    return "TRUE".  */
 
 int
    return "TRUE".  */
 
 int
-child_thread_alive (pid)
-     int pid;
+child_thread_alive (ptid_t ptid)
 {
   return 1;
 }
 {
   return 1;
 }
This page took 0.03709 seconds and 4 git commands to generate.