Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Pedro Alves <palves@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] PR server/9684: gdbserver, attach to stopped processes
Date: Sat, 25 Feb 2012 06:24:00 -0000	[thread overview]
Message-ID: <4F487823.5030006@codesourcery.com> (raw)
In-Reply-To: <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 (齐尧)


  parent reply	other threads:[~2012-02-25  5:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24 23:00 Pedro Alves
2012-02-24 23:22 ` Joel Brobecker
2012-02-27 17:26   ` Pedro Alves
2012-02-25  5:58 ` Jan Kratochvil
2012-02-27 16:24   ` Pedro Alves
2012-02-25  6:24 ` Yao Qi [this message]
2012-02-27 16:31   ` move pid_is_stopped to common/ Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F487823.5030006@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox