Author: Gongyu Deng Date: 2020-03-06T10:44:00-08:00 New Revision: ec31255c00808dac40710173162f22e4ee89a2fe
URL: https://github.com/llvm/llvm-project/commit/ec31255c00808dac40710173162f22e4ee89a2fe DIFF: https://github.com/llvm/llvm-project/commit/ec31255c00808dac40710173162f22e4ee89a2fe.diff LOG: [lldb] Update the current execution context at the beginning of tab completions Summary: Fix a bug that tab completions won't synchronous the current execution context. ( Thanks for Jim's explanation! ) Reviewers: teemperor, labath, jingham Reviewed By: jingham Subscribers: jingham, labath Tags: #lldb Differential Revision: https://reviews.llvm.org/D75597 Added: Modified: lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: ################################################################################ diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index c2c70dc8aaa0..65b3cf535bfc 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1837,6 +1837,8 @@ void CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) { void CommandInterpreter::HandleCompletion(CompletionRequest &request) { + UpdateExecutionContext(nullptr); + // Don't complete comments, and if the line we are completing is just the // history repeat character, substitute the appropriate history line. llvm::StringRef first_arg = request.GetParsedLine().GetArgumentAtIndex(0); diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index b87ca44c9943..01fa86750b12 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -267,6 +267,9 @@ void CommandObject::Cleanup() { } void CommandObject::HandleCompletion(CompletionRequest &request) { + + m_exe_ctx = m_interpreter.GetExecutionContext(); + // Default implementation of WantsCompletion() is !WantsRawCommandString(). // Subclasses who want raw command string but desire, for example, argument // completion should override WantsCompletion() to return true, instead. @@ -293,6 +296,8 @@ void CommandObject::HandleCompletion(CompletionRequest &request) { // If we got here, the last word is not an option or an option argument. HandleArgumentCompletion(request, opt_element_vector); } + + m_exe_ctx.Clear(); } bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word, diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 9e15b5d3f557..1156650c78f8 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -43,9 +43,10 @@ def test_frame_variable(self): (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, '// Break here', self.main_source_spec) self.assertEquals(process.GetState(), lldb.eStateStopped) - # FIXME: This pulls in the debug information to make the completions work, - # but the completions should also work without. - self.runCmd("frame variable fooo") + + # Since CommandInterpreter has been corrected to update the current execution + # context at the beginning of HandleCompletion, we're here explicitly testing + # the scenario where "frame var" is completed without any preceding commands. self.complete_from_to('frame variable fo', 'frame variable fooo') _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits