From: Pedro Alves <pedro@codesourcery.com>
To: gdb@sourceware.org
Cc: "suresh ds" <dssuresh66@mail.com>
Subject: Re: Behaviour of default all-stop mode -- Why no one has replied ?
Date: Tue, 21 Jul 2009 14:00:00 -0000 [thread overview]
Message-ID: <200907211459.56464.pedro@codesourcery.com> (raw)
In-Reply-To: <20090720105023.A9543BE407F@ws1-9.us4.outblaze.com>
Em Monday 20 July 2009 11:50:23, suresh ds escreveu:
> Fine. vCont is properly implemented and most of the things are working fine.
> I've a query with single step.
> Let's say there are four threads, 1,2,3,4.
> Sometimes when I single step, I get a packet from gdb as "vCont;s:1;c".
> Accordingly, I insert a break at the next address, and continue all.
>
> 1)
>
> (i) Now, even before thread 1 hits the break at the next address, the other thread(s) may hit some other breakpoint and report that. In this case, the single step is not yet
> reached (and therefore not removed). A further continue will make all run, and then thread 1 may hit this single step break, remove it and report it to gdb. What this all means
> is, gdb may get the single step status after quite some time and not immediately after one does "step". Is this OK ?
Take this sequence:
1. --> vCont;s:1;c
2. <-- T05 thread:2
3. --> vCont;c
In this case, point 3 told thread 1 to continue, so any previous step
request to thread 1 is cancelled. What is means is that the last
command applied to a thread is what counts. Even this could happen:
1. --> vCont;s:1;c
2. <-- T05 thread:2
3. --> <change PC of thread 1 to point somewhere else>
4. --> vCont;s:1
Notice that the step in point 4 is now done at a different PC
from point 1. Again, a new command to thread 1 cancelled a
previous command to thread 1.
(warning: older GDB's didn't behave correctly in this use case)
> (ii) There is also another possibility. Some other thread may hit this single step breakpoint, remove the breakpoint and report it than the actual thread 1, which is supposed
> to hit, remove it and report it. If this happens, then the actuaI thread 1 which is supposed to single step will not be single stepped. Is this way of implementation OK ?
No, it is not. GDB would report a SIGTRAP to the user, as it
had no idea why did the thread stop. And then again, neither would
the user know why did the thread stop if it didn't tell it to. It
would be a confusing behaviour. If you want to implement software single
stepping yourself, then you need to make sure that GDB doesn't see that
other threads can hit that thread-1-specific-internal-detail-to-your-stub
breakpoint. It's as if you need to make GDB believe that your architecture
supports hardware single-stepping.
> 2) Another way is, even if other threads hit some other breakpoint or hit this single step breakpoint itself, they do not report it and wait for thread 1 to hit the single step
> and report it. Is this the way to be implemented ?
That's one way. Another way is to make the thread that hit the
other-thread's-step-breakpoint "step over" the breakpoint (remove breaks; step
*only* that thread, leaving others stopped; reinsert breaks; resume threads
again, going on waiting for the right thread to reach the step
breakpoint) --- this is an implementation that avoids more than one
level deep nested software single stepping, and is what GDB implements itself
(see src/gdb/infrun.c and look around for stepping_past_singlestep_breakpoint).
You could even go crazy and support a fully nested algorithm, by *only* removing
the step-breakpoint that the thread is trying to step over, and resume all
threads that GDB asked to be running *except* the thread that *was supposed*
to hit that step-breakpoint (otherwise, that thread may well miss its step break).
Your version would be what I'd call a 0-level nesting implementation; gdb's a
1-level nesting, the latter a more complicated N-level nesting version.
--
Pedro Alves
next prev parent reply other threads:[~2009-07-21 14:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-20 10:50 suresh ds
2009-07-21 14:00 ` Pedro Alves [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-07-06 14:42 suresh ds
2009-07-06 17:03 ` Pedro Alves
2009-06-15 15:37 suresh ds
2009-06-15 16:51 ` Daniel Jacobowitz
2009-06-15 15:10 suresh ds
2009-06-15 15:20 ` Daniel Jacobowitz
2009-06-15 18:44 ` Pedro Alves
2009-06-15 10:38 suresh ds
2009-06-15 11:01 ` Pedro Alves
2009-06-10 7:18 suresh ds
2009-06-10 17:55 ` Pedro Alves
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=200907211459.56464.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=dssuresh66@mail.com \
--cc=gdb@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