From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: "Ulrich Weigand" <uweigand@de.ibm.com>, Doug Evans <dje@google.com>
Subject: Re: Get rid of stop_pc (was: [RFA] dummy frame handling cleanup, plus inferior fun call signal handling improvement)
Date: Fri, 05 Dec 2008 02:46:00 -0000 [thread overview]
Message-ID: <200812050245.20430.pedro@codesourcery.com> (raw)
In-Reply-To: <200812050115.30692.pedro@codesourcery.com>
On Friday 05 December 2008 01:15:30, Pedro Alves wrote:
> On Friday 05 December 2008 00:36:56, Pedro Alves wrote:
> > On Friday 05 December 2008 00:18:00, Ulrich Weigand wrote:
> > > Pedro Alves wrote:
> > > > On Thursday 04 December 2008 22:32:12, Doug Evans wrote:
> > > > > In the original code, is there a case when stop_pc != registers.pc?
> > > >
> > > > Here,
> > > >
> > > > <stopped at 0x1234, thread 1>
> > > > (gdb) set $pc = 0xf00
> > > > (gdb) call func()
> > >
> > > Huh. But that case is in fact *broken*, because GDB will use stop_pc
> > > incorrectly: for example, the check whether we are about to continue
> > > at a breakpoint will look at stop_pc, but then continue at $pc.
> >
> > This one I believe was the original intention. The rationale being
> > that you'd not want to hit a breakpoint again at stop_pc (0x1234),
> > because there's where you stopped; but, you'd want to hit a a breakpoint
> > at 0xf00, sort of like jump *$pc hits a breakpoint at $pc.
> >
> > Note, I'm not saying I agree with this. I did say that probably nobody
> > would notice if we got rid of stop_pc.
> >
> > > It seems to me just about every current user of stop_pc *really* wants
> > > to look at regcache_read_pc (get_current_regcache ()) ...
>
> Is using read_pc instead OK with you? It's what I had written already.
>
> > I've been sneaking the idea of getting rid of stop_pc for a while now:
> > http://sourceware.org/ml/gdb-patches/2008-06/msg00450.html
> >
> > In fact, I have a months old patch here that completelly removes stop_pc.
> > IIRC, there were no visible changes in the testsuite. Say the word,
> > and I'll brush it up, regtest, submit it.
>
> Here it is, it still applied cleanly. It's smallish. Regtested on
> x86-64-unknown-linux-gnu.
>
> My original motivation was to get rid of the ugly checks
> in switch_to_thread, and to try to minimize the extra thread
> switching and register reads in non-stop mode.
>
> I had held posting this when I wrote it, since I was not sure we'd not
> miss stop_pc in some case.
>
I should say that I also considered going the other direction and
adding a stop_pc per thread for use in `proceed', while still
replacing most other references to stop_pc by read_pc.
Say something like, in all-stop mode, the thread that hit the breakpoint
would have stop_pc set to read_pc, and all the other threads would have it
set to say (CORE_ADDR) -1. This was to consider the following case:
Say where you're debugging an inferior with 2 threads, and two distinct breakpoints
installed. thread 1 has just reported a hit on breakpoint 1; and thread 2
happens to have hit breakpoint 2 simultaneously, but, since events are serialized,
linux-nat.c:cancel_breakpoint took action, so thread 2 got the PC rolled back.
The user does:
(gdb) b foo
<bpkt 1>
(gdb) b bar
<bpkt 2>
(gdb) continue
<thread 1, bpk1 1 hit>
(gdb) thread 2
<GDB reads stop_pc of thread 2, which is now pointing at a breakpoint 2>
(gdb) delete 1
proceed'ing now doesn't need to step over
breakpoint 1 (prepare_to_proceed will do nothing), since breakpoint 1
is gone.
(gdb) continue
At this point, current GDB will step over breakpoint 2, although it
was never reported as hit.
proceed:
if (addr == (CORE_ADDR) -1)
{
if (pc == stop_pc && breakpoint_here_p (pc)
^^^^^^^^^^^^^
If this was instead tp->stop_pc, and it was -1 at this point, because
thread 2 was not the thread that reported the last event, breakpoint 2
would not be missed.
--
Pedro Alves
next prev parent reply other threads:[~2008-12-05 2:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-18 21:01 [RFA] dummy frame handling cleanup, plus inferior fun call signal handling improvement Doug Evans
2008-11-19 14:07 ` Doug Evans
2008-11-20 15:02 ` Doug Evans
2008-11-20 15:06 ` Doug Evans
2008-12-01 20:52 ` Doug Evans
2008-12-01 21:22 ` Pedro Alves
2008-12-02 1:20 ` Doug Evans
2008-12-03 6:04 ` Doug Evans
2008-12-04 15:32 ` Ulrich Weigand
2008-12-04 15:54 ` Pedro Alves
2008-12-04 22:32 ` Doug Evans
2008-12-04 22:42 ` Pedro Alves
2008-12-05 0:18 ` Ulrich Weigand
2008-12-05 0:37 ` Pedro Alves
2008-12-05 1:16 ` Get rid of stop_pc (was: [RFA] dummy frame handling cleanup, plus inferior fun call signal handling improvement) Pedro Alves
2008-12-05 1:50 ` Doug Evans
2008-12-05 2:14 ` Pedro Alves
2008-12-05 2:46 ` Pedro Alves [this message]
2008-12-05 18:43 ` Ulrich Weigand
2008-12-05 19:07 ` Pedro Alves
2008-12-05 0:30 ` [RFA] dummy frame handling cleanup, plus inferior fun call signal handling improvement Ulrich Weigand
2008-11-26 19:17 ` Doug Evans
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=200812050245.20430.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.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