]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2012-02-27 Pedro Alves <palves@redhat.com>
authorPedro Alves <palves@redhat.com>
Mon, 27 Feb 2012 16:22:16 +0000 (16:22 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 27 Feb 2012 16:22:16 +0000 (16:22 +0000)
gdb/gdbserver/
* linux-low.c (pid_is_stopped): Delete, moved to common/.
(linux_attach_lwp_1): Adjust to use linux_proc_pid_is_stopped.

gdb/
* linux-nat.c (pid_is_stopped): Delete, moved to common/.
(linux_nat_post_attach_wait): Adjust to use
linux_proc_pid_is_stopped.

* common/linux-procfs.h (linux_proc_pid_is_stopped): Declare.
* common/linux-procfs.c (linux_proc_pid_is_stopped): New function,
based on pid_is_stopped from both linux-nat.c and
gdbserver/linux-low.c, and renamed.

gdb/ChangeLog
gdb/common/linux-procfs.c
gdb/common/linux-procfs.h
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c
gdb/linux-nat.c

index 0772ee87af2a84e7c261cddbca96578208a3a63c..e2379f4791e993a0fc2ddb914388a7a094f27b08 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-27  Pedro Alves  <palves@redhat.com>
+
+       * linux-nat.c (pid_is_stopped): Delete, moved to common/.
+       (linux_nat_post_attach_wait): Adjust to use
+       linux_proc_pid_is_stopped.
+       * common/linux-procfs.h (linux_proc_pid_is_stopped): Declare.
+       * common/linux-procfs.c (linux_proc_pid_is_stopped): New function,
+       based on pid_is_stopped from both linux-nat.c and
+       gdbserver/linux-low.c, and renamed.
+
 2012-02-24  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * remote.c (remote_watchpoint_addr_within_range): New function.
index 421f36edb46a671f1fa8152d37a6963078db8c4a..165383e8755813948bd74765c4cc8b3458097e3b 100644 (file)
@@ -53,3 +53,34 @@ linux_proc_get_tgid (int lwpid)
 
   return tgid;
 }
+
+/* Detect `T (stopped)' in `/proc/PID/status'.
+   Other states including `T (tracing stop)' are reported as false.  */
+
+int
+linux_proc_pid_is_stopped (pid_t pid)
+{
+  FILE *status_file;
+  char buf[100];
+  int retval = 0;
+
+  snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid);
+  status_file = fopen (buf, "r");
+  if (status_file != NULL)
+    {
+      int have_state = 0;
+
+      while (fgets (buf, sizeof (buf), status_file))
+       {
+         if (strncmp (buf, "State:", 6) == 0)
+           {
+             have_state = 1;
+             break;
+           }
+       }
+      if (have_state && strstr (buf, "T (stopped)") != NULL)
+       retval = 1;
+      fclose (status_file);
+    }
+  return retval;
+}
index a4ba4a1b48db5e809ba7848b7ae3774cb937dbfc..c1e55474ad75bcc00721061c8bcbfedb0650d58e 100644 (file)
@@ -26,4 +26,9 @@
 
 extern int linux_proc_get_tgid (int lwpid);
 
+/* Detect `T (stopped)' in `/proc/PID/status'.
+   Other states including `T (tracing stop)' are reported as false.  */
+
+extern int linux_proc_pid_is_stopped (pid_t pid);
+
 #endif /* COMMON_LINUX_PROCFS_H */
index b6d9ce939328b24bff4376d009d91d08e7a8d9f3..fed95bfd8e7dc3261d54eb1debd9ecf516567c1b 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-27  Pedro Alves  <palves@redhat.com>
+
+       * linux-low.c (pid_is_stopped): Delete, moved to common/.
+       (linux_attach_lwp_1): Adjust to use linux_proc_pid_is_stopped.
+
 2012-02-27  Pedro Alves  <palves@redhat.com>
 
        PR server/9684
index f2887e65413f368c37aa22512968f88b5f175114..8f57ee3407cf7cb6698710bb0767b92a3f1d5d91 100644 (file)
@@ -598,37 +598,6 @@ linux_create_inferior (char *program, char **allargs)
   return pid;
 }
 
-/* Detect `T (stopped)' in `/proc/PID/status'.
-   Other states including `T (tracing stop)' are reported as false.  */
-
-static int
-pid_is_stopped (pid_t pid)
-{
-  FILE *status_file;
-  char buf[100];
-  int retval = 0;
-
-  snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid);
-  status_file = fopen (buf, "r");
-  if (status_file != NULL)
-    {
-      int have_state = 0;
-
-      while (fgets (buf, sizeof (buf), status_file))
-       {
-         if (strncmp (buf, "State:", 6) == 0)
-           {
-             have_state = 1;
-             break;
-           }
-       }
-      if (have_state && strstr (buf, "T (stopped)") != NULL)
-       retval = 1;
-      fclose (status_file);
-    }
-  return retval;
-}
-
 /* Attach to an inferior process.  */
 
 static void
@@ -674,7 +643,7 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial)
      ptrace call on this LWP.  */
   new_lwp->must_set_ptrace_flags = 1;
 
-  if (pid_is_stopped (lwpid))
+  if (linux_proc_pid_is_stopped (lwpid))
     {
       if (debug_threads)
        fprintf (stderr,
index 3731096d585fd9a486e007bdd177be28b6a1d63e..e4263870f18cef7659ecf38f99f9c59b53398c97 100644 (file)
@@ -1356,37 +1356,6 @@ exit_lwp (struct lwp_info *lp)
   delete_lwp (lp->ptid);
 }
 
-/* Detect `T (stopped)' in `/proc/PID/status'.
-   Other states including `T (tracing stop)' are reported as false.  */
-
-static int
-pid_is_stopped (pid_t pid)
-{
-  FILE *status_file;
-  char buf[100];
-  int retval = 0;
-
-  snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid);
-  status_file = fopen (buf, "r");
-  if (status_file != NULL)
-    {
-      int have_state = 0;
-
-      while (fgets (buf, sizeof (buf), status_file))
-       {
-         if (strncmp (buf, "State:", 6) == 0)
-           {
-             have_state = 1;
-             break;
-           }
-       }
-      if (have_state && strstr (buf, "T (stopped)") != NULL)
-       retval = 1;
-      fclose (status_file);
-    }
-  return retval;
-}
-
 /* Wait for the LWP specified by LP, which we have just attached to.
    Returns a wait status for that LWP, to cache.  */
 
@@ -1397,7 +1366,7 @@ linux_nat_post_attach_wait (ptid_t ptid, int first, int *cloned,
   pid_t new_pid, pid = GET_LWP (ptid);
   int status;
 
-  if (pid_is_stopped (pid))
+  if (linux_proc_pid_is_stopped (pid))
     {
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,