This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Next over function and breakpoint setting


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]