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