[PATCH] PR server/9684: gdbserver, attach to stopped processes
Yao Qi
yao@codesourcery.com
Sat Feb 25 06:24:00 GMT 2012
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 (é½å°§)
More information about the Gdb-patches
mailing list