LLDB mainline
SBStream.h
Go to the documentation of this file.
1//===-- SBStream.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_API_SBSTREAM_H
10#define LLDB_API_SBSTREAM_H
11
12#include <cstdio>
13
14#include "lldb/API/SBDefines.h"
15
16namespace lldb_private {
17class ScriptInterpreter;
18} // namespace lldb_private
19
20namespace lldb {
21
23public:
24 SBStream();
25
26#ifndef SWIG
27 SBStream(SBStream &&rhs);
28#endif
29
31
32 explicit operator bool() const;
33
34 bool IsValid() const;
35
36 // If this stream is not redirected to a file, it will maintain a local cache
37 // for the stream data which can be accessed using this accessor.
38 const char *GetData();
39
40 // If this stream is not redirected to a file, it will maintain a local cache
41 // for the stream output whose length can be accessed using this accessor.
42 size_t GetSize();
43
44#ifndef SWIG
45 __attribute__((format(printf, 2, 3))) void Printf(const char *format, ...);
46#endif
47
48 void Print(const char *str);
49
50 void RedirectToFile(const char *path, bool append);
51
52 void RedirectToFile(lldb::SBFile file);
53
54 void RedirectToFile(lldb::FileSP file);
55
56#ifndef SWIG
57 void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
58#endif
59
60 void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);
61
62 // If the stream is redirected to a file, forget about the file and if
63 // ownership of the file was transferred to this object, close the file. If
64 // the stream is backed by a local cache, clear this cache.
65 void Clear();
66
67protected:
68 friend class SBAddress;
69 friend class SBAddressRange;
70 friend class SBAddressRangeList;
71 friend class SBBlock;
72 friend class SBBreakpoint;
74 friend class SBBreakpointName;
76 friend class SBCompileUnit;
77 friend class SBData;
78 friend class SBDebugger;
79 friend class SBDeclaration;
80 friend class SBEvent;
81 friend class SBFileSpec;
82 friend class SBFileSpecList;
83 friend class SBFrame;
84 friend class SBFunction;
85 friend class SBInstruction;
86 friend class SBInstructionList;
87 friend class SBLaunchInfo;
88 friend class SBLineEntry;
89 friend class SBMemoryRegionInfo;
90 friend class SBModule;
91 friend class SBModuleSpec;
92 friend class SBModuleSpecList;
93 friend class SBProcess;
94 friend class SBSection;
95 friend class SBSourceManager;
96 friend class SBStructuredData;
97 friend class SBSymbol;
98 friend class SBSymbolContext;
99 friend class SBSymbolContextList;
100 friend class SBTarget;
101 friend class SBThread;
102 friend class SBThreadPlan;
103 friend class SBType;
104 friend class SBTypeEnumMember;
106 friend class SBTypeMember;
107 friend class SBValue;
108 friend class SBWatchpoint;
109
111
112 lldb_private::Stream *operator->();
113
115
117
118private:
119 SBStream(const SBStream &) = delete;
120 const SBStream &operator=(const SBStream &) = delete;
121 std::unique_ptr<lldb_private::Stream> m_opaque_up;
122 bool m_is_file = false;
123};
124
125} // namespace lldb
126
127#endif // LLDB_API_SBSTREAM_H
#define LLDB_API
Definition: SBDefines.h:28
SBStream(const SBStream &)=delete
__attribute__((format(printf, 2, 3))) void Printf(const char *format
const SBStream & operator=(const SBStream &)=delete
std::unique_ptr< lldb_private::Stream > m_opaque_up
Definition: SBStream.h:121
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::File > FileSP
Definition: lldb-forward.h:351