aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-06-17 22:51:50 +0000
committerEnrico Granata <egranata@apple.com>2013-06-17 22:51:50 +0000
commitb1fb72761226817e7f687eca21cbe9c0a3ec4cf6 (patch)
tree2a9c1d0b2bcd6674d4deca838b5a231e185cf22f /include
parent9ba2772e6cc98ff7bd561c4c1d05ed96d3670de6 (diff)
downloadlldb-b1fb72761226817e7f687eca21cbe9c0a3ec4cf6.tar.gz
<rdar://problem/14134716>
This is a rewrite of the command history facility of LLDB It takes the history management out of the CommandInterpreter into its own CommandHistory class It reimplements the command history command to allow more combinations of options to work correctly (e.g. com hist -c 1 -s 5) It adds a new --wipe (-w) option to command history to allow clearing the history on demand It extends the lldbtest runCmd: and expect: methods to allow adding commands to history if need be It adds a test case for the reimplemented facility git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/lldb/Interpreter/CommandHistory.h76
-rw-r--r--include/lldb/Interpreter/CommandInterpreter.h33
-rw-r--r--include/lldb/Utility/Range.h89
3 files changed, 183 insertions, 15 deletions
diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h
new file mode 100644
index 000000000..5faaf1cb3
--- /dev/null
+++ b/include/lldb/Interpreter/CommandHistory.h
@@ -0,0 +1,76 @@
+//===-- CommandHistory.h ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_CommandHistory_h_
+#define liblldb_CommandHistory_h_
+
+// C Includes
+// C++ Includes
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+
+#include "lldb/lldb-private.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Host/Mutex.h"
+
+namespace lldb_private {
+
+class CommandHistory
+{
+public:
+ CommandHistory ();
+
+ ~CommandHistory ();
+
+ size_t
+ GetSize () const;
+
+ bool
+ IsEmpty () const;
+
+ const char*
+ FindString (const char* input_str) const;
+
+ const char*
+ GetStringAtIndex (size_t idx) const;
+
+ const char*
+ operator [] (size_t idx) const;
+
+ const char*
+ GetRecentmostString () const;
+
+ void
+ AppendString (const std::string& str,
+ bool reject_if_dupe = true);
+
+ void
+ Clear ();
+
+ void
+ Dump (Stream& stream,
+ size_t start_idx = 0,
+ size_t stop_idx = UINT64_MAX) const;
+
+ static const char g_repeat_char = '!';
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(CommandHistory);
+
+ typedef std::vector<std::string> History;
+ mutable Mutex m_mutex;
+ History m_history;
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CommandHistory_h_
diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h
index 0621bf94a..31fcc38ee 100644
--- a/include/lldb/Interpreter/CommandInterpreter.h
+++ b/include/lldb/Interpreter/CommandInterpreter.h
@@ -18,6 +18,7 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
+#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Core/Event.h"
@@ -381,15 +382,6 @@ public:
bool
GetSynchronous ();
- void
- DumpHistory (Stream &stream, uint32_t count) const;
-
- void
- DumpHistory (Stream &stream, uint32_t start, uint32_t end) const;
-
- const char *
- FindHistoryString (const char *input_str) const;
-
size_t
FindLongestCommandWord (CommandObject::CommandMap &dict);
@@ -407,30 +399,42 @@ public:
SetBatchCommandMode (bool value) { m_batch_command_mode = value; }
void
- ChildrenTruncated()
+ ChildrenTruncated ()
{
if (m_truncation_warning == eNoTruncation)
m_truncation_warning = eUnwarnedTruncation;
}
bool
- TruncationWarningNecessary()
+ TruncationWarningNecessary ()
{
return (m_truncation_warning == eUnwarnedTruncation);
}
void
- TruncationWarningGiven()
+ TruncationWarningGiven ()
{
m_truncation_warning = eWarnedTruncation;
}
const char *
- TruncationWarningText()
+ TruncationWarningText ()
{
return "*** Some of your variables have more members than the debugger will show by default. To show all of them, you can either use the --show-all-children option to %s or raise the limit by changing the target.max-children-count setting.\n";
}
+ const CommandHistory&
+ GetCommandHistory () const
+ {
+ return m_command_history;
+ }
+
+ CommandHistory&
+ GetCommandHistory ()
+ {
+ return m_command_history;
+ }
+
//------------------------------------------------------------------
// Properties
//------------------------------------------------------------------
@@ -466,11 +470,10 @@ private:
CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands
CommandObject::CommandMap m_user_dict; // Stores user-defined commands
OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias.
- std::vector<std::string> m_command_history;
+ CommandHistory m_command_history;
std::string m_repeat_command; // Stores the command that will be executed for an empty command string.
std::unique_ptr<ScriptInterpreter> m_script_interpreter_ap;
char m_comment_char;
- char m_repeat_char;
bool m_batch_command_mode;
ChildrenTruncatedWarningStatus m_truncation_warning; // Whether we truncated children and whether the user has been told
uint32_t m_command_source_depth;
diff --git a/include/lldb/Utility/Range.h b/include/lldb/Utility/Range.h
new file mode 100644
index 000000000..1257adb71
--- /dev/null
+++ b/include/lldb/Utility/Range.h
@@ -0,0 +1,89 @@
+//===--------------------- Range.h ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef utility_Range_h_
+#define utility_Range_h_
+
+#include <stdint.h>
+#include <algorithm>
+
+namespace lldb_utility {
+
+class Range
+{
+public:
+
+ typedef uint64_t ValueType;
+
+ static const ValueType OPEN_END = UINT64_MAX;
+
+ Range (const Range& rng);
+
+ Range (ValueType low = 0,
+ ValueType high = OPEN_END);
+
+ Range&
+ operator = (const Range& rhs);
+
+ ValueType
+ GetLow ()
+ {
+ return m_low;
+ }
+
+ ValueType
+ GetHigh ()
+ {
+ return m_high;
+ }
+
+ void
+ SetLow (ValueType low)
+ {
+ m_low = low;
+ }
+
+ void
+ SetHigh (ValueType high)
+ {
+ m_high = high;
+ }
+
+ void
+ Flip ();
+
+ void
+ Intersection (const Range& other);
+
+ void
+ Union (const Range& other);
+
+ typedef bool (*RangeCallback)(ValueType index);
+
+ void
+ Iterate (RangeCallback callback);
+
+ ValueType
+ GetSize ();
+
+ bool
+ IsEmpty ();
+
+private:
+
+ void
+ InitRange ();
+
+ ValueType m_low;
+ ValueType m_high;
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef utility_Range_h_