/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp
Line | Count | Source |
1 | | //===-- StreamAsynchronousIO.cpp ------------------------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "lldb/Core/StreamAsynchronousIO.h" |
10 | | |
11 | | #include "lldb/Core/Debugger.h" |
12 | | #include "lldb/lldb-enumerations.h" |
13 | | |
14 | | using namespace lldb; |
15 | | using namespace lldb_private; |
16 | | |
17 | | StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout, |
18 | | bool colors) |
19 | 7.46k | : Stream(0, 4, eByteOrderBig, colors), m_debugger(debugger), m_data(), |
20 | 7.46k | m_for_stdout(for_stdout) {} |
21 | | |
22 | 7.46k | StreamAsynchronousIO::~StreamAsynchronousIO() { |
23 | | // Flush when we destroy to make sure we display the data |
24 | 7.46k | Flush(); |
25 | 7.46k | } |
26 | | |
27 | 12.6k | void StreamAsynchronousIO::Flush() { |
28 | 12.6k | if (!m_data.empty()) { |
29 | 2.48k | m_debugger.PrintAsync(m_data.data(), m_data.size(), m_for_stdout); |
30 | 2.48k | m_data = std::string(); |
31 | 2.48k | } |
32 | 12.6k | } |
33 | | |
34 | 8.97k | size_t StreamAsynchronousIO::WriteImpl(const void *s, size_t length) { |
35 | 8.97k | m_data.append((const char *)s, length); |
36 | 8.97k | return length; |
37 | 8.97k | } |