Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Orjan Friberg <orjan.friberg@axis.com>
To: Andrew Cagney <cagney@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: STEP_SKIPS_DELAY question, sort of
Date: Tue, 25 May 2004 11:53:00 -0000	[thread overview]
Message-ID: <40B33399.3090803@axis.com> (raw)
In-Reply-To: <40B23BB2.6070001@gnu.org>

Andrew Cagney wrote:
I think there is still some missing information.  Given:
  N+0: branch foo
  N+2: nop
and PC==N+0, exactly what state information is available after doing a 
single hardware single-step (PC and status registers)?
State information is only PC (see below) and SPC (single-step PC). 
There's no information in the status registers regarding branch 
taken/not taken.

(The h/w single-step procedure works like this: after the instruction 
pointed out by the SPC has been executed, a single-step exception is 
given, and the SPC is updated to the next instruction.)

- If I understand things correctly, one h/w single-step gets PC==N+2 and 
two h/w single-steps gets PC==foo.  For that to work there must be some 
additional state information lurking somewhere - a bit indicating 
stopped in delay slot perhaphs?
One h/w single-step actually gets PC==N+1, which I then adjust to N+2 
before reporting it to GDB.  So, (yes) the bit indicating stopped in a 
delay slot is the lowest bit of the PC.

- If there were a breakpoint at N+2, what state information would be 
available then.  If the breakpoint were then yanked, where would a 
single-step end up - again additional state information is needed to 
make this work?
With a breakpoint at N+2, PC==N+1 (again, interrupted in delay slot, 
will resume execution at N) and PC is reported as N+2.  For a 
single-step at this point, SPC is set up with N+2, so a single-step 
exception fires after the delay slot has been executed.

(The decrementation of the PC when executing a break instruction is 
handled by the stub itself, which becomes a bit of a kludge when we're 
stopped in a delay slot.)

What could be implemented relatively easily is to automatically 
single-step again if we end up in a delay-slot due to a single-step (not 
due to a breakpoint though).  This would, in some sense, break the 
"stepi" command since we would step two instructions instead of one in 
those cases.

Maybe this can be stated in even simpler terms than "don't re-insert a 
breakpoint on an instruction that's going to be restarted when we 
resume execution".  Rather, "single-step twice before re-inserting a 
breakpoint we're currently stopped at". 


GDB needs to know that its in such a state.
Yeah, I had a look at resume/handle_inferior_event, and it certainly 
wasn't obvious to me how that kind of mechanism should be implemented.

--
Orjan Friberg
Axis Communications


  reply	other threads:[~2004-05-25 11:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-21 17:14 Orjan Friberg
2004-05-21 20:25 ` Andrew Cagney
2004-05-24  9:15   ` Orjan Friberg
2004-05-24 18:15     ` Andrew Cagney
2004-05-25 11:53       ` Orjan Friberg [this message]
2004-05-25 21:14         ` Andrew Cagney
2004-05-26  9:39           ` Orjan Friberg
2004-05-26 17:39             ` Andrew Cagney
2004-06-07 12:12             ` Orjan Friberg
2004-06-07 12:42               ` Orjan Friberg
2004-06-07 13:09                 ` Orjan Friberg
2004-06-07 15:08                   ` Andrew Cagney
2004-06-09  9:48                     ` Orjan Friberg
2004-06-09 16:00                       ` Andrew Cagney
2004-06-14 12:09                         ` Orjan Friberg
2004-06-16 14:53                           ` Orjan Friberg
2004-06-24 18:25                             ` Andrew Cagney
2004-10-01 11:26                         ` Orjan Friberg
2004-10-25 20:18                           ` Andrew Cagney

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=40B33399.3090803@axis.com \
    --to=orjan.friberg@axis.com \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sources.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