aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-02-27 16:22:16 +0000
committerPedro Alves <palves@redhat.com>2012-02-27 16:22:16 +0000
commit644cebc98ce121ef7e6a8c0d1867ae01e936b41b (patch)
treef4eee5e5d107abfb51774b8dabae8706ad8232a1 /gdb/linux-nat.c
parentc14d7ab2b61d410e10380fcdc21985cdcd88f810 (diff)
downloadgdb-644cebc98ce121ef7e6a8c0d1867ae01e936b41b.zip
gdb-644cebc98ce121ef7e6a8c0d1867ae01e936b41b.tar.gz
gdb-644cebc98ce121ef7e6a8c0d1867ae01e936b41b.tar.bz2
2012-02-27 Pedro Alves <palves@redhat.com>
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.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 3731096..e426387 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -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,