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 {
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
53
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;
77 friend class SBCompileUnit;
78 friend class SBData;
79 friend class SBDebugger;
80 friend class SBDeclaration;
81 friend class SBEvent;
82 friend class SBFileSpec;
83 friend class SBFileSpecList;
84 friend class SBFrame;
85 friend class SBFrameList;
86 friend class SBFunction;
87 friend class SBInstruction;
88 friend class SBInstructionList;
89 friend class SBLaunchInfo;
90 friend class SBLineEntry;
91 friend class SBMemoryRegionInfo;
92 friend class SBModule;
93 friend class SBModuleSpec;
94 friend class SBModuleSpecList;
95 friend class SBProcess;
96 friend class SBSection;
97 friend class SBSourceManager;
98 friend class SBStructuredData;
99 friend class SBSymbol;
100 friend class SBSymbolContext;
102 friend class SBTarget;
103 friend class SBThread;
104 friend class SBThreadPlan;
105 friend class SBType;
106 friend class SBTypeEnumMember;
108 friend class SBTypeMember;
109 friend class SBTypeSummary;
110 friend class SBValue;
111 friend class SBWatchpoint;
112
114
116
118
120
121private:
122 SBStream(const SBStream &) = delete;
123 const SBStream &operator=(const SBStream &) = delete;
124 const char *GetString() const;
125 std::unique_ptr<lldb_private::Stream> m_opaque_up;
126 bool m_is_file = false;
127};
128
129} // namespace lldb
130
131#endif // LLDB_API_SBSTREAM_H
#define LLDB_API
Definition SBDefines.h:28
friend class SBWatchpoint
Definition SBStream.h:111
SBStream(const SBStream &)=delete
friend class SBLaunchInfo
Definition SBStream.h:89
void Print(const char *str)
Definition SBStream.cpp:66
friend class SBStructuredData
Definition SBStream.h:98
size_t GetSize()
Definition SBStream.cpp:57
friend class SBTypeEnumMember
Definition SBStream.h:106
friend class SBCommandReturnObject
Definition SBStream.h:75
friend class SBProcess
Definition SBStream.h:95
const char * GetString() const
Exists so friend classes can use the StringString's data without putting it in the ConstString pool.
Definition SBStream.cpp:201
friend class SBTypeSummary
Definition SBStream.h:109
friend class SBInstruction
Definition SBStream.h:87
friend class SBSymbol
Definition SBStream.h:99
friend class SBDebugger
Definition SBStream.h:79
friend class SBTarget
Definition SBStream.h:102
friend class SBAddressRange
Definition SBStream.h:69
friend class SBModule
Definition SBStream.h:92
__attribute__((format(printf, 2, 3))) void Printf(const char *format
friend class SBBreakpoint
Definition SBStream.h:72
friend class SBSymbolContext
Definition SBStream.h:100
friend class SBDeclaration
Definition SBStream.h:80
friend class SBMemoryRegionInfo
Definition SBStream.h:91
friend class SBModuleSpecList
Definition SBStream.h:94
friend class SBValue
Definition SBStream.h:110
friend class SBAddress
Definition SBStream.h:68
void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership)
Definition SBStream.cpp:154
friend class SBEvent
Definition SBStream.h:81
friend class SBFrameList
Definition SBStream.h:85
friend class SBTypeMemberFunction
Definition SBStream.h:107
void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership)
Definition SBStream.cpp:118
friend class SBThread
Definition SBStream.h:103
friend class SBModuleSpec
Definition SBStream.h:93
friend class SBLineEntry
Definition SBStream.h:90
friend class SBBlock
Definition SBStream.h:71
friend class SBThreadPlan
Definition SBStream.h:104
friend class SBSymbolContextList
Definition SBStream.h:101
lldb_private::Stream & ref()
Definition SBStream.cpp:179
const SBStream & operator=(const SBStream &)=delete
std::unique_ptr< lldb_private::Stream > m_opaque_up
Definition SBStream.h:125
friend class SBFrame
Definition SBStream.h:84
friend class SBTypeMember
Definition SBStream.h:108
friend class SBSection
Definition SBStream.h:96
friend class SBData
Definition SBStream.h:78
void RedirectToFile(const char *path, bool append)
Definition SBStream.cpp:81
friend class SBFunction
Definition SBStream.h:86
friend class SBCompileUnit
Definition SBStream.h:77
friend class SBFileSpecList
Definition SBStream.h:83
friend class SBBreakpointName
Definition SBStream.h:74
friend class SBBreakpointLocation
Definition SBStream.h:73
friend class SBSourceManager
Definition SBStream.h:97
friend class SBAddressRangeList
Definition SBStream.h:70
friend class SBType
Definition SBStream.h:105
const char * GetData()
Definition SBStream.cpp:45
friend class SBInstructionList
Definition SBStream.h:88
lldb_private::Stream * operator->()
Definition SBStream.cpp:175
friend class SBCommandInterpreter
Definition SBStream.h:76
bool IsValid() const
Definition SBStream.cpp:33
friend class SBFileSpec
Definition SBStream.h:82
lldb_private::Stream * get()
Definition SBStream.cpp:177
Unwraps the opaque internal object held by an SB (public API) instance, for scripting-language plugin...
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.
std::shared_ptr< lldb_private::File > FileSP