-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Caroline Tice
committed
May 2, 2011
1 parent
f897d3b
commit 969ed3d
Showing
25 changed files
with
351 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//===-- StreamAsynchronousIO.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_StreamAsynchronousIO_h_ | ||
#define liblldb_StreamAsynchronousIO_h_ | ||
|
||
#include <string> | ||
|
||
#include "lldb/Core/Stream.h" | ||
#include "lldb/Core/StreamString.h" | ||
|
||
namespace lldb_private { | ||
|
||
class StreamAsynchronousIO : | ||
public Stream | ||
{ | ||
public: | ||
StreamAsynchronousIO (Broadcaster &broadcaster, uint32_t broadcast_event_type); | ||
|
||
virtual ~StreamAsynchronousIO (); | ||
|
||
virtual void | ||
Flush (); | ||
|
||
virtual int | ||
Write (const void *src, size_t src_len); | ||
|
||
|
||
private: | ||
Broadcaster &m_broadcaster; | ||
uint32_t m_broadcast_event_type; | ||
StreamString m_accumulated_data; | ||
}; | ||
|
||
} // namespace lldb_private | ||
#endif // #ifndef liblldb_StreamAsynchronousIO_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===-- StreamBroadcast.cpp -------------------------------------*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <stdio.h> | ||
|
||
#include "lldb/lldb-private.h" | ||
#include "lldb/Core/Broadcaster.h" | ||
#include "lldb/Core/Event.h" | ||
#include "lldb/Core/StreamAsynchronousIO.h" | ||
|
||
using namespace lldb; | ||
using namespace lldb_private; | ||
|
||
|
||
StreamAsynchronousIO::StreamAsynchronousIO (Broadcaster &broadcaster, uint32_t broadcast_event_type) : | ||
Stream (0, 4, eByteOrderBig), | ||
m_broadcaster (broadcaster), | ||
m_broadcast_event_type (broadcast_event_type), | ||
m_accumulated_data () | ||
{ | ||
} | ||
|
||
StreamAsynchronousIO::~StreamAsynchronousIO () | ||
{ | ||
} | ||
|
||
void | ||
StreamAsynchronousIO::Flush () | ||
{ | ||
if (m_accumulated_data.GetSize() > 0) | ||
{ | ||
std::auto_ptr<EventDataBytes> data_bytes_ap (new EventDataBytes); | ||
// Let's swap the bytes to avoid LARGE string copies. | ||
data_bytes_ap->SwapBytes (m_accumulated_data.GetString()); | ||
EventSP new_event_sp (new Event (m_broadcast_event_type, data_bytes_ap.release())); | ||
m_broadcaster.BroadcastEvent (new_event_sp); | ||
m_accumulated_data.Clear(); | ||
} | ||
} | ||
|
||
int | ||
StreamAsynchronousIO::Write (const void *s, size_t length) | ||
{ | ||
m_accumulated_data.Write (s, length); | ||
return length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.