LLDB:列出源代码
我最常用的 gdb
命令是 l
,后跟 n
,后跟 l-
。
My single most used gdb
command is l
followed by n
followed by l -
.
如何在lldb中获得相同的内容?
How can I get the same in lldb?
我对感到不满意,不得不输入一些行号只是为了在某处查看代码。在将大量变量转储到终端后,我想查看代码中的位置。我以前使用 l-
回去看看我在哪里,因为随后对 l
的调用将滚动令我失望(lldb也这样做,但是关键是不响应 l-
)。
I am not satisfied with having to type some line number just to see the code somewhere. I want to see where I am in the code, after dumping a ton of variables out to the terminal. And I used to use l -
to go back to look at where I am, since subsequent calls to l
will scroll me down (lldb also does this, but crucially does not respond to l -
).
也许我很想念我可以放入某种模式,它将始终在单独的缓冲区 中显示相应的源位置。那样很好,但是我什至没有要求。
Perhaps I am missing something and there is some sort of "mode" i can put it in, which will show the corresponding source location in a separate buffer all the time. That would be nice, but I'm not even asking for that.
在Xcode 4.6中,lldb的 l
别名是源列表
的简单快捷方式。
In Xcode 4.6, lldb's l
alias is a simple shortcut for source list
.
树源,已对其进行了改进,使其行为更像gdb。如果您在 http:上查看 source / Interpreter / CommandInterpreter.cpp
//lldb.llvm.org/ 您会看到 l
现在是正则表达式命令的别名,在以下情况下:
In the top of tree sources, this has been improved to behave more like gdb. If you look at source/Interpreter/CommandInterpreter.cpp
over at http://lldb.llvm.org/ you'll see that l
is now a regular expression command alias 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"))
情况下,您将获得以下行为:
With these cases, you will get behavior like this:
显示当前帧:
(lldb) f
#0: 0x0000000100000f2b a.out`main + 27 at a.c:15
12
13
14
-> 15 puts ("hi"); // line 15
16
17 puts ("hi"); // line 17
18 }
显示前十行:
(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 source context is displayed at frame stops.
请注意,您可以在〜/ .lldbinit
文件中创建自己的正则表达式命令别名,与树顶端lldb的 l
行为相同。有关语法和示例,请参见 help命令正则表达式
。
Note that you can create your own regular expression command alias in your ~/.lldbinit
file with the same behavior as the top-of-tree lldb's l
. See help command regex
for the syntax and an example.