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, utrace-devel@redhat.com
Subject: Re: Q: multiple inferiors, all-stop && vCont
Date: Tue, 03 Aug 2010 16:56:00 -0000	[thread overview]
Message-ID: <20100803165359.GA11274@redhat.com> (raw)
In-Reply-To: <20100803155521.GA3226@host1.dyn.jankratochvil.net>

On 08/03, Jan Kratochvil wrote:
>
> On Tue, 03 Aug 2010 16:30:04 +0200, Oleg Nesterov wrote:
> > 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.
>
> attach_command_post_wait:
>
>       /* At least the current thread is already stopped.  */
>
>       /* In all-stop, by definition, all threads have to be already
>          stopped at this point.  In non-stop, however, although the
>          selected thread is stopped, others may still be executing.
>          Be sure to explicitly stop all threads of the process.  This
>          should have no effect on already stopped threads.  */
>       if (non_stop)
>         target_stop (pid_to_ptid (inferior->pid));

This just reflects the current situation with the current implementation.
gdb already did

	vAttach;PID
	vCont;t:pPID.-1

I do not see anything in the _documentation_ which could explain that
only the main thread can be stopped despite the fact "-1" means all
threads.

Once again, I already understand why gdb + gdbserver work this way,
I meant remote protocol "in general".

And in fact, I do not think your explanation is correct. Yes, this
attach_command_post_wait() is called during attach. But even after that
gdbserver reports only the main thread. This happens before qSymbol
stage.

Only when gdb issues yet _another_ vCont;t:pPID.-1 after that, gdbserver
reports other threads, and this have nothing to do (I think) with
attach_command_post_wait(). In fact, to me this all works _contrary_
to the comment above.

	Be sure to explicitly stop all threads of the process.

This doesn't happen.

But, it is very possible I missed something. Ang again, I think (I hope ;)
we can forget this because the simple method works too.

> > 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 ?
>
> As far as I understand it now in-kernel gdbserver does not need libthread_db
> at all.  The communication is based only on PID/TID anyway and on Linux we do
> not need libthread_db to enumerate the TIDs of a PID.

Yes, thanks. This is what I meant.

I was afraid there are some other reason why we can't avoid libthread_db.

> > Should I worry about this issue right now?
>
> The pthread_t / libthread_db stuff should be probably only the GDB client
> problem.  You will probably never face it.
>
> > And, I hope that "client side only using: libthread_db" means gdb, not
> > gdbserver ?
>
> yes, I have meant it that way.

Great, thanks.

> > > 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.
>
> Anyway I see GDB uses `vCont;c' even with gdbstub so this problem is not
> reproducible for me.
>
> => $vCont;c:p658.658
> <= $OK

Yes. From another email from me:

	OK. After I read remote_vcont_resume()->remote_vcont_probe() path
	I understand why 'vCont;c;t' doesn't work. Contrary to what the
	documentation says it is all or nothing. Except 't' has the separate
	remote_state->support_vCont_t flag. Very strange.

That is why gdbstub reports 'vCont;t;c;C;s;S' to 'vCont?', despite
the fact it doesn't implement C/s/S yet.

> > > But it is not yet stopped that time.
> >
> > Well. And how can I stop it?
> >
> > Once again, this all works in CLI mode. And this looks very natural
>
> What do you call CLI mode?  We use only CLI mode so far all the time.  The
> other mode is MI (`gdb -i=mi').

Sorry for confusion, I do not know how to name it correctly...

I can start gdb and then enter these commands by hand, this is what
I called CLI (command line interface ;). And in this case everything
works as I expected.

Or I can put these command into the file FILE, and then do "$ gdb < FILE".
In this case "attach" + "info registers" doesn't work.

I didn't try "gdb -nx -ex ..." method yet.

Otherwise, I always use remote mode.

> This was this way in the sync/all-stop mode.  In async/non-stop mode it is
> intentionally asynchronous:
>
> attach_command:
>       if (target_can_async_p ())
>           add_inferior_continuation (attach_command_continuation, a,
>                                      attach_command_continuation_free_args);
>           return;
>
> It may take some time before this inferior reports us back the stop and we may
> want to debug other inferiors in the meantime.

Yes, I see,

> > Yes, yes, now I understand this. Once again, I was greatly confused
> > because I didn't know that CLI mode makes the difference. Even if I
>                              ^^^ local (=non-remote) probably

no, please see above. And sorry for confusion again.


So. To summarise, I never claimed this is a bug. OTOH, I think this
difference can confuse a newbie like me.

Yes, I do understand vAttach issues, but I thought that "attach"
command should always hide these details. From the documentation:

	attach PROCESS-ID

		...
		The first thing GDB does after arranging to debug the specified
		process is to stop it.  You can examine and modify an attached process
		with all the GDB commands that are ordinarily available when you start
		processes with `run'.  You can insert breakpoints; you can step and
		continue; you can modify storage.  If you would rather the process
		continue running, you may use the `continue' command after attaching
		GDB to the process.


Oleg.

  reply	other threads:[~2010-08-03 16:56 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
2010-08-03 15:55             ` Jan Kratochvil
2010-08-03 16:56               ` Oleg Nesterov [this message]
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=20100803165359.GA11274@redhat.com \
    --to=oleg@redhat.com \
    --cc=archer@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=roland@redhat.com \
    --cc=utrace-devel@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).