Here's a fun little idea plus a preliminary patch implementing it.
When I'm debugging programs I often wonder what exactly will happen when I step-in. This is particularly a problem with code that has lots of control flow happening on a single line, such as a C++ for loop with iterators, a function call with a lambda or block definition, or plain old nested function calls.
For example, let's say I'm stopped inside lldb in SourceManager.cpp:93 — I would really like to know which function I'll be stepping into next. Will the next "step" take me into get(), new, File(), or reset()?
90 // If file_sp is no good or it points to a non-existent file, reset it. 91 if (!file_sp || !file_sp->GetFileSpec().Exists()) 92 { -> 93 file_sp.reset (new File (file_spec, target_sp.get())); 94 95 if (debugger_sp) 96 debugger_sp->GetSourceFileCache().AddSourceFile(file_sp); (lldb) step
Of course a debugger cannot predict the future, but what it can do is tell me exactly where I am stopped now!
Compilers like clang already include column information in the debug info by default. The attached patch makes use of this by adding an underline attribute to the character on the current column to indicate the exact breakpoint on the current line (here simulated with a caret):
90 // If file_sp is no good or it points to a non-existent file, reset it. 91 if (!file_sp || !file_sp->GetFileSpec().Exists()) 92 { -> 93 file_sp.reset (new File (file_spec, target_sp.get())); ^ 94 95 if (debugger_sp) 96 debugger_sp->GetSourceFileCache().AddSourceFile(file_sp); (lldb) step
With this markup I may now assume that "step" will take me into the File() constructor. Just what I wanted to know.
This is of course just scratching the surface of what we could do with column information, but probably a good starting point. Having a more fine-grained visualization, for example, it might be interesting to have "next" take me to the next "is_stmt" in the line table instead of always to the next line, and so on.
Let me know what you think!
I think I will occasionally want to see the source listing w/o the column stop info (e.g. to cut & paste it somewhere) so it might be convenient to have a command option that overrides the setting. It's always annoying to have to go change & reset a setting to do this, plus then I can't make aliases for the different behaviors.