[CommandInterpreter] Accept blanks after all or [0-9]+ for bt.

Previously "bt all    " would've failed as the regex didn't match
them.

Over the shoulder review by Jonas Devlieghere.

<rdar://problem/50824935>

llvm-svn: 360966
This commit is contained in:
Davide Italiano
2019-05-17 01:03:21 +00:00
parent 9427961c89
commit d768ee2140
2 changed files with 16 additions and 4 deletions

View File

@@ -0,0 +1,12 @@
# Check basic functionality of command bt.
# RUN: %lldb -s %s 2>&1 | FileCheck %s
# Make sure this is not rejected by the parser as invalid syntax.
# Blank characters after the '1' are important, as we're testing the parser.
bt 1
# CHECK: error: invalid target
# Make sure this is not rejected by the parser as invalid syntax.
# Blank characters after the '1' are important, as we're testing the parser.
bt all
# CHECK: error: invalid target

View File

@@ -758,12 +758,12 @@ void CommandInterpreter::LoadCommandDictionary() {
// command if you wanted to backtrace three frames you would do "bt -c 3"
// but the intention is to have this emulate the gdb "bt" command and so
// now "bt 3" is the preferred form, in line with gdb.
if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)$",
if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)\\s*$",
"thread backtrace -c %1") &&
bt_regex_cmd_up->AddRegexCommand("^-c ([[:digit:]]+)$",
bt_regex_cmd_up->AddRegexCommand("^-c ([[:digit:]]+)\\s*$",
"thread backtrace -c %1") &&
bt_regex_cmd_up->AddRegexCommand("^all$", "thread backtrace all") &&
bt_regex_cmd_up->AddRegexCommand("^$", "thread backtrace")) {
bt_regex_cmd_up->AddRegexCommand("^all\\s*$", "thread backtrace all") &&
bt_regex_cmd_up->AddRegexCommand("^\\s*$", "thread backtrace")) {
CommandObjectSP command_sp(bt_regex_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}