Lint fixes from Paul Eggert (eggert@twinsun.com):
[deliverable/binutils-gdb.git] / gdb / infptrace.c
index e9fa66d855529caecb60ee3b3359708e7418d627..f97d2c32f9805e9818380782900890f78dd4af4e 100644 (file)
@@ -22,6 +22,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "inferior.h"
 #include "target.h"
 
+#include "nm.h"
+
 #ifdef USG
 #include <sys/types.h>
 #endif
@@ -30,7 +32,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <sys/dir.h>
 #include <signal.h>
 #include <sys/ioctl.h>
-#ifndef USG
+
+#ifdef PTRACE_IN_WRONG_PLACE
+#include <ptrace.h>
+#else
 #include <sys/ptrace.h>
 #endif
 
@@ -85,21 +90,16 @@ call_ptrace (request, pid, addr, data)
 #define ptrace call_ptrace
 #endif
 
-/* This is used when GDB is exiting.  It gives less chance of error.*/
-
 void
-kill_inferior_fast ()
+kill_inferior ()
 {
   if (inferior_pid == 0)
     return;
+  /* ptrace PT_KILL only works if process is stopped!!!  So stop it with
+     a real signal first, if we can.  */
+  kill (inferior_pid, SIGKILL);
   ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0);
   wait ((int *)0);
-}
-
-void
-kill_inferior ()
-{
-  kill_inferior_fast ();
   target_mourn_inferior ();
 }
 
@@ -116,20 +116,17 @@ child_resume (step, signal)
 
   /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where
      it was.  (If GDB wanted it to start some other way, we have already
-     written a new PC value to the child.)  */
+     written a new PC value to the child.)
+
+     If this system does not support PT_STEP, a higher level function will
+     have called single_step() to transmute the step request into a
+     continue request (by setting breakpoints on all possible successor
+     instructions), so we don't have to worry about that here.  */
 
   if (step)
-#ifdef NO_SINGLE_STEP
-    single_step (signal);
-#else    
-    ptrace (PT_STEP, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
-#endif
+    ptrace (PT_STEP,     inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
   else
-#ifdef AIX_BUGGY_PTRACE_CONTINUE
-    AIX_BUGGY_PTRACE_CONTINUE;
-#else
     ptrace (PT_CONTINUE, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
-#endif
 
   if (errno)
     perror_with_name ("ptrace");
@@ -395,8 +392,7 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
 
       /* Copy data to be written over corresponding part of buffer */
 
-      (void) memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr,
-                    len);
+      memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
 
       /* Write the entire buffer.  */
 
@@ -431,8 +427,7 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
        }
 
       /* Copy appropriate bytes out of the buffer.  */
-      (void) memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)),
-                    len);
+      memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
     }
   return len;
 }
This page took 0.024938 seconds and 4 git commands to generate.