0

如果我想扩展一个内置别名(比如'b'),我需要默认实现。

我在哪里可以找到这个?我假设它们会在磁盘上的某个地方,但我无法在任何地方找到它。

4

1 回答 1

3

如果您help -a在 LLDB 提示符下键入,您将看到列出的内置别名:

b         -- ('_regexp-break')  Set a breakpoint using a regular expression to specify the location, where <linenum> is in decimal and <address> is in hex.

这是正则表达式命令的别名,它是 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.

于 2013-05-08T16:05:14.247 回答