Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Core/StreamBuffer.h
Line
Count
Source (jump to first uncovered line)
1
//===-- StreamBuffer.h ------------------------------------------*- C++ -*-===//
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
#ifndef LLDB_CORE_STREAMBUFFER_H
10
#define LLDB_CORE_STREAMBUFFER_H
11
12
#include "lldb/Utility/Stream.h"
13
#include "llvm/ADT/SmallVector.h"
14
#include <cstdio>
15
#include <string>
16
17
namespace lldb_private {
18
19
template <unsigned N> class StreamBuffer : public Stream {
20
public:
21
0
  StreamBuffer() : Stream(0, 4, lldb::eByteOrderBig), m_packet() {}
22
23
  StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order)
24
15
      : Stream(flags, addr_size, byte_order), m_packet() {}
lldb_private::StreamBuffer<32u>::StreamBuffer(unsigned int, unsigned int, lldb::ByteOrder)
Line
Count
Source
24
15
      : Stream(flags, addr_size, byte_order), m_packet() {}
Unexecuted instantiation: lldb_private::StreamBuffer<4096u>::StreamBuffer(unsigned int, unsigned int, lldb::ByteOrder)
25
26
15
  ~StreamBuffer() override = default;
lldb_private::StreamBuffer<32u>::~StreamBuffer()
Line
Count
Source
26
15
  ~StreamBuffer() override = default;
Unexecuted instantiation: lldb_private::StreamBuffer<4096u>::~StreamBuffer()
27
28
0
  void Flush() override {
29
    // Nothing to do when flushing a buffer based stream...
30
0
  }
Unexecuted instantiation: lldb_private::StreamBuffer<32u>::Flush()
Unexecuted instantiation: lldb_private::StreamBuffer<4096u>::Flush()
31
32
0
  void Clear() { m_packet.clear(); }
33
34
  // Beware, this might not be NULL terminated as you can expect from
35
  // StringString as there may be random bits in the llvm::SmallVector. If you
36
  // are using this class to create a C string, be sure the call PutChar ('\0')
37
  // after you have created your string, or use StreamString.
38
4
  const char *GetData() const { return m_packet.data(); }
lldb_private::StreamBuffer<32u>::GetData() const
Line
Count
Source
38
4
  const char *GetData() const { return m_packet.data(); }
Unexecuted instantiation: lldb_private::StreamBuffer<4096u>::GetData() const
39
40
15
  size_t GetSize() const { return m_packet.size(); }
lldb_private::StreamBuffer<32u>::GetSize() const
Line
Count
Source
40
15
  size_t GetSize() const { return m_packet.size(); }
Unexecuted instantiation: lldb_private::StreamBuffer<4096u>::GetSize() const
41
42
protected:
43
  llvm::SmallVector<char, N> m_packet;
44
45
21
  size_t WriteImpl(const void *s, size_t length) override {
46
21
    if (s && length)
47
21
      m_packet.append((const char *)s, ((const char *)s) + length);
48
21
    return length;
49
21
  }
lldb_private::StreamBuffer<32u>::WriteImpl(void const*, unsigned long)
Line
Count
Source
45
21
  size_t WriteImpl(const void *s, size_t length) override {
46
21
    if (s && length)
47
21
      m_packet.append((const char *)s, ((const char *)s) + length);
48
21
    return length;
49
21
  }
Unexecuted instantiation: lldb_private::StreamBuffer<4096u>::WriteImpl(void const*, unsigned long)
50
};
51
52
} // namespace lldb_private
53
54
#endif // LLDB_CORE_STREAMBUFFER_H