Jonas Meyer
Jonas Meyer

Reputation: 803

LLDB Where are the builtin aliases

If I want to extend a builtin alias(say, 'b'), I'd need the default implementation.

Where do I find this? I'd assume they'd be somewhere on disk, but I haven't been able to find it anywhere.

Upvotes: 1

Views: 555

Answers (1)

Enrico Granata
Enrico Granata

Reputation: 3329

If you type help -a at the LLDB prompt you will see the builtin aliases listed:

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

This is an alias to a regex commands, which is a form of LLDB commands that tries to match its input against one or more regular expression and performs an expansion that depends upon that match.

For instance _regexp_break, which is what you care about:

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

I don’t think LLDB currently has a way to see the “contents” of regular expression commands, but since it is an open source project, you can figure it out by looking at sources:

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'"}};

This is an array of string pairs, and each pair defines a regular expression and the corresponding expansion upon match. (for your reference, this code is in lldb/source/Interpreter/CommandInterpreter.cpp)

If you end up defining your own and you like it so much that you want it always available, you can "roll your own" at each session by defining your modified command in ~/.lldbinit.

Upvotes: 4

Related Questions