Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv2] gdb/remote: Restore support for 'S' stop reply packet
Date: Thu, 27 Feb 2020 19:46:00 -0000	[thread overview]
Message-ID: <14a8b8f2-f866-fcd8-bf23-c1f67d426421@redhat.com> (raw)
In-Reply-To: <20200227161704.16480-1-andrew.burgess@embecosm.com>

On 2/27/20 4:17 PM, Andrew Burgess wrote:

> The solution I propose in this commit is to use the first non exited
> thread of the inferior.

s/of the inferior/of the target/

> Additionally, GDB will give a warning if a
> multi-threaded target stops without passing a thread-id.
> 
> There's no test included with this commit, if anyone has any ideas for
> how we could test this aspect of the remote protocol (short of writing
> a new gdbserver) then I'd love to know.

I forgot to mention this earlier, but I think we could test this by using
gdbserver's --disable-packet=Tthread option (or --disable-packet=threads
to disable vCont as well.).  This sets the disable_packet_Tthread global in
gdbserver, which makes it skip including the thread in the T stop reply.

$ gdbserver --disable-packet
Disableable packets:
  vCont         All vCont packets
  qC            Querying the current thread
  qfThreadInfo  Thread listing
  Tthread       Passing the thread specifier in the T stop reply packet
  threads       All of the above

I added these options several years ago exactly to exercise support
for old non-threaded protocol.  ISTR having documented them, ...
... ah, here:
  https://sourceware.org/ml/gdb-patches/2008-06/msg00501.html

doesn't look like that patch was ever merged.  :-/

>  
> -  /* If no thread/process was reported by the stub, assume the current
> -     inferior.  */
> +  /* If no thread/process was reported by the stub then use the first
> +     non-exited thread in the current inferior.  */

s/current inferior/current target/

>    if (ptid == null_ptid)
> -    ptid = inferior_ptid;
> +    {
> +      for (thread_info *thr : all_non_exited_threads (this))
> +	{
> +	  if (ptid != null_ptid)
> +	    {
> +	      warning (_("multi-threaded target stopped without sending "
> +			 "a thread-id, using first non-exited thread"));

I wonder about making this only warn once, to avoid a flood of warnings.
Like:

    if (!warned)
      {
        warned = true;
        warning (....);
      }

We use that same pattern in other places we only want to warn once.
E.g., parse_memory_map.

Otherwise LGTM.

Thanks,
Pedro Alves


  reply	other threads:[~2020-02-27 19:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31  7:35 [PATCH] gdb/remote: Ask target for current thread if it doesn't tell us Andrew Burgess
2020-02-26 18:52 ` Andrew Burgess
2020-02-26 19:28 ` Pedro Alves
2020-02-27 16:17   ` [PATCHv2] gdb/remote: Restore support for 'S' stop reply packet Andrew Burgess
2020-02-27 19:46     ` Pedro Alves [this message]
2020-02-28 14:03       ` Andrew Burgess
2020-02-28 17:46         ` Pedro Alves
2020-03-02 11:54           ` [PATCHv3 0/2] " Andrew Burgess
     [not found]             ` <27befec6c761c43f2e1a9e59403644c198cbd75b.1583149853.git.andrew.burgess@embecosm.com>
2020-03-02 12:24               ` [PATCHv3 1/2] gdbserver: Add mechanism to prevent sending T stop packets Pedro Alves
2020-03-02 11:54           ` [PATCHv3 2/2] gdb/remote: Restore support for 'S' stop reply packet Andrew Burgess
2020-03-02 12:25             ` Pedro Alves
2020-03-02 15:19               ` Andrew Burgess
2020-03-02 19:07                 ` Pedro Alves
2020-03-02 19:25                   ` Andrew Burgess
2020-03-09 17:35             ` Tom Tromey
2020-03-10 19:05               ` Andrew Burgess
2020-03-11 16:23               ` Andrew Burgess
2020-03-11 18:02                 ` Tom Tromey

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=14a8b8f2-f866-fcd8-bf23-c1f67d426421@redhat.com \
    --to=palves@redhat.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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