* emulating single-step in gdbserver?
@ 2003-02-20 4:39 Miles Bader
2003-02-20 13:07 ` Andrew Cagney
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Miles Bader @ 2003-02-20 4:39 UTC (permalink / raw)
To: gdb
Hi,
I'm porting gdbserver to uClinux on the (NEC) v850e processor, and
ptrace on this machine doesn't support PTRACE_SINGLESTEP (because the
hardware doesn't support single-stepping).
I thought gdb might already support an emulated singlestep by always
setting a temporary breakpoint at the next insn, but from a quick
perusal of the source, it seems not.
So I'm wondering where the best place to stick this functionality is.
My thought is to modify `linux_resume_one_process', in
gdbserver/linux-low.c, something like this (error-checking omitted):
static void
linux_resume_one_process (struct inferior_list_entry *entry,
int step, int signal)
{
...
#ifdef PTRACE_SINGLESTEP
ptrace(step ? PTRACE_SINGLESTEP : PTRACE_CONT, process->lwpid, 0, signal);
#else
if (step)
/* This platform can't single-step, so simulate it. */
{
CORE_ADDR stop_pc = (*the_low_target.get_pc) ();
if (! (*the_low_target.breakpoint_at) (stop_pc))
{
CORE_ADDR next_pc = (*the_low_target.next_pc) ();
set_breakpoint_at (next_pc, delete_single_step_breakpoint);
}
}
ptrace (PTRACE_CONT, process->lwpid, 0, signal);
#endif
...
}
void
delete_single_step_breakpoint (CORE_ADDR stopped_at)
{
struct breakpoint *bp = find_breakpoint_at (stopped_at);
if (bp)
delete_breakpoint (bp);
else
error ("Could not find single-step breakpoint in list.");
}
The `next_pc' member added to the_low_target would be a function that
calculates the next pc after executing the current insn.
Any comments on this approach; does it seem correct?
An alternative might be to add this to the kernel's ptrace
implementation; however, I'd rather not do this, as the `calculate the
next insn' function is a little hairy, and I'd rather it be in
user-space.
A related question, BTW, is what's the precise meaning of
`the_low_target.breakpoint_reinsert_addr'? It's not documented very
well...
Thanks,
-Miles
p.s. Does anyone know if the gdb GNATS database is really the best place
to send bug-fix patches? I sent something there a few months ago,
and it's languished ever since, with no feedback, no change of
state, no nothing. The patch only affects the NEC v850, and is
certainly an improvement over the existing code (which is very
clearly wrong). Would it be better to send email to gdb-patches
or something?
--
I'd rather be consing.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: emulating single-step in gdbserver?
2003-02-20 4:39 emulating single-step in gdbserver? Miles Bader
@ 2003-02-20 13:07 ` Andrew Cagney
2003-02-20 15:08 ` Daniel Jacobowitz
[not found] ` <miles@lsi.nec.co.jp>
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-02-20 13:07 UTC (permalink / raw)
To: Miles Bader; +Cc: gdb
Miles,
I see FSF assignments for things like EMACS but not GDB. If this is
correct then can you get the GDB paperwork put in place?
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: emulating single-step in gdbserver?
2003-02-20 4:39 emulating single-step in gdbserver? Miles Bader
2003-02-20 13:07 ` Andrew Cagney
@ 2003-02-20 15:08 ` Daniel Jacobowitz
2003-02-20 15:53 ` Miles Bader
[not found] ` <miles@lsi.nec.co.jp>
2 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-02-20 15:08 UTC (permalink / raw)
To: Miles Bader; +Cc: gdb
On Thu, Feb 20, 2003 at 01:39:25PM +0900, Miles Bader wrote:
> Hi,
>
> I'm porting gdbserver to uClinux on the (NEC) v850e processor, and
> ptrace on this machine doesn't support PTRACE_SINGLESTEP (because the
> hardware doesn't support single-stepping).
>
> I thought gdb might already support an emulated singlestep by always
> setting a temporary breakpoint at the next insn, but from a quick
> perusal of the source, it seems not.
>
> So I'm wondering where the best place to stick this functionality is.
GDB (i.e. the client, not gdbserver). Certainly gdbserver could do it,
but you have to do some rather more complicated work in the server that
GDB is already set up to do and the server isn't - with threads, for
instance. Most other platforms do this; see ARM and MIPS at least.
However, now that I've got limited breakpoint support in gdbserver, it
might be practical to do it in the server.
> The `next_pc' member added to the_low_target would be a function that
> calculates the next pc after executing the current insn.
>
> Any comments on this approach; does it seem correct?
Roughly. Another detail you'd get wrong would be if we get a signal
before hitting the single-step breakpoint - it should be removed, not
left for later. There are probably others.
> A related question, BTW, is what's the precise meaning of
> `the_low_target.breakpoint_reinsert_addr'? It's not documented very
> well...
It's essentially a very limitted next_pc function. The only
breakpoints gdbserver places right now are in empty marker functions in
the thread library. After hitting one, it either single-steps or
places a breakpoint at the function's return address, and then
reinserts it. The advantage is that finding the return address is
quick and very simple.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: emulating single-step in gdbserver?
2003-02-20 15:08 ` Daniel Jacobowitz
@ 2003-02-20 15:53 ` Miles Bader
0 siblings, 0 replies; 5+ messages in thread
From: Miles Bader @ 2003-02-20 15:53 UTC (permalink / raw)
To: gdb
Thanks for the response.
It looks like I won't need to do this after all -- I've been informed that
the CPU _does_ implement single-stepping, it's just that the documentation
claims otherwise to avoid having to support it (and all the other debugger
writers use it, so it works)!
> > A related question, BTW, is what's the precise meaning of
> > `the_low_target.breakpoint_reinsert_addr'? It's not documented very
> > well...
>
> It's essentially a very limitted next_pc function. The only
> breakpoints gdbserver places right now are in empty marker functions in
> the thread library. After hitting one, it either single-steps or
> places a breakpoint at the function's return address, and then
> reinserts it. The advantage is that finding the return address is
> quick and very simple.
I see. Now the comments that are there make a bit more sense; I was very
confused when I saw the mips just returned the function's return-address!
I guess I can just set it to null and let gdb single-step over the
breakpoint.
Thanks,
-Miles
--
Next to fried food, the South has suffered most from oratory.
-- Walter Hines Page
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <miles@lsi.nec.co.jp>]
end of thread, other threads:[~2003-02-20 15:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-20 4:39 emulating single-step in gdbserver? Miles Bader
2003-02-20 13:07 ` Andrew Cagney
2003-02-20 15:08 ` Daniel Jacobowitz
2003-02-20 15:53 ` Miles Bader
[not found] ` <miles@lsi.nec.co.jp>
2003-02-20 15:31 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox