public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Roland McGrath <roland@redhat.com>, archer@sourceware.org
Subject: Re: Q: multiple inferiors, all-stop && vCont
Date: Tue, 03 Aug 2010 14:32:00 -0000	[thread overview]
Message-ID: <20100803143004.GB2185@redhat.com> (raw)
In-Reply-To: <20100803123940.GA16669@host1.dyn.jankratochvil.net>

On 08/03, Jan Kratochvil wrote:
>
> On Mon, 26 Jul 2010 16:27:59 +0200, Oleg Nesterov wrote:
> > For example, I spent several hours trying to understand why gdb
> > ignores '%Stop:' notification and never sends '$vStopped', but
> > it does send vStopped to the real gdbserver with the same batch
> > file. The reason was partly my misunderstanding, but also another
> > bug in gdb and the timing issues.
>
> Which bug in gdb do you mean?

Heh. Funny that, I just sent another email which explains how I was
confused (in reply to my first "Q: %Stop && gdb crash" message).

> I do not have the problem reproducible, the
> logs look OK.
> 	=> $vCont;t:p5b84.-1
> 	<= $OK
> 	<= %Stop:T00thread:p5b84.5b84;
> 	=> $vStopped
> 	<= $T00thread:p5b84.5b87;
> 	=> $vStopped
> 	<= $OK

Yes, this is OK. And this is how this all works when I enter the
commands via CLI (probably -ex works too).

> Are you aware of the comment before remote_get_pending_stop_replies()?

Well, I read it before, but I was never able to parse it up to the end ;)

> > Or vAttach in the multithreaded case. I'd say that gdbserver is just
> > wrong here, even if this works in practice. The first qfThreadInfo
> > after vAttach reports only the main thread.
>
> Yes...
>
> OK:
> getpkt ("qXfer:threads:read::0,fff");  [no ack sent]
> putpkt ("$l<threads>
> <thread id="p5baa.5baa" core="2"/>
> </threads>
> #de"); [noack mode]
>
> > After the first
> > vCont;t:PID.-1 only the main thread is reported again. Somehow it
> > provokes gdb to send more 'vCont;t:PID.-1's packets, only then it
> > reports the new threads via Stop/vStopped.
>
> Only after GDB issues:
>
> ->server: getpkt ("qSymbol::");  [no ack sent]
> [...]
> <-server: putpkt ("$qSymbol:5f7468726561645f64625f6c6973745f745f6e657874#a0"); [noack mode]
>                             = _thread_db_list_t_next
> ->server: getpkt ("qSymbol:7f4c9a0ab0bc:5f7468726561645f64625f6c6973745f745f6e657874");  [no ack sent]
>                                         = _thread_db_list_t_next
>
> gdbserver can ask GDB for some symbols the gdbserver needs to provide to
> libthread_db to be able to find out all the inferior threads using
> libthread_db calling back gdbserver's ps_pglobal_lookup.

Yes, I know.

> Immediately at the moment of vAttach GDB may not be able to answer those
> questions so it is delayed a bit.

Yes, I have to take my "gdbserver is just wrong" back.

However, I do not really understand how this can work reliably in the
terms of remote protocol. Somehow this scheme relies on the fact that
gdb will send another vCont;t:pTGID.-1 _once again_ after the previous
vCont;t:pTGID.-1, and gdbserver can report the other threads via
Stop/vStopped. OK, I hope this doesn't matter.

> > At first I tried to mimic this behaviour, I was already totally
> > confused because I also had other problems with gdb - it constantly
> > crashed. But finally I have found that the simple approach seems to
> > work too.
>
> Yes, I see:
>
> gdb=> $vAttach;5bb7
> gdb<= $OK
> gdb=> $qfThreadInfo
> gdb<= $mp5bb7.5bb7,p5bb7.5bba
> gdb=> $qsThreadInfo
> gdb<= $l
> [...]
> gdb=> $qSymbol::
> gdb<= $

Yes. And please note that at least in-kernel gdbstub can not use
libthread_db. But, I also hope that we can avoid it even if gdbstub
runs in user-space ?

> Even FSF gdbserver does not seem to use/provide pthread_t identifiers:
>   2 Thread 23487.23490  0x00007fb25c983a6d in nanosleep () at ../sysdeps/unix/syscall-template.S:82
> * 1 Thread 23487.23487  0x00007fb25cc63fbd in pthread_join (threadid=140404033701648, thread_return=0x0) at pthread_join.c:89
>
> as provided by local linux-nat.c / linux-thread-db.c.
>   2 Thread 0x7ffff7842710 (LWP 23503)  0x00007ffff78e9a6d in nanosleep () at ../sysdeps/unix/syscall-template.S:82
> * 1 Thread 0x7ffff7ff3700 (LWP 23500)  0x00007ffff7bc9fbd in pthread_join (threadid=140737346021136, thread_return=0x0) at pthread_join.c:89
>
> The LWP -> thread_t conversion could be done later from the client side only
> using:
> libthread_db (td_ta_map_lwp2thr(), td_thr_get_info(),
>               typeof (td_thrinfo_t->ti_tid) = thread_t)

Cough. This is black magic to me ;)

