dwarf, step over

Programming, for all ages and all languages.
Post Reply
user12
Posts: 3
Joined: Sun Jul 18, 2010 9:17 am

dwarf, step over

Post by user12 »

Hi,

Im working on a C source level debugger. The debug info available in elf
format. How could be 'step over' implemented?
The problem is at 'Point1', anyway I can wait for the
next source line (reading it from the .debug_line table).

Code: Select all

if (a == 1)
 x = 1; //Point1
else if (a == 2)
 x = 1;

z = 1;
Now I put breakpoint after the current line to execute 'step over' but in this case it isnt good.

My small example
http://www.sendspace.com/file/dt0ljg


Thanks
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: dwarf, step over

Post by jal »

user12 wrote:How could be 'step over' implemented?
The problem is at 'Point1', (...)

Code: Select all

if (a == 1)
 x = 1; //Point1
else if (a == 2)
 x = 1;

z = 1;
Now I put breakpoint after the current line to execute 'step over' but in this case it isnt good.
I don't understand exactly what you mean - at what point in the source code are you, about to execute Point1 (so "a" equals 1)? In assembly, there's a jmp instruction after the assignment, so the breakpoint goes there. When hitting that, you check the destination address, find what line that corresponds to, et voila.


JAL
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: dwarf, step over

Post by bewing »

Well, "step over" really is a teeny bit complicated. Most of the time, you want to set a breakpoint at the next instruction, then "continue" until you hit it. But there is a list of instructions you can't do that with, and you need to singlestep over them, instead. Mostly jumps, branches, and RETs. You might want to look at the very last function (bx_dbg_step_over_command) in the bochs file dbg_main.cc for an example -- but that's not source level, so I'm not sure how much real help it would be.
Post Reply