LLDB: enter the source code

My most used gdb command is l followed by n and then l - .

How can i get the same in lldb?

I am not happy with the need to dial a line number to see the code somewhere. I want to see where I am in the code after I posted a lot of variables on the terminal. And I used l - to return to see where I am, since subsequent calls to l will scroll me (lldb also does this, but doesn't actually respond to l - ).

Perhaps something is missing for me, and there is some kind of β€œmode” in which I can put it, which will show the corresponding source location in a separate buffer. That would be good, but I do not even ask for it.

+7
c ++ debugging lldb gdb
source share
1 answer

In Xcode 4.6, the alias lldb l is a simple shortcut to the source list .

At the top of the source tree, it is improved to behave like gdb. If you look at source/Interpreter/CommandInterpreter.cpp at http://lldb.llvm.org/ , you will see that l now an alias of the regex command with these cases

 if (list_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$", "source list --line %1") && list_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "source list --file '%1' --line %2") && list_regex_cmd_ap->AddRegexCommand("^\\*?(0x[[:xdigit:]]+)[[:space:]]*$", "source list --address %1") && list_regex_cmd_ap->AddRegexCommand("^-[[:space:]]*$", "source list --reverse") && list_regex_cmd_ap->AddRegexCommand("^-([[:digit:]]+)[[:space:]]*$", "source list --reverse --count %1") && list_regex_cmd_ap->AddRegexCommand("^(.+)$", "source list --name \"%1\"") && list_regex_cmd_ap->AddRegexCommand("^$", "source list")) 

In these cases, you will receive the following:

Show current frame:

 (lldb) f #0: 0x0000000100000f2b a.out`main + 27 at ac:15 12 13 14 -> 15 puts ("hi"); // line 15 16 17 puts ("hi"); // line 17 18 } 

show the previous ten lines:

 (lldb) l - 5 6 7 8 9 puts ("hi"); // line 9 10 11 

You can also use the stop-line-count-after and stop-line-count-before settings to control how much the source context is displayed when the frame stops.

Note that you can create your own regular expression command alias in the ~/.lldbinit with the same behavior as the top of the lldb l tree. See help command regex for syntax and example.

+15
source share

All Articles