annotate lldb/source/Core/StreamAsynchronousIO.cpp @ 227:21e6aa2e49ef

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 19 Jul 2021 06:57:16 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===-- StreamAsynchronousIO.cpp ------------------------------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #include "lldb/Core/StreamAsynchronousIO.h"
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 #include "lldb/Core/Debugger.h"
anatofuz
parents:
diff changeset
12 #include "lldb/lldb-enumerations.h"
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 using namespace lldb;
anatofuz
parents:
diff changeset
15 using namespace lldb_private;
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout)
anatofuz
parents:
diff changeset
18 : Stream(0, 4, eByteOrderBig), m_debugger(debugger), m_data(),
anatofuz
parents:
diff changeset
19 m_for_stdout(for_stdout) {}
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 StreamAsynchronousIO::~StreamAsynchronousIO() {
anatofuz
parents:
diff changeset
22 // Flush when we destroy to make sure we display the data
anatofuz
parents:
diff changeset
23 Flush();
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 void StreamAsynchronousIO::Flush() {
anatofuz
parents:
diff changeset
27 if (!m_data.empty()) {
anatofuz
parents:
diff changeset
28 m_debugger.PrintAsync(m_data.data(), m_data.size(), m_for_stdout);
anatofuz
parents:
diff changeset
29 m_data = std::string();
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 size_t StreamAsynchronousIO::WriteImpl(const void *s, size_t length) {
anatofuz
parents:
diff changeset
34 m_data.append((const char *)s, length);
anatofuz
parents:
diff changeset
35 return length;
anatofuz
parents:
diff changeset
36 }