From: Oleg Nesterov <oleg@redhat.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: archer@sourceware.org, Roland McGrath <roland@redhat.com>
Subject: Re: Q: who maintains the STOPPED/RUNNING state?
Date: Wed, 21 Jul 2010 10:20:00 -0000 [thread overview]
Message-ID: <20100721101826.GA12176@redhat.com> (raw)
In-Reply-To: <y0mk4ophmvn.fsf@fche.csb>
On 07/20, Frank Ch. Eigler wrote:
>
> Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
>
> > [...]
> > Who maintains this state? gdb, server, both? To illustrate, suppose
> > that ugdb receives
> > $c <--- resumes the tracee
> > $g <--- asks general registers
> > What should ugdb do?
>
> Even if the protocol documentation theoretically permits this,
> if actual gdb does not send it, and actual gdbserver does not
> specifically handle it, you don't have to worry about it.
I'd like to know how can I check that gdb can't do this.
OK, it seems to be true, so I'll assume ugdb should return E01.
> > - reply E01 because it is not stopped?
> > - stop it, read the regs, reply ?
> > - stop, read the regs, reply, then resume it again ?
>
> I'm pretty sure that even if this packet is legitimate in this
> context, gdbserver will not stop the target thread just to pull out a
> sample of its registers. The values would become invalid the moment
> the thread resumed anyway.
Oh. Sure, but I used this scenario only to illustrate the question.
> > This is connected to another question. From gdb.info:
> > `H C THREAD-ID'
> > Set thread for subsequent operations (`m', `M', `g', `G', et.al.).
> > ...
> > What does this "Set" above actually mean? [...]
>
> (Whatever gdbserver uses it to mean.)
Nice. OK, unless I misread the (non-trivial) sources, gdbserver doesn't
stop the tracee. It merely sets general_thread, set_desired_inferior()
just sets current_inferior in this case.
> > To clarify, I am mostly asking about the protocol in general, not
> > about the current implementation in gdb.
>
> The abstract protocol is not precise enough or well-documented enough
> to answer these questions.
Thanks, I knew this from the very beginning ;)
> Reference to actual practice is usually
> required to implement the normal cases.
IOW, RTFS. Understand.
Yes, I tried to avoid the questions. Until I hit the limitations and
bugs (threading).
As for '$g' in particular... I didn't verify this, but looking at the
sources I strongly believe gdbserver is buggy.
It doesn't check the state of the tracee at all. Usually this doesn't
matter, because (I think) gdb will never send '$g' unless the tracee is
stopped. And if it is stopped, registers should be already cached in
thread_info->regcache_data, gdbserver does fetch_inferior_registers()
in advance when the tracee stops, before gdb actually asks.
However, if gdb sends '$g' when the tracee is not stopped, or if
get_thread_regcache() races with SIGKILL we have the (minor) problems.
regsets_fetch_inferior_registers() will notice that ptrace() fails
and it will complain via perror(), but that is all. It will send the
wrong regcache->registers content to gdb instead of E01.
OK. To answer my question, I think that ugdb can assume that the tracee
must be always stopped by debugger. Unless gdb asks to stop it, of
course.
Oleg.
next prev parent reply other threads:[~2010-07-21 10:20 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 [this message]
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
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=20100721101826.GA12176@redhat.com \
--to=oleg@redhat.com \
--cc=archer@sourceware.org \
--cc=fche@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).