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;
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
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
friend class SBWatchpoint
Definition SBStream.h:108
SBStream(const SBStream &)=delete
friend class SBLaunchInfo
Definition SBStream.h:87
void Print(const char *str)
Definition SBStream.cpp:65
friend class SBStructuredData
Definition SBStream.h:96
size_t GetSize()
Definition SBStream.cpp:56
friend class SBTypeEnumMember
Definition SBStream.h:104
friend class SBCommandReturnObject
Definition SBStream.h:75
friend class SBProcess
Definition SBStream.h:93
friend class SBInstruction
Definition SBStream.h:85
friend class SBSymbol
Definition SBStream.h:97
friend class SBDebugger
Definition SBStream.h:78
friend class SBTarget
Definition SBStream.h:100
friend class SBAddressRange
Definition SBStream.h:69
friend class SBModule
Definition SBStream.h:90
__attribute__((format(printf, 2, 3))) void Printf(const char *format
friend class SBBreakpoint
Definition SBStream.h:72
friend class SBSymbolContext
Definition SBStream.h:98
friend class SBDeclaration
Definition SBStream.h:79
friend class SBMemoryRegionInfo
Definition SBStream.h:89
friend class SBModuleSpecList
Definition SBStream.h:92
friend class SBValue
Definition SBStream.h:107
friend class SBAddress
Definition SBStream.h:68
void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership)
Definition SBStream.cpp:152
friend class SBEvent
Definition SBStream.h:80
friend class SBTypeMemberFunction
Definition SBStream.h:105
void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership)
Definition SBStream.cpp:117
friend class SBThread
Definition SBStream.h:101
friend class SBModuleSpec
Definition SBStream.h:91
friend class SBLineEntry
Definition SBStream.h:88
friend class SBBlock
Definition SBStream.h:71
friend class SBThreadPlan
Definition SBStream.h:102
friend class SBSymbolContextList
Definition SBStream.h:99
lldb_private::Stream & ref()
Definition SBStream.cpp:177
const SBStream & operator=(const SBStream &)=delete
std::unique_ptr< lldb_private::Stream > m_opaque_up
Definition SBStream.h:121
friend class SBFrame
Definition SBStream.h:83
friend class SBTypeMember
Definition SBStream.h:106
friend class SBSection
Definition SBStream.h:94
friend class SBData
Definition SBStream.h:77
void RedirectToFile(const char *path, bool append)
Definition SBStream.cpp:80
friend class SBFunction
Definition SBStream.h:84
friend class SBCompileUnit
Definition SBStream.h:76
friend class SBFileSpecList
Definition SBStream.h:82
friend class SBBreakpointName
Definition SBStream.h:74
friend class SBBreakpointLocation
Definition SBStream.h:73
friend class SBSourceManager
Definition SBStream.h:95
friend class SBAddressRangeList
Definition SBStream.h:70
friend class SBType
Definition SBStream.h:103
const char * GetData()
Definition SBStream.cpp:44
friend class SBInstructionList
Definition SBStream.h:86
lldb_private::Stream * operator->()
Definition SBStream.cpp:173
bool IsValid() const
Definition SBStream.cpp:32
friend class SBFileSpec
Definition SBStream.h:81
lldb_private::Stream * get()
Definition SBStream.cpp:175
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