This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] PR server/9684: gdbserver, attach to stopped processes
- From: Yao Qi <yao at codesourcery dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Sat, 25 Feb 2012 13:56:51 +0800
- Subject: Re: [PATCH] PR server/9684: gdbserver, attach to stopped processes
- References: <20120224222127.14659.51317.stgit@hit-nxdomain.opendns.com>
On 02/25/2012 06:21 AM, Pedro Alves wrote:
> +/* 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;
> +}
This function is exactly the same as linux-nat.c:pid_is_stopped, so
why don't we move them to common/linux-linuxprocfs.c?
--
Yao (éå)