如果我想扩展一个内置别名(比如'b'),我需要默认的实现。
我在哪里找到这个?我猜他们会在磁盘上的某个地方,但我无法在任何地方找到它。
答案 0 :(得分:3)
如果您在LLDB提示符下键入help -a
,您会看到列出的内置别名:
b -- ('_regexp-break') Set a breakpoint using a regular expression to specify the location, where <linenum> is in decimal and <address> is in hex.
这是regex命令的别名,这是一种LLDB命令,它尝试将其输入与一个或多个正则表达式进行匹配,并执行依赖于该匹配的扩展。
例如_regexp_break
,这是你关心的:
_regexp-break -- Set a breakpoint using a regular expression to specify the location, where <linenum> is in decimal and <address> is in hex.
我认为LLDB目前没有办法查看正则表达式命令的“内容”,但由于它是一个开源项目,你可以通过查看来源来解决它:
const char *break_regexes[][2] = {{"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "breakpoint set --file '%1' --line %2"},
{"^([[:digit:]]+)[[:space:]]*$", "breakpoint set --line %1"},
{"^\\*?(0x[[:xdigit:]]+)[[:space:]]*$", "breakpoint set --address %1"},
{"^[\"']?([-+]?\\[.*\\])[\"']?[[:space:]]*$", "breakpoint set --name '%1'"},
{"^(-.*)$", "breakpoint set %1"},
{"^(.*[^[:space:]])`(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%2' --shlib '%1'"},
{"^\\&(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1' --skip-prologue=0"},
{"^(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1'"}};
这是一个字符串对数组,每对都定义了一个正则表达式和匹配时的相应扩展。
(供您参考,此代码位于lldb/source/Interpreter/CommandInterpreter.cpp
)
如果您最终定义了自己的并且您非常喜欢它,以至于您希望它始终可用,您可以通过在~/.lldbinit
中定义修改后的命令,在每个会话中“自行滚动”。