Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:42

0001 //===-- SBStream.h ----------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_API_SBSTREAM_H
0010 #define LLDB_API_SBSTREAM_H
0011 
0012 #include <cstdio>
0013 
0014 #include "lldb/API/SBDefines.h"
0015 
0016 namespace lldb_private {
0017 class ScriptInterpreter;
0018 } // namespace lldb_private
0019 
0020 namespace lldb {
0021 
0022 class LLDB_API SBStream {
0023 public:
0024   SBStream();
0025 
0026 #ifndef SWIG
0027   SBStream(SBStream &&rhs);
0028 #endif
0029 
0030   ~SBStream();
0031 
0032   explicit operator bool() const;
0033 
0034   bool IsValid() const;
0035 
0036   // If this stream is not redirected to a file, it will maintain a local cache
0037   // for the stream data which can be accessed using this accessor.
0038   const char *GetData();
0039 
0040   // If this stream is not redirected to a file, it will maintain a local cache
0041   // for the stream output whose length can be accessed using this accessor.
0042   size_t GetSize();
0043 
0044 #ifndef SWIG
0045   __attribute__((format(printf, 2, 3))) void Printf(const char *format, ...);
0046 #endif
0047 
0048   void Print(const char *str);
0049 
0050   void RedirectToFile(const char *path, bool append);
0051 
0052   void RedirectToFile(lldb::SBFile file);
0053 
0054   void RedirectToFile(lldb::FileSP file);
0055 
0056 #ifndef SWIG
0057   void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
0058 #endif
0059 
0060   void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);
0061 
0062   // If the stream is redirected to a file, forget about the file and if
0063   // ownership of the file was transferred to this object, close the file. If
0064   // the stream is backed by a local cache, clear this cache.
0065   void Clear();
0066 
0067 protected:
0068   friend class SBAddress;
0069   friend class SBAddressRange;
0070   friend class SBAddressRangeList;
0071   friend class SBBlock;
0072   friend class SBBreakpoint;
0073   friend class SBBreakpointLocation;
0074   friend class SBBreakpointName;
0075   friend class SBCommandReturnObject;
0076   friend class SBCompileUnit;
0077   friend class SBData;
0078   friend class SBDebugger;
0079   friend class SBDeclaration;
0080   friend class SBEvent;
0081   friend class SBFileSpec;
0082   friend class SBFileSpecList;
0083   friend class SBFrame;
0084   friend class SBFunction;
0085   friend class SBInstruction;
0086   friend class SBInstructionList;
0087   friend class SBLaunchInfo;
0088   friend class SBLineEntry;
0089   friend class SBMemoryRegionInfo;
0090   friend class SBModule;
0091   friend class SBModuleSpec;
0092   friend class SBModuleSpecList;
0093   friend class SBProcess;
0094   friend class SBSection;
0095   friend class SBSourceManager;
0096   friend class SBStructuredData;
0097   friend class SBSymbol;
0098   friend class SBSymbolContext;
0099   friend class SBSymbolContextList;
0100   friend class SBTarget;
0101   friend class SBThread;
0102   friend class SBThreadPlan;
0103   friend class SBType;
0104   friend class SBTypeEnumMember;
0105   friend class SBTypeMemberFunction;
0106   friend class SBTypeMember;
0107   friend class SBValue;
0108   friend class SBWatchpoint;
0109 
0110   friend class lldb_private::ScriptInterpreter;
0111 
0112   lldb_private::Stream *operator->();
0113 
0114   lldb_private::Stream *get();
0115 
0116   lldb_private::Stream &ref();
0117 
0118 private:
0119   SBStream(const SBStream &) = delete;
0120   const SBStream &operator=(const SBStream &) = delete;
0121   std::unique_ptr<lldb_private::Stream> m_opaque_up;
0122   bool m_is_file = false;
0123 };
0124 
0125 } // namespace lldb
0126 
0127 #endif // LLDB_API_SBSTREAM_H