public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: archer@sourceware.org
Subject: Q: multiple inferiors, all-stop && vCont
Date: Wed, 21 Jul 2010 17:06:00 -0000	[thread overview]
Message-ID: <20100721170400.GA30978@redhat.com> (raw)
In-Reply-To: <20100716205147.GA26313@redhat.com>

Probably the last question before I'll try to add the threading
support.

I am trying to undestand what ugdb should know about the multiple
inferiors. Looks like, I shouldn't worry at all. They do not exist
from gdbserver's pov. It should handle the multiple attach/detach,
of course, but that is all. Say, qsThreadInfo should list all
attached threads in random order. IOW, there is no any command
which can refer to any particular inferior somehow, explicitly or
implicitly. Only THREAD-ID can matter.

Correct?

-------------------------------------------------------------------------------
But there is one oddity I can't understand in all-stop mode.

	(gdb) info inferiors
	  Num  Description       Executable
	* 3    process 22988     /bin/sleep
	  2    process 22823     /bin/sleep
	  1    process 22822     /bin/sleep
	(gdb) info threads
	* 3 Thread 22988.22988  0x000000375faa6390 in __nanosleep_nocancel () from /lib64/libc.so.6
	  2 Thread 22823.22823  0x000000375faa6390 in __nanosleep_nocancel () from /lib64/libc.so.6
	  1 Thread 22822.22822  0x000000375faa6390 in __nanosleep_nocancel () from /lib64/libc.so.6
	(gdb) c
	Continuing.

The last 'c' correctly resumes all processes/threads. But, gdb
sends the single vCont packet, and this packet is

	vCont;c:p59cc.-1

iow, it asks to resume only the 3rd 22988 process.

Does this mean that gdbserver should always ignore the THREAD-ID part
of this command in all-stop mode?

Oh. grep, grep, grep. Looks like this is true, but the code is nontrivial.
Not sure I understand it correctly.

It seems to me, handle_v_cont() first resumes the process it was
asked explicitly, then it does mywait(minus_one_ptid) and eventually
this ptid is passed to linux_resume() to wake up other threads.

I must admit, this looks a bit strange. Why gdb doesn't send
"vCont;c:-1.-1" which looks obviously more logical ?

I am afraid I missed something I should know here, I'll appreciate
any info.


-------------------------------------------------------------------
Well. And perhaps there is another bug....

If I sent SIGCONT to one of the processes, then gdbserver reports
T13 and stops all 3 processes, this looks correct.

gdb looks good too:

	Program received signal SIGCONT, Continued.
	[Switching to Thread 22822.22822]

But, the next continue

	(gdb) c
	Continuing.

resumes only one process, that one who recieved the signal. Other
processes are not resumed. Hmm, and CTRL-C does not work after that.

I can't understand this. Bug? Or something I should learn?

Just in case, I tried other sig_kernel_ignore() signals instead of
SIGCONT, the same.

-------------------------------------------------------------------
Let's play with SIGKILL.

	(gdb) info inferiors
	  Num  Description       Executable
	  3    process 29449     /bin/sleep
	  2    process 28409     /bin/sleep
	* 1    process 28408     /bin/sleep
	(gdb) c
	Continuing.

kill -9 29449. gdbserver correctly reports "X9;process:7309", gdb
informs the user:

	Program terminated with signal SIGKILL, Killed.
	The program no longer exists.
	(gdb) info inferiors
	  Num  Description       Executable
	* 3    <null>            /bin/sleep
	  2    process 28409     /bin/sleep
	  1    process 28408     /bin/sleep
	(gdb) info threads
	  2 Thread 28409.28409  0x00000000000000b0 in ?? ()
	  1 Thread 28408.28408  0x3030303030303030 in ?? ()

	No selected thread.  See `help thread'.
	(gdb)

But. In this case gdbserver does not stop other inferiors/threads,
there are running.

Isn't this wrong? This is all-stop mode. Or I misread the docs, this
is very possible.

But afaics, this can't be right.

	(gdb) inferior 1
	[Switching to inferior 1 [process 28408] (/bin/sleep)]
	[Switching to thread 1 (Thread 28408.28408)] 
	#0  0x3030303030303030 in ?? ()

Indeed, gdb blindly sends m/g requests and gets E01 or the bogus
register data from gdbserver.

	(gdb) c
	Continuing.
	^C
	Program received signal SIGINT, Interrupt.
	0x3030303030303030 in ?? ()

this finally stops 2 other processes,

	(gdb) c
	Continuing.

	Program received signal SIGSEGV, Segmentation fault.
	0x3030303030303030 in ?? ()
	(gdb)

Hmm. Yes, /bin/sleep is killed by SIGSEGV. Nice. Well, starting from
here nothing really works.

----------------------------------------------------------------------
So. Reference to actual practice doesn't help, I suspect it is buggy.

From gdb.info

	`vCont[;ACTION[:THREAD-ID]]...'
	     Resume the inferior, specifying different actions for each thread.
	     If an action is specified with no THREAD-ID, then it is applied to
	     any threads that don't have a specific action specified; if no
	     default action is specified then other threads should remain
	     stopped in all-stop mode

I can't really parse this... but let's look at gdb's vCont packet again,

	vCont;c:p59cc.-1

To me, it looks as "no default action is specified". Doesn't this mean
gdbserver should not have resumed other processes?

Confused.

Oleg.

  parent reply	other threads:[~2010-07-21 17:06 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 ` Oleg Nesterov [this message]
2010-07-21 20:42   ` Q: multiple inferiors, all-stop && vCont 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
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=20100721170400.GA30978@redhat.com \
    --to=oleg@redhat.com \
    --cc=archer@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).