This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR server/9684: gdbserver, attach to stopped processes


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 (éå)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]