summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Target.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2011-05-02 20:41:46 +0000
committerCaroline Tice <ctice@apple.com>2011-05-02 20:41:46 +0000
commit969ed3d10f2bed3ef9c4d53114594827fefecf68 (patch)
treeb7055dc7c40247fe6accf64529b215cd455b6f30 /lldb/source/Target/Target.cpp
parentf897d3b88bf5b09b7aa142e2033146bdeda5316f (diff)
downloadbcm5719-llvm-969ed3d10f2bed3ef9c4d53114594827fefecf68.tar.gz
bcm5719-llvm-969ed3d10f2bed3ef9c4d53114594827fefecf68.zip
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by editline, the asynchronous process output & error messages, and asynchronous messages written by target stop-hooks. As part of this it introduces a new Stream class, StreamAsynchronousIO. A StreamAsynchronousIO object is created with a broadcaster, who will eventually broadcast the stream's data for a listener to handle, and an event type indicating what type of event the broadcaster will broadcast. When the Write method is called on a StreamAsynchronousIO object, the data is appended to an internal string. When the Flush method is called on a StreamAsynchronousIO object, it broadcasts it's data string and clears the string. Anything in lldb-core that needs to generate asynchronous output for the end-user should use the StreamAsynchronousIO objects. I have also added a new notification type for InputReaders, to let them know that a asynchronous output has been written. This is to allow the input readers to, for example, refresh their prompts and lines, if desired. I added the case statements to all the input readers to catch this notification, but I haven't added any code for handling them yet (except to the IOChannel input reader). llvm-svn: 130721
Diffstat (limited to 'lldb/source/Target/Target.cpp')
-rw-r--r--lldb/source/Target/Target.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 11804798490..a023bf5b764 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -20,6 +20,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamAsynchronousIO.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
@@ -1104,8 +1105,12 @@ Target::RunStopHooks ()
if (num_exe_ctx == 0)
return;
- result.SetImmediateOutputFile (m_debugger.GetOutputFile().GetStream());
- result.SetImmediateErrorFile (m_debugger.GetErrorFile().GetStream());
+ StreamSP output_stream (new StreamAsynchronousIO (m_debugger.GetCommandInterpreter(),
+ CommandInterpreter::eBroadcastBitAsynchronousOutputData));
+ StreamSP error_stream (new StreamAsynchronousIO (m_debugger.GetCommandInterpreter(),
+ CommandInterpreter::eBroadcastBitAsynchronousErrorData));
+ result.SetImmediateOutputStream (output_stream);
+ result.SetImmediateErrorStream (error_stream);
bool keep_going = true;
bool hooks_ran = false;
@@ -1176,6 +1181,9 @@ Target::RunStopHooks ()
}
if (hooks_ran)
result.AppendMessage ("\n** End Stop Hooks **\n");
+
+ result.GetImmediateOutputStream()->Flush();
+ result.GetImmediateErrorStream()->Flush();
}
//--------------------------------------------------------------
OpenPOWER on IntegriCloud