summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBCommandReturnObject.h12
-rw-r--r--lldb/scripts/Python/interface/SBCommandReturnObject.i18
-rw-r--r--lldb/source/API/SBCommandReturnObject.cpp42
-rw-r--r--lldb/test/functionalities/command_script/welcome.py5
-rw-r--r--lldb/tools/driver/Driver.cpp16
-rw-r--r--lldb/tools/driver/IOChannel.cpp4
6 files changed, 84 insertions, 13 deletions
diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h
index 1dc632c84cc..5de54f77592 100644
--- a/lldb/include/lldb/API/SBCommandReturnObject.h
+++ b/lldb/include/lldb/API/SBCommandReturnObject.h
@@ -92,6 +92,18 @@ public:
size_t
Printf(const char* format, ...) __attribute__ ((format (printf, 2, 3)));
+ const char *
+ GetOutput (bool only_if_no_immediate);
+
+ const char *
+ GetError (bool only_if_no_immediate);
+
+ size_t
+ GetErrorSize (bool only_if_no_immediate);
+
+ size_t
+ GetOutputSize (bool only_if_no_immediate);
+
protected:
friend class SBCommandInterpreter;
friend class SBOptions;
diff --git a/lldb/scripts/Python/interface/SBCommandReturnObject.i b/lldb/scripts/Python/interface/SBCommandReturnObject.i
index 82c07ee434d..81e85ca8c21 100644
--- a/lldb/scripts/Python/interface/SBCommandReturnObject.i
+++ b/lldb/scripts/Python/interface/SBCommandReturnObject.i
@@ -36,14 +36,26 @@ public:
GetError ();
size_t
- PutOutput (FILE *fh);
-
- size_t
GetOutputSize ();
size_t
GetErrorSize ();
+ const char *
+ GetOutput (bool only_if_no_immediate);
+
+ const char *
+ GetError (bool if_no_immediate);
+
+ size_t
+ GetErrorSize (bool only_if_no_immediate);
+
+ size_t
+ GetOutputSize (bool only_if_no_immediate);
+
+ size_t
+ PutOutput (FILE *fh);
+
size_t
PutError (FILE *fh);
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index 4632009679b..e923bba1041 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -268,7 +268,7 @@ SBCommandReturnObject::SetImmediateOutputFile (FILE *fh)
if (m_opaque_ap.get())
m_opaque_ap->SetImmediateOutputFile (fh);
}
-
+
void
SBCommandReturnObject::SetImmediateErrorFile (FILE *fh)
{
@@ -285,6 +285,46 @@ SBCommandReturnObject::PutCString(const char* string, int len)
}
}
+const char *
+SBCommandReturnObject::GetOutput (bool only_if_no_immediate)
+{
+ if (!m_opaque_ap.get())
+ return NULL;
+ if (only_if_no_immediate == false || m_opaque_ap->GetImmediateOutputStream().get() == NULL)
+ return GetOutput();
+ return NULL;
+}
+
+const char *
+SBCommandReturnObject::GetError (bool only_if_no_immediate)
+{
+ if (!m_opaque_ap.get())
+ return NULL;
+ if (only_if_no_immediate == false || m_opaque_ap->GetImmediateErrorStream().get() == NULL)
+ return GetError();
+ return NULL;
+}
+
+size_t
+SBCommandReturnObject::GetErrorSize (bool only_if_no_immediate)
+{
+ if (!m_opaque_ap.get())
+ return NULL;
+ if (only_if_no_immediate == false || m_opaque_ap->GetImmediateErrorStream().get() == NULL)
+ return GetErrorSize();
+ return NULL;
+}
+
+size_t
+SBCommandReturnObject::GetOutputSize (bool only_if_no_immediate)
+{
+ if (!m_opaque_ap.get())
+ return NULL;
+ if (only_if_no_immediate == false || m_opaque_ap->GetImmediateOutputStream().get() == NULL)
+ return GetOutputSize();
+ return NULL;
+}
+
size_t
SBCommandReturnObject::Printf(const char* format, ...)
{
diff --git a/lldb/test/functionalities/command_script/welcome.py b/lldb/test/functionalities/command_script/welcome.py
index 29bbbc4b57e..da65e6ddbd0 100644
--- a/lldb/test/functionalities/command_script/welcome.py
+++ b/lldb/test/functionalities/command_script/welcome.py
@@ -18,10 +18,11 @@ def target_name_impl(debugger, args, result, dict):
return None
def print_wait_impl(debugger, args, result, dict):
- print 'Trying to do long task..';
+ result.SetImmediateOutputFile(sys.stdout)
+ result.PutCString('Trying to do long task..')
import time
time.sleep(1)
- print 'Still doing long task..';
+ result.PutCString('Still doing long task..')
time.sleep(1)
result.PutCString('Done; if you saw the delays I am doing OK')
return None
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 048faff2147..11db9b27270 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -1020,11 +1020,17 @@ Driver::HandleIOEvent (const SBEvent &event)
// output orderings and problems with the prompt.
m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true);
- if (result.GetOutputSize() > 0)
- m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), NO_ASYNC);
-
- if (result.GetErrorSize() > 0)
- m_io_channel_ap->OutWrite (result.GetError(), result.GetErrorSize(), NO_ASYNC);
+ const bool only_if_no_immediate = true;
+
+ const size_t output_size = result.GetOutputSize(only_if_no_immediate);
+
+ if (output_size > 0)
+ m_io_channel_ap->OutWrite (result.GetOutput(only_if_no_immediate), output_size, NO_ASYNC);
+
+ const size_t error_size = result.GetErrorSize(only_if_no_immediate);
+
+ if (error_size > 0)
+ m_io_channel_ap->OutWrite (result.GetError(only_if_no_immediate), error_size, NO_ASYNC);
// We are done getting and running our command, we can now clear the
// m_waiting_for_command so we can get another one.
diff --git a/lldb/tools/driver/IOChannel.cpp b/lldb/tools/driver/IOChannel.cpp
index b6d4224a790..ade07b003b6 100644
--- a/lldb/tools/driver/IOChannel.cpp
+++ b/lldb/tools/driver/IOChannel.cpp
@@ -528,7 +528,7 @@ IOChannel::RefreshPrompt ()
void
IOChannel::OutWrite (const char *buffer, size_t len, bool asynchronous)
{
- if (len == 0)
+ if (len == 0 || buffer == NULL)
return;
// We're in the process of exiting -- IOChannel::Run() has already completed
@@ -552,7 +552,7 @@ IOChannel::OutWrite (const char *buffer, size_t len, bool asynchronous)
void
IOChannel::ErrWrite (const char *buffer, size_t len, bool asynchronous)
{
- if (len == 0)
+ if (len == 0 || buffer == NULL)
return;
// Use the mutex to make sure OutWrite and ErrWrite do not interfere with each other's output.
OpenPOWER on IntegriCloud