Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===-- SBError.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_SBERROR_H
0010 #define LLDB_API_SBERROR_H
0011 
0012 #include "lldb/API/SBDefines.h"
0013 
0014 namespace lldb_private {
0015 class ScriptInterpreter;
0016 namespace python {
0017 class SWIGBridge;
0018 }
0019 } // namespace lldb_private
0020 
0021 namespace lldb {
0022 
0023 class LLDB_API SBError {
0024 public:
0025   SBError();
0026 
0027   SBError(const lldb::SBError &rhs);
0028 
0029   SBError(const char *message);
0030 
0031   ~SBError();
0032 
0033   const SBError &operator=(const lldb::SBError &rhs);
0034 
0035   /// Get the error string as a NULL terminated UTF8 c-string.
0036   ///
0037   /// This SBError object owns the returned string and this object must be kept
0038   /// around long enough to use the returned string.
0039   const char *GetCString() const;
0040 
0041   void Clear();
0042 
0043   bool Fail() const;
0044 
0045   bool Success() const;
0046 
0047   /// Get the error code.
0048   uint32_t GetError() const;
0049 
0050   /// Get the error in machine-readable form. Particularly useful for
0051   /// compiler diagnostics.
0052   SBStructuredData GetErrorData() const;
0053 
0054   lldb::ErrorType GetType() const;
0055 
0056   void SetError(uint32_t err, lldb::ErrorType type);
0057 
0058   void SetErrorToErrno();
0059 
0060   void SetErrorToGenericError();
0061 
0062   void SetErrorString(const char *err_str);
0063 
0064 #ifndef SWIG
0065   __attribute__((format(printf, 2, 3)))
0066 #else
0067   // clang-format off
0068   %varargs(3, char *str = NULL) SetErrorStringWithFormat;
0069   // clang-format on
0070 #endif
0071   int SetErrorStringWithFormat(const char *format, ...);
0072 
0073   explicit operator bool() const;
0074 
0075   bool IsValid() const;
0076 
0077   bool GetDescription(lldb::SBStream &description);
0078 
0079 protected:
0080   friend class SBBreakpoint;
0081   friend class SBBreakpointLocation;
0082   friend class SBBreakpointName;
0083   friend class SBCommandReturnObject;
0084   friend class SBCommunication;
0085   friend class SBSaveCoreOptions;
0086   friend class SBData;
0087   friend class SBDebugger;
0088   friend class SBFile;
0089   friend class SBFormat;
0090   friend class SBHostOS;
0091   friend class SBPlatform;
0092   friend class SBProcess;
0093   friend class SBReproducer;
0094   friend class SBStructuredData;
0095   friend class SBTarget;
0096   friend class SBThread;
0097   friend class SBTrace;
0098   friend class SBValue;
0099   friend class SBValueList;
0100   friend class SBWatchpoint;
0101 
0102   friend class lldb_private::ScriptInterpreter;
0103   friend class lldb_private::python::SWIGBridge;
0104 
0105   SBError(lldb_private::Status &&error);
0106 
0107   lldb_private::Status *get();
0108 
0109   lldb_private::Status *operator->();
0110 
0111   const lldb_private::Status &operator*() const;
0112 
0113   lldb_private::Status &ref();
0114 
0115   void SetError(lldb_private::Status &&lldb_error);
0116 
0117 private:
0118   std::unique_ptr<lldb_private::Status> m_opaque_up;
0119 
0120   void CreateIfNeeded();
0121 };
0122 
0123 } // namespace lldb
0124 
0125 #endif // LLDB_API_SBERROR_H