I probably understand what pthread_t is, but I do not know how/if this
is important for gdb.

Should I worry about this issue right now?

And, I hope that "client side only using: libthread_db" means gdb, not
gdbserver ?

> > Right now I am trying to understand why gdb doesn't use 'vCont:c'
> > but sends 'c' instead. And yes, I report 'vCont;c;t' to 'vCont?'.
>
> GDB can use both,

Yes, I know.

> why do you want from GDB to use specifically `vCont:c'?

Because, first of all, I wanted to understand why gdb doesn't send
vCont:c to me, but uses this command when it works with the real
gdbserver.

Also, I am trying to identify the "essential" commands subset.
Afaics, vCont:c is preferred, and gdb never uses 'c' if it knows
it can use 'vCont:c'.

And. How could I verify that I handle vCont:c correctly if I wasn't
able to provoke gdb to send it?

Oleg.

  reply	other threads:[~2010-08-03 14:32 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16 20:54 Q: mutlithreaded tracees && clone/exit Oleg Nesterov
2010-07-16 21:40 ` Roland McGrath
2010-07-18 17:51   ` Oleg Nesterov
2010-07-18 18:04     ` Oleg Nesterov
2010-07-18 20:22     ` Roland McGrath
2010-07-19 13:44 ` BUG: add_thread_silent()->switch_to_thread(minus_one_ptid) is wrong Oleg Nesterov
2010-07-19 15:36   ` Oleg Nesterov
2010-07-19 16:01 ` Q: mutlithreaded tracees && clone/exit Jan Kratochvil
2010-07-19 22:57   ` Roland McGrath
2010-07-20 13:18   ` Oleg Nesterov
2010-07-20 14:04     ` BUG? gdb, non-stop && c -a Oleg Nesterov
2010-07-20 14:12       ` Jan Kratochvil
2010-07-20 14:49         ` Oleg Nesterov
2010-07-20 15:08           ` Jan Kratochvil
2010-07-20 15:28             ` Oleg Nesterov
2010-07-20 19:43         ` Roland McGrath
2010-07-21  7:59           ` Oleg Nesterov
2010-07-21  8:10             ` Jan Kratochvil
2010-07-21 11:12               ` Oleg Nesterov
2010-07-20 14:21     ` Q: mutlithreaded tracees && clone/exit Jan Kratochvil
2010-07-20 15:09       ` Oleg Nesterov
2010-07-20 19:41     ` Roland McGrath
2010-07-21  8:32       ` Oleg Nesterov
2010-07-20 14:43 ` Q: who maintains the STOPPED/RUNNING state? Oleg Nesterov
     [not found]   ` <y0mk4ophmvn.fsf@fche.csb>
2010-07-21 10:20     ` Oleg Nesterov
2010-07-21 10:51       ` Oleg Nesterov
2010-07-21 17:06 ` Q: multiple inferiors, all-stop && vCont Oleg Nesterov
2010-07-21 20:42   ` Roland McGrath
2010-07-23 17:33     ` Oleg Nesterov
2010-07-26 14:30       ` Oleg Nesterov
2010-07-26 16:06         ` Oleg Nesterov
2010-07-28 18:19         ` gdbstub initial code, another approach Oleg Nesterov
2010-07-29 21:38           ` Frank Ch. Eigler
2010-07-30 13:00             ` Oleg Nesterov
2010-07-30 13:16               ` Frank Ch. Eigler
2010-07-30 15:01                 ` Oleg Nesterov
2010-07-30 13:25               ` Jan Kratochvil
2010-07-30 14:44                 ` Oleg Nesterov
2010-07-30 15:20                   ` Jan Kratochvil
2010-08-02 12:54                     ` Oleg Nesterov
2010-08-03 13:55                       ` Jan Kratochvil
2010-07-30 17:59                 ` Tom Tromey
2010-08-02 18:25           ` Oleg Nesterov
2010-08-02 23:54           ` Jan Kratochvil
2010-08-03 12:27             ` Q: %Stop && gdb crash Oleg Nesterov
2010-08-03 13:17               ` Oleg Nesterov
2010-08-03 19:57                 ` Kevin Buettner
2010-08-04 19:42                   ` Oleg Nesterov
2010-08-04 23:32                     ` Kevin Buettner
2010-08-05 18:24                       ` Oleg Nesterov
2010-08-03 13:36               ` Jan Kratochvil
2010-08-03 15:09                 ` Oleg Nesterov
2010-08-03 12:39         ` Q: multiple inferiors, all-stop && vCont Jan Kratochvil
2010-08-03 14:32           ` Oleg Nesterov [this message]
2010-08-03 15:55             ` Jan Kratochvil
2010-08-03 16:56               ` Oleg Nesterov
2010-08-03 18:37                 ` Jan Kratochvil
2010-08-18 17:07           ` Jan Kratochvil
2010-08-18 19:22             ` Roland McGrath

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=20100803143004.GB2185@redhat.com \
    --to=oleg@redhat.com \
    --cc=archer@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=roland@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).