[Lldb-commits] [lldb] r338043 - Fix duplicate suggestions after an ambiguous command
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 26 10:14:18 PDT 2018
Author: teemperor
Date: Thu Jul 26 10:14:18 2018
New Revision: 338043
URL: http://llvm.org/viewvc/llvm-project?rev=338043&view=rev
Log:
Fix duplicate suggestions after an ambiguous command
Summary:
So far lldb is printing this when it finds an ambiguous command:
```
(lldb) g
Ambiguous command 'g'. Possible matches:
gdb-remote
gui
gdb-remote
gui
```
The duplicates come from the fact that we call the same query twice with the same parameters
and add it to the same list. This patch just removes the second query call to `GetCommandObject`.
As `GetCommandObject` is const and the name parameter is also not modified, this shouldn't break
anything else. I didn't merge the remaining if statement into the else as I think otherwise the
`if obj==nullptr do X else Y` pattern in there becomes hard to recognize.
Reviewers: davide
Reviewed By: davide
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D49866
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py?rev=338043&r1=338042&r2=338043&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py Thu Jul 26 10:14:18 2018
@@ -26,7 +26,7 @@ class UnknownCommandTestCase(TestBase):
self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. Possible matches:")
self.assertRegexpMatches(result.GetError(), "gui")
self.assertRegexpMatches(result.GetError(), "gdb-remote")
- # FIXME: Somehow we get 'gui' and 'gdb-remote' twice in the output.
+ self.assertEquals(1, result.GetError().count("gdb-remote"))
@no_debug_info_test
def test_unknown_command(self):
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=338043&r1=338042&r2=338043&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jul 26 10:14:18 2018
@@ -2932,8 +2932,6 @@ CommandInterpreter::ResolveCommandImpl(s
actual_cmd_name_len = cmd_obj->GetCommandName().size();
}
} else {
- if (!cmd_obj)
- cmd_obj = GetCommandObject(next_word, &matches);
if (cmd_obj) {
llvm::StringRef cmd_name = cmd_obj->GetCommandName();
actual_cmd_name_len += cmd_name.size();
More information about the lldb-commits
mailing list