Author: davide Date: Thu May 16 18:03:21 2019 New Revision: 360966 URL: http://llvm.org/viewvc/llvm-project?rev=360966&view=rev Log: [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> Added: lldb/trunk/lit/Commands/command-backtrace.test Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Added: lldb/trunk/lit/Commands/command-backtrace.test URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Commands/command-backtrace.test?rev=360966&view=auto ============================================================================== --- lldb/trunk/lit/Commands/command-backtrace.test (added) +++ lldb/trunk/lit/Commands/command-backtrace.test Thu May 16 18:03:21 2019 @@ -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 Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=360966&r1=360965&r2=360966&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu May 16 18:03:21 2019 @@ -758,12 +758,12 @@ void CommandInterpreter::LoadCommandDict // 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; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits