* Next over function and breakpoint setting
2004-03-19 0:09 Next over function and breakpoint setting Orjan Friberg
@ 2004-03-16 15:42 ` Orjan Friberg
2004-03-27 5:50 ` Daniel Jacobowitz
1 sibling, 0 replies; 5+ messages in thread
From: Orjan Friberg @ 2004-03-16 15:42 UTC (permalink / raw)
To: gdb-patches
Out of curiosity I followed what happens when issuing a next command
over a function call. The reason I got curious was that I noticed
(remote protocol) that GDB sets a breakpoint on the first instruction of
the function being stepped over, and, when stopped there, sets another
breakpoint at that function's return address to accomplish the "next".
Actually, maybe that's a misrepresentation: looking at the code, it
seems GDB does a step, and if it *then* finds it ended up inside a
function (step_into_function -> step_over_function) it decides to step
out of it.
Looking at the code in infcmd.c and infrun.c I'm sure there's a good
reason for not just setting the breakpoint on the address belonging to
the next line of code, but I couldn't find any comment saying what that
reason is. Anyone care to enlighten me?
(I couldn't say if any of this was remote target/CRIS specific;
apologies if it is and I missed it.)
--
Orjan Friberg
Axis Communications
^ permalink raw reply [flat|nested] 5+ messages in thread
* Next over function and breakpoint setting
@ 2004-03-19 0:09 Orjan Friberg
2004-03-16 15:42 ` Orjan Friberg
2004-03-27 5:50 ` Daniel Jacobowitz
0 siblings, 2 replies; 5+ messages in thread
From: Orjan Friberg @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches
Out of curiosity I followed what happens when issuing a next command
over a function call. The reason I got curious was that I noticed
(remote protocol) that GDB sets a breakpoint on the first instruction of
the function being stepped over, and, when stopped there, sets another
breakpoint at that function's return address to accomplish the "next".
Actually, maybe that's a misrepresentation: looking at the code, it
seems GDB does a step, and if it *then* finds it ended up inside a
function (step_into_function -> step_over_function) it decides to step
out of it.
Looking at the code in infcmd.c and infrun.c I'm sure there's a good
reason for not just setting the breakpoint on the address belonging to
the next line of code, but I couldn't find any comment saying what that
reason is. Anyone care to enlighten me?
(I couldn't say if any of this was remote target/CRIS specific;
apologies if it is and I missed it.)
--
Orjan Friberg
Axis Communications
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Next over function and breakpoint setting
2004-03-19 0:09 Next over function and breakpoint setting Orjan Friberg
2004-03-16 15:42 ` Orjan Friberg
@ 2004-03-27 5:50 ` Daniel Jacobowitz
2004-03-29 8:48 ` Orjan Friberg
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-03-27 5:50 UTC (permalink / raw)
To: Orjan Friberg; +Cc: gdb-patches
On Tue, Mar 16, 2004 at 04:42:30PM +0100, Orjan Friberg wrote:
> Out of curiosity I followed what happens when issuing a next command
> over a function call. The reason I got curious was that I noticed
> (remote protocol) that GDB sets a breakpoint on the first instruction of
> the function being stepped over, and, when stopped there, sets another
> breakpoint at that function's return address to accomplish the "next".
>
> Actually, maybe that's a misrepresentation: looking at the code, it
> seems GDB does a step, and if it *then* finds it ended up inside a
> function (step_into_function -> step_over_function) it decides to step
> out of it.
>
> Looking at the code in infcmd.c and infrun.c I'm sure there's a good
> reason for not just setting the breakpoint on the address belonging to
> the next line of code, but I couldn't find any comment saying what that
> reason is. Anyone care to enlighten me?
>
> (I couldn't say if any of this was remote target/CRIS specific;
> apologies if it is and I missed it.)
[Sorry, missed this the first time.]
"The next line of code" is a very iffy concept. GDB doesn't analyze a
line to figure out what it does, or where it might transfer control
to... while possible, that would be a very different approach to
debugging. So the only way we have to implement next is to step and
see where we end up - and if we don't like it, go until we're somewhere
else.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Next over function and breakpoint setting
2004-03-27 5:50 ` Daniel Jacobowitz
@ 2004-03-29 8:48 ` Orjan Friberg
2004-03-29 13:36 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Orjan Friberg @ 2004-03-29 8:48 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
>
> "The next line of code" is a very iffy concept. GDB doesn't analyze a
> line to figure out what it does, or where it might transfer control
> to... while possible, that would be a very different approach to
> debugging. So the only way we have to implement next is to step and
> see where we end up - and if we don't like it, go until we're somewhere
> else.
I guess I wasn't really asking a question - I was just confused by the
way it was implemented since it wasn't what I had expected. Anyhow,
thanks for clearing that up.
--
Orjan Friberg
Axis Communications
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Next over function and breakpoint setting
2004-03-29 8:48 ` Orjan Friberg
@ 2004-03-29 13:36 ` Andrew Cagney
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2004-03-29 13:36 UTC (permalink / raw)
To: Orjan Friberg; +Cc: Daniel Jacobowitz, gdb-patches
> Daniel Jacobowitz wrote:
>
>>
>> "The next line of code" is a very iffy concept. GDB doesn't analyze a
>> line to figure out what it does, or where it might transfer control
>> to... while possible, that would be a very different approach to
>> debugging. So the only way we have to implement next is to step and
>> see where we end up - and if we don't like it, go until we're somewhere
>> else.
>
>
> I guess I wasn't really asking a question - I was just confused by the way it was implemented since it wasn't what I had expected. Anyhow, thanks for clearing that up.
BTW, have a look at the step out of range code. The theory is that the
target be presented with a range of addresses and it run until it leave
that range (as is the case with a step or next).
The implementation breaks the theory -- the code didn't consider threads
and multi-threaded interactions. As far as I'm concerned, to fix the
theory we need to disentangle threads.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-03-29 13:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-19 0:09 Next over function and breakpoint setting Orjan Friberg
2004-03-16 15:42 ` Orjan Friberg
2004-03-27 5:50 ` Daniel Jacobowitz
2004-03-29 8:48 ` Orjan Friberg
2004-03-29 13:36 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox