在 Xcode 4.6 中,lldb 的 l 别名是 source list 的简单快捷方式。
在树源的顶部,这已被改进为更像 gdb。如果你在http://lldb.llvm.org/ 上查看source/Interpreter/CommandInterpreter.cpp,你会发现l 现在是这些情况下的正则表达式命令别名:
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"))
在这些情况下,您会得到如下行为:
显示当前帧:
(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
您还可以使用stop-line-count-after 和stop-line-count-before 设置来控制在帧停止处显示多少源上下文。
请注意,您可以在 ~/.lldbinit 文件中创建自己的正则表达式命令别名,其行为与树顶 lldb 的 l 相同。有关语法和示例,请参阅help command regex。