This revision was automatically updated to reflect the committed changes. Closed by commit rG8cc8b36f24d6: CommandObjectRegexCommand shouldn't put two commands on the history stack. (authored by jingham).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126789/new/ https://reviews.llvm.org/D126789 Files: lldb/source/Commands/CommandObjectRegexCommand.cpp lldb/test/API/functionalities/history/TestHistoryRecall.py Index: lldb/test/API/functionalities/history/TestHistoryRecall.py =================================================================== --- lldb/test/API/functionalities/history/TestHistoryRecall.py +++ lldb/test/API/functionalities/history/TestHistoryRecall.py @@ -1,5 +1,5 @@ """ -Make sure the !N and !-N commands work properly. +Test some features of "session history" and history recall. """ @@ -20,9 +20,25 @@ def test_history_recall(self): """Test the !N and !-N functionality of the command interpreter.""" - self.sample_test() + self.do_bang_N_test() - def sample_test(self): + def test_regex_history(self): + """Test the regex commands don't add two elements to the history""" + self.do_regex_history_test() + + def do_regex_history_test(self): + interp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + command = "_regexp-break foo.c:12" + self.runCmd(command, msg="Run the regex break command", inHistory = True) + interp.HandleCommand("session history", result, True) + self.assertTrue(result.Succeeded(), "session history ran successfully") + results = result.GetOutput() + self.assertIn(command, results, "Recorded the actual command") + self.assertNotIn("breakpoint set --file 'foo.c' --line 12", results, + "Didn't record the resolved command") + + def do_bang_N_test(self): interp = self.dbg.GetCommandInterpreter() result = lldb.SBCommandReturnObject() interp.HandleCommand("session history", result, True) Index: lldb/source/Commands/CommandObjectRegexCommand.cpp =================================================================== --- lldb/source/Commands/CommandObjectRegexCommand.cpp +++ lldb/source/Commands/CommandObjectRegexCommand.cpp @@ -71,11 +71,10 @@ // Interpret the new command and return this as the result! if (m_interpreter.GetExpandRegexAliases()) result.GetOutputStream().Printf("%s\n", new_command->c_str()); - // Pass in true for "no context switching". The command that called us - // should have set up the context appropriately, we shouldn't have to - // redo that. + // We don't have to pass an override_context here, as the command that + // called us should have set up the context appropriately. return m_interpreter.HandleCommand(new_command->c_str(), - eLazyBoolCalculate, result); + eLazyBoolNo, result); } } result.SetStatus(eReturnStatusFailed);
Index: lldb/test/API/functionalities/history/TestHistoryRecall.py =================================================================== --- lldb/test/API/functionalities/history/TestHistoryRecall.py +++ lldb/test/API/functionalities/history/TestHistoryRecall.py @@ -1,5 +1,5 @@ """ -Make sure the !N and !-N commands work properly. +Test some features of "session history" and history recall. """ @@ -20,9 +20,25 @@ def test_history_recall(self): """Test the !N and !-N functionality of the command interpreter.""" - self.sample_test() + self.do_bang_N_test() - def sample_test(self): + def test_regex_history(self): + """Test the regex commands don't add two elements to the history""" + self.do_regex_history_test() + + def do_regex_history_test(self): + interp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + command = "_regexp-break foo.c:12" + self.runCmd(command, msg="Run the regex break command", inHistory = True) + interp.HandleCommand("session history", result, True) + self.assertTrue(result.Succeeded(), "session history ran successfully") + results = result.GetOutput() + self.assertIn(command, results, "Recorded the actual command") + self.assertNotIn("breakpoint set --file 'foo.c' --line 12", results, + "Didn't record the resolved command") + + def do_bang_N_test(self): interp = self.dbg.GetCommandInterpreter() result = lldb.SBCommandReturnObject() interp.HandleCommand("session history", result, True) Index: lldb/source/Commands/CommandObjectRegexCommand.cpp =================================================================== --- lldb/source/Commands/CommandObjectRegexCommand.cpp +++ lldb/source/Commands/CommandObjectRegexCommand.cpp @@ -71,11 +71,10 @@ // Interpret the new command and return this as the result! if (m_interpreter.GetExpandRegexAliases()) result.GetOutputStream().Printf("%s\n", new_command->c_str()); - // Pass in true for "no context switching". The command that called us - // should have set up the context appropriately, we shouldn't have to - // redo that. + // We don't have to pass an override_context here, as the command that + // called us should have set up the context appropriately. return m_interpreter.HandleCommand(new_command->c_str(), - eLazyBoolCalculate, result); + eLazyBoolNo, result); } } result.SetStatus(eReturnStatusFailed);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits