Coverage Report

Created: 2022-01-25 06:29

/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
    : Stream(0, 4, eByteOrderBig), m_debugger(debugger), m_data(),
19
3.67k
      m_for_stdout(for_stdout) {}
20
21
3.67k
StreamAsynchronousIO::~StreamAsynchronousIO() {
22
  // Flush when we destroy to make sure we display the data
23
3.67k
  Flush();
24
3.67k
}
25
26
6.36k
void StreamAsynchronousIO::Flush() {
27
6.36k
  if (!m_data.empty()) {
28
268
    m_debugger.PrintAsync(m_data.data(), m_data.size(), m_for_stdout);
29
268
    m_data = std::string();
30
268
  }
31
6.36k
}
32
33
978
size_t StreamAsynchronousIO::WriteImpl(const void *s, size_t length) {
34
978
  m_data.append((const char *)s, length);
35
978
  return length;
36
978
}