Don't limit StreamTee to just two streams. It now can contain
N streams by making the stream a vector of stream shared pointers
that is protected by a mutex. Streams can be get/set by index which
allows indexes to be defined as stream indentifiers. If a stream is
set at index 3 and there are now streams in the collection, then
empty stream objects are inserted to ensure that stream at index 3
has a valid stream. There is also an append method that allows a stream
to be pushed onto the stack. This will allow our streams to be very
flexible in where the output goes.
Modified the CommandReturnObject to use the new StreamTee functionality.
This class now defines two StreamTee indexes: 0 for the stream string
stream, and 1 for the immediate stream. This is used both on the output
and error streams.
Added the ability to get argument types as strings or as descriptions.
This is exported through the SBCommandInterpreter API to allow external
access.
Modified the Driver class to use the newly exported argument names from
SBCommandInterpreter::GetArgumentTypeAsCString().
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126067 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index ddd26cf..443545d 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -292,3 +292,17 @@
return broadcaster;
}
+const char *
+SBCommandInterpreter::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
+{
+ return CommandObject::GetArgumentTypeAsCString (arg_type);
+}
+
+const char *
+SBCommandInterpreter::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
+{
+ return CommandObject::GetArgumentDescriptionAsCString (arg_type);
+}
+
+
+
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index a690670..fbe47d2 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -92,27 +92,27 @@
LoadCommandDictionary ();
// Set up some initial aliases.
- result.Clear(); HandleCommand ("command alias q quit", false, result);
- result.Clear(); HandleCommand ("command alias run process launch --", false, result);
- result.Clear(); HandleCommand ("command alias r process launch --", false, result);
- result.Clear(); HandleCommand ("command alias c process continue", false, result);
- result.Clear(); HandleCommand ("command alias continue process continue", false, result);
- result.Clear(); HandleCommand ("command alias expr expression", false, result);
- result.Clear(); HandleCommand ("command alias exit quit", false, result);
- result.Clear(); HandleCommand ("command alias b regexp-break", false, result);
- result.Clear(); HandleCommand ("command alias bt thread backtrace", false, result);
- result.Clear(); HandleCommand ("command alias si thread step-inst", false, result);
- result.Clear(); HandleCommand ("command alias step thread step-in", false, result);
- result.Clear(); HandleCommand ("command alias s thread step-in", false, result);
- result.Clear(); HandleCommand ("command alias next thread step-over", false, result);
- result.Clear(); HandleCommand ("command alias n thread step-over", false, result);
- result.Clear(); HandleCommand ("command alias finish thread step-out", false, result);
- result.Clear(); HandleCommand ("command alias x memory read", false, result);
- result.Clear(); HandleCommand ("command alias l source list", false, result);
- result.Clear(); HandleCommand ("command alias list source list", false, result);
- result.Clear(); HandleCommand ("command alias p frame variable", false, result);
- result.Clear(); HandleCommand ("command alias print frame variable", false, result);
- result.Clear(); HandleCommand ("command alias po expression -o --", false, result);
+ HandleCommand ("command alias q quit", false, result);
+ HandleCommand ("command alias run process launch --", false, result);
+ HandleCommand ("command alias r process launch --", false, result);
+ HandleCommand ("command alias c process continue", false, result);
+ HandleCommand ("command alias continue process continue", false, result);
+ HandleCommand ("command alias expr expression", false, result);
+ HandleCommand ("command alias exit quit", false, result);
+ HandleCommand ("command alias b regexp-break", false, result);
+ HandleCommand ("command alias bt thread backtrace", false, result);
+ HandleCommand ("command alias si thread step-inst", false, result);
+ HandleCommand ("command alias step thread step-in", false, result);
+ HandleCommand ("command alias s thread step-in", false, result);
+ HandleCommand ("command alias next thread step-over", false, result);
+ HandleCommand ("command alias n thread step-over", false, result);
+ HandleCommand ("command alias finish thread step-out", false, result);
+ HandleCommand ("command alias x memory read", false, result);
+ HandleCommand ("command alias l source list", false, result);
+ HandleCommand ("command alias list source list", false, result);
+ HandleCommand ("command alias p frame variable", false, result);
+ HandleCommand ("command alias print frame variable", false, result);
+ HandleCommand ("command alias po expression -o --", false, result);
}
const char *
@@ -1517,9 +1517,6 @@
CommandReturnObject &result)
{
size_t num_lines = commands.GetSize();
- CommandReturnObject tmp_result;
- tmp_result.SetImmediateOutputStream (result.GetImmediateOutputStream ());
- tmp_result.SetImmediateErrorStream (result.GetImmediateErrorStream ());
// If we are going to continue past a "continue" then we need to run the commands synchronously.
// Make sure you reset this value anywhere you return from the function.
@@ -1543,7 +1540,6 @@
if (cmd[0] == '\0')
continue;
- tmp_result.Clear();
if (echo_commands)
{
result.AppendMessageWithFormat ("%s %s\n",
@@ -1551,6 +1547,9 @@
cmd);
}
+ CommandReturnObject tmp_result;
+ tmp_result.SetImmediateOutputStream (result.GetImmediateOutputStream ());
+ tmp_result.SetImmediateErrorStream (result.GetImmediateErrorStream ());
bool success = HandleCommand(cmd, false, tmp_result, NULL);
if (print_results)
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 2f88a48..b0446d0 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -600,6 +600,23 @@
return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. This can be done through several mechanisms. The easiest way is to just enter a space-separated list of breakpoint ids. To specify all the breakpoint locations under a major breakpoint, you can use the major breakpoint number followed by '.*', eg. '5.*' means all the locations under breakpoint 5. You can also indicate a range of breakpoints by using <start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can be any valid breakpoint ids. It is not legal, however, to specify a range using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7 is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal.";
}
+const char *
+CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
+{
+ if (arg_type >=0 && arg_type < eArgTypeLastArg)
+ return g_arguments_data[arg_type].arg_name;
+ return NULL;
+
+}
+
+const char *
+CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
+{
+ if (arg_type >=0 && arg_type < eArgTypeLastArg)
+ return g_arguments_data[arg_type].help_text;
+ return NULL;
+}
+
CommandObject::ArgumentTableEntry
CommandObject::g_arguments_data[] =
{
@@ -667,6 +684,8 @@
const CommandObject::ArgumentTableEntry*
CommandObject::GetArgumentTable ()
{
+ // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration
+ assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
return CommandObject::g_arguments_data;
}
diff --git a/source/Interpreter/CommandReturnObject.cpp b/source/Interpreter/CommandReturnObject.cpp
index 3faf912..9d32279 100644
--- a/source/Interpreter/CommandReturnObject.cpp
+++ b/source/Interpreter/CommandReturnObject.cpp
@@ -19,10 +19,8 @@
using namespace lldb_private;
CommandReturnObject::CommandReturnObject () :
- m_error_stream_string_sp (),
- m_output_stream_string_sp (),
- m_output_stream (),
- m_error_stream (),
+ m_out_stream (),
+ m_err_stream (),
m_status (eReturnStatusStarted),
m_did_change_process_state (false)
{
@@ -145,11 +143,15 @@
void
CommandReturnObject::Clear()
{
- if (m_output_stream_string_sp)
- static_cast<StreamString *>(m_output_stream_string_sp.get())->Clear();
- if (m_error_stream_string_sp)
- static_cast<StreamString *>(m_error_stream_string_sp.get())->Clear();
+ lldb::StreamSP stream_sp;
+ stream_sp = m_out_stream.GetStreamAtIndex (eStreamStringIndex);
+ if (stream_sp)
+ static_cast<StreamString *>(stream_sp.get())->Clear();
+ stream_sp = m_err_stream.GetStreamAtIndex (eStreamStringIndex);
+ if (stream_sp)
+ static_cast<StreamString *>(stream_sp.get())->Clear();
m_status = eReturnStatusStarted;
+ m_did_change_process_state = false;
}
bool