Page 1 of 1

dwarf, step over

Posted: Sun Jul 18, 2010 9:26 am
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

Re: dwarf, step over

Posted: Mon Aug 16, 2010 7:29 am
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

Re: dwarf, step over

Posted: Mon Aug 16, 2010 6:02 pm
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.