1969ed3d1SCaroline Tice //===-- StreamBroadcast.cpp -------------------------------------*- C++ -*-===// 2969ed3d1SCaroline Tice // 3969ed3d1SCaroline Tice // The LLVM Compiler Infrastructure 4969ed3d1SCaroline Tice // 5969ed3d1SCaroline Tice // This file is distributed under the University of Illinois Open Source 6969ed3d1SCaroline Tice // License. See LICENSE.TXT for details. 7969ed3d1SCaroline Tice // 8969ed3d1SCaroline Tice //===----------------------------------------------------------------------===// 9969ed3d1SCaroline Tice 10*4446487dSPavel Labath #include "lldb/Core/StreamAsynchronousIO.h" 11969ed3d1SCaroline Tice 12969ed3d1SCaroline Tice #include "lldb/lldb-private.h" 13*4446487dSPavel Labath #include "lldb/Core/Debugger.h" 14969ed3d1SCaroline Tice 15969ed3d1SCaroline Tice using namespace lldb; 16969ed3d1SCaroline Tice using namespace lldb_private; 17969ed3d1SCaroline Tice 18969ed3d1SCaroline Tice 19*4446487dSPavel Labath StreamAsynchronousIO::StreamAsynchronousIO (Debugger &debugger, bool for_stdout) : 20969ed3d1SCaroline Tice Stream (0, 4, eByteOrderBig), 21*4446487dSPavel Labath m_debugger (debugger), 22*4446487dSPavel Labath m_data (), 23*4446487dSPavel Labath m_for_stdout (for_stdout) 24969ed3d1SCaroline Tice { 25969ed3d1SCaroline Tice } 26969ed3d1SCaroline Tice 27969ed3d1SCaroline Tice StreamAsynchronousIO::~StreamAsynchronousIO () 28969ed3d1SCaroline Tice { 2944d93782SGreg Clayton // Flush when we destroy to make sure we display the data 3044d93782SGreg Clayton Flush(); 31969ed3d1SCaroline Tice } 32969ed3d1SCaroline Tice 33969ed3d1SCaroline Tice void 34969ed3d1SCaroline Tice StreamAsynchronousIO::Flush () 35969ed3d1SCaroline Tice { 36*4446487dSPavel Labath if (!m_data.empty()) 37969ed3d1SCaroline Tice { 38*4446487dSPavel Labath m_debugger.PrintAsync (m_data.data(), m_data.size(), m_for_stdout); 39*4446487dSPavel Labath m_data = std::move(std::string()); 40969ed3d1SCaroline Tice } 41969ed3d1SCaroline Tice } 42969ed3d1SCaroline Tice 43c7bece56SGreg Clayton size_t 44969ed3d1SCaroline Tice StreamAsynchronousIO::Write (const void *s, size_t length) 45969ed3d1SCaroline Tice { 46*4446487dSPavel Labath m_data.append ((const char *)s, length); 47969ed3d1SCaroline Tice return length; 48969ed3d1SCaroline Tice } 49