[Dwarf-Discuss] dwarf, step over

Wim Lewis wiml@omnigroup.com
Mon Jul 19 18:22:29 GMT 2010


On Jul 19, 2010, at 5:45 AM, John Smith wrote:
> 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).

This is a little subtle: the object code corresponding to a single line of source can be very simple or very complex. If the compiler is doing very much optimization, parts of different lines will be interleaved. Possibly a single instruction might belong to several lines, if the compiler has done some common-subexpression elimination. So you need to define carefully what you mean by "step over", so that you can implement it.

One way to do it is to simply single-step over instructions until you reach an instruction that's part of a different line. This can be slow, so as an optimization you can scan ahead in the object code looking for branch instructions, etc.

The line number table includes the is_stmt and basic_block flags which should be helpful for working this out, but GCC doesn't seem to emit useful values for them.

> Even if I put a breakpoint after the last call the line number information wont be correct, because Im highlighting the current line based on the line info table


I don't understand what you mean by this?






More information about the Dwarf-discuss mailing list