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).
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.
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.