OSDN Git Service

* infptrace.c: Remove #ifdef'ed out inclusion of gdb_stat.h.
authorkettenis <kettenis>
Sun, 22 Aug 2004 19:03:39 +0000 (19:03 +0000)
committerkettenis <kettenis>
Sun, 22 Aug 2004 19:03:39 +0000 (19:03 +0000)
Reorder includes.
(fetch_register, store_register): Remove prototypes.
(child_resume): Reorganize code and comments such that it is
grouped a bit more logically.
(attach): Explicitly compare errno against 0.
(detach): Likewise.  Use perror_with_name instead of
print_sys_errmsg.
* Makefile.in (infptrace.o): Update dependencies.

gdb/ChangeLog
gdb/Makefile.in
gdb/infptrace.c

index 9dd207c..dd0eb85 100644 (file)
@@ -1,5 +1,15 @@
 2004-08-22  Mark Kettenis  <kettenis@gnu.org>
 
+       * infptrace.c: Remove #ifdef'ed out inclusion of gdb_stat.h.
+       Reorder includes.
+       (fetch_register, store_register): Remove prototypes.
+       (child_resume): Reorganize code and comments such that it is
+       grouped a bit more logically.
+       (attach): Explicitly compare errno against 0.
+       (detach): Likewise.  Use perror_with_name instead of
+       print_sys_errmsg.
+       * Makefile.in (infptrace.o): Update dependencies.
+
        * ia64-linux-nat.c: Update copyright year.
        (fetch_debug_register, store_debug_register)
        (ia64_linux_stopped_by_watchpoint): Replace PTRACE_ARG3_TYPE with
index fd09157..9aa6ff3 100644 (file)
@@ -2049,10 +2049,9 @@ inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
 inflow.o: inflow.c $(defs_h) $(frame_h) $(inferior_h) $(command_h) \
        $(serial_h) $(terminal_h) $(target_h) $(gdbthread_h) $(gdb_string_h) \
        $(inflow_h)
-infptrace.o: infptrace.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
-       $(gdb_string_h) $(regcache_h) $(gdb_wait_h) $(command_h) \
-       $(gdb_dirent_h) $(gdb_ptrace_h) $(gdbcore_h) $(gdb_stat_h) \
-       $(gdb_assert_h)
+infptrace.o: infptrace.c $(defs_h) $(command_h) $(frame_h) $(gdbcore_h) \
+       $(inferior_h) $(regcache_h) $(target_h) $(gdb_assert_h) \
+       $(gdb_wait_h) $(gdb_string_h) $(gdb_dirent_h) $(gdb_ptrace_h)
 infrun.o: infrun.c $(defs_h) $(gdb_string_h) $(symtab_h) $(frame_h) \
        $(inferior_h) $(breakpoint_h) $(gdb_wait_h) $(gdbcore_h) $(gdbcmd_h) \
        $(cli_script_h) $(target_h) $(gdbthread_h) $(annotate_h) \
index 7473781..0c59d8f 100644 (file)
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "command.h"
 #include "frame.h"
+#include "gdbcore.h"
 #include "inferior.h"
-#include "target.h"
-#include "gdb_string.h"
 #include "regcache.h"
+#include "target.h"
 
+#include "gdb_assert.h"
 #include "gdb_wait.h"
-
-#include "command.h"
+#include "gdb_string.h"
 
 #ifdef USG
 #include <sys/types.h>
 
 #include "gdb_ptrace.h"
 
-#include "gdbcore.h"
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
-#if 0
-/* Don't think this is used anymore.  On the sequent (not sure whether it's
-   dynix or ptx or both), it is included unconditionally by sys/user.h and
-   not protected against multiple inclusion.  */
-#include "gdb_stat.h"
-#endif
-
-#include "gdb_assert.h"
 
 #if !defined (FETCH_INFERIOR_REGISTERS)
 #include <sys/user.h>          /* Probably need to poke the user structure */
 static void udot_info (char *, int);
 #endif
 
-#if !defined (FETCH_INFERIOR_REGISTERS)
-static void fetch_register (int);
-static void store_register (int);
-#endif
-
 void _initialize_infptrace (void);
 \f
 
@@ -198,52 +185,48 @@ kill_inferior (void)
 void
 child_resume (ptid_t ptid, int step, enum target_signal signal)
 {
+  int request = PT_CONTINUE;
   int pid = PIDGET (ptid);
 
-  errno = 0;
-
   if (pid == -1)
     /* Resume all threads.  */
     /* I think this only gets used in the non-threaded case, where "resume
        all threads" and "resume inferior_ptid" are the same.  */
     pid = PIDGET (inferior_ptid);
 
-  /* An address of (PTRACE_TYPE_ARG3)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.)
-
-     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)
     {
-      if (SOFTWARE_SINGLE_STEP_P ())
-       internal_error (__FILE__, __LINE__, "failed internal consistency check");               /* Make sure this doesn't happen. */
-      else
-       ptrace (PT_STEP, pid, (PTRACE_TYPE_ARG3) 1,
-               target_signal_to_host (signal));
+      /* 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.  */
+
+      gdb_assert (!SOFTWARE_SINGLE_STEP_P ());
+      request = PT_STEP;
     }
-  else
-    ptrace (PT_CONTINUE, pid, (PTRACE_TYPE_ARG3) 1,
-           target_signal_to_host (signal));
 
-  if (errno)
-    {
-      perror_with_name ("ptrace");
-    }
+  /* An address of (PTRACE_TYPE_ARG3)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.  */
+
+  errno = 0;
+  ptrace (request, pid, (PTRACE_TYPE_ARG3)1, target_signal_to_host (signal));
+  if (errno != 0)
+    perror_with_name ("ptrace");
 }
 #endif /* CHILD_RESUME */
 \f
+
 /* Start debugging the process whose number is PID.  */
+
 int
 attach (int pid)
 {
 #ifdef PT_ATTACH
   errno = 0;
   ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3) 0, 0);
-  if (errno)
+  if (errno != 0)
     perror_with_name ("ptrace");
   attach_flag = 1;
   return pid;
@@ -252,19 +235,19 @@ attach (int pid)
 #endif
 }
 
-/* Stop debugging the process whose number is PID
-   and continue it with signal number SIGNAL.
-   SIGNAL = 0 means just continue it.  */
+/* Stop debugging the process whose number is PID and continue it with
+   signal number SIGNAL.  SIGNAL = 0 means just continue it.  */
 
 void
 detach (int signal)
 {
 #ifdef PT_DETACH
+  int pid = PIDGET (inferior_ptid);
+
   errno = 0;
-  ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) 1,
-          signal);
-  if (errno)
-    print_sys_errmsg ("ptrace", errno);
+  ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3) 1, signal);
+  if (errno != 0)
+    perror_with_name ("ptrace");
   attach_flag = 0;
 #else
   error ("This system does not support detaching from a process");