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;
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);
if (m_opaque_ap.get())
m_opaque_ap->SetImmediateOutputFile (fh);
}
-
+
void
SBCommandReturnObject::SetImmediateErrorFile (FILE *fh)
{
}
}
+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, ...)
{
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
// 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.
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
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.