[Lldb-commits] [lldb] r300785 - Fix !N and !-N commands and add a test case.
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 19 16:21:05 PDT 2017
Author: jingham
Date: Wed Apr 19 18:21:04 2017
New Revision: 300785
URL: http://llvm.org/viewvc/llvm-project?rev=300785&view=rev
Log:
Fix !N and !-N commands and add a test case.
<rdar://problem/31713267>
Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/
lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py
Modified:
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Interpreter/CommandHistory.cpp
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py?rev=300785&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py Wed Apr 19 18:21:04 2017
@@ -0,0 +1,45 @@
+"""
+Make sure the !N and !-N commands work properly.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestHistoryRecall(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_history_recall(self):
+ """Test the !N and !-N functionality of the command interpreter."""
+ self.sample_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def sample_test(self):
+ interp = self.dbg.GetCommandInterpreter()
+ result = lldb.SBCommandReturnObject()
+ interp.HandleCommand("command history", result, True)
+ interp.HandleCommand("platform list", result, True)
+
+ interp.HandleCommand("!0", result, False)
+ self.assertTrue(result.Succeeded(), "!0 command did not work: %s"%(result.GetError()))
+ self.assertTrue("command history" in result.GetOutput(), "!0 didn't rerun command history")
+
+ interp.HandleCommand("!-1", result, False)
+ self.assertTrue(result.Succeeded(), "!-1 command did not work: %s"%(result.GetError()))
+ self.assertTrue("host:" in result.GetOutput(), "!-1 didn't rerun platform list.")
Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=300785&r1=300784&r2=300785&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Apr 19 18:21:04 2017
@@ -50,7 +50,11 @@ class CommandObjectCommandsHistory : pub
public:
CommandObjectCommandsHistory(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "command history",
- "Dump the history of commands in this session.",
+ "Dump the history of commands in this session.\n"
+ "Commands in the history list can be run again "
+ "using \"!<INDEX>\". \"!-<OFFSET>\" will re-run "
+ "the command that is <OFFSET> commands from the end"
+ " of the list (counting the current command).",
nullptr),
m_options() {}
Modified: lldb/trunk/source/Interpreter/CommandHistory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandHistory.cpp?rev=300785&r1=300784&r2=300785&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandHistory.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandHistory.cpp Wed Apr 19 18:21:04 2017
@@ -47,13 +47,13 @@ CommandHistory::FindString(llvm::StringR
size_t idx = 0;
if (input_str.front() == '-') {
- if (input_str.drop_front(2).getAsInteger(0, idx))
+ if (input_str.drop_front(1).getAsInteger(0, idx))
return llvm::None;
if (idx >= m_history.size())
return llvm::None;
idx = m_history.size() - idx;
} else {
- if (input_str.drop_front().getAsInteger(0, idx))
+ if (input_str.getAsInteger(0, idx))
return llvm::None;
if (idx >= m_history.size())
return llvm::None;
More information about the lldb-commits
mailing list