[Lldb-commits] [PATCH] D20835: Mark the current column when displaying the context of the current breakpoint on the terminal.

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Tue May 31 14:11:45 PDT 2016


aprantl created this revision.
aprantl added reviewers: jingham, clayborg.
aprantl added a subscriber: lldb-commits.
aprantl set the repository for this revision to rL LLVM.

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!

Repository:
  rL LLVM

http://reviews.llvm.org/D20835

Files:
  include/lldb/API/SBSourceManager.h
  include/lldb/Core/SourceManager.h
  scripts/interface/SBSourceManager.i
  scripts/interface/SBStream.i
  source/API/SBSourceManager.cpp
  source/Commands/CommandObjectSource.cpp
  source/Core/Disassembler.cpp
  source/Core/SourceManager.cpp
  source/Target/StackFrame.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20835.59117.patch
Type: text/x-patch
Size: 15190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160531/ab7aea62/attachment-0001.bin>


More information about the lldb-commits mailing list