10b57cec5SDimitry Andric //===-- SBError.h -----------------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 95ffd83dbSDimitry Andric #ifndef LLDB_API_SBERROR_H 105ffd83dbSDimitry Andric #define LLDB_API_SBERROR_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "lldb/API/SBDefines.h" 130b57cec5SDimitry Andric 14fe6060f1SDimitry Andric namespace lldb_private { 15fe6060f1SDimitry Andric class ScriptInterpreter; 1606c3fb27SDimitry Andric namespace python { 1706c3fb27SDimitry Andric class SWIGBridge; 1806c3fb27SDimitry Andric } 19fe6060f1SDimitry Andric } // namespace lldb_private 20fe6060f1SDimitry Andric 210b57cec5SDimitry Andric namespace lldb { 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric class LLDB_API SBError { 240b57cec5SDimitry Andric public: 250b57cec5SDimitry Andric SBError(); 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric SBError(const lldb::SBError &rhs); 280b57cec5SDimitry Andric 2906c3fb27SDimitry Andric SBError(const char *message); 30bdd1243dSDimitry Andric 310b57cec5SDimitry Andric ~SBError(); 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric const SBError &operator=(const lldb::SBError &rhs); 340b57cec5SDimitry Andric 35bdd1243dSDimitry Andric /// Get the error string as a NULL terminated UTF8 c-string. 36bdd1243dSDimitry Andric /// 37bdd1243dSDimitry Andric /// This SBError object owns the returned string and this object must be kept 38bdd1243dSDimitry Andric /// around long enough to use the returned string. 390b57cec5SDimitry Andric const char *GetCString() const; 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric void Clear(); 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric bool Fail() const; 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric bool Success() const; 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric uint32_t GetError() const; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric lldb::ErrorType GetType() const; 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric void SetError(uint32_t err, lldb::ErrorType type); 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric void SetErrorToErrno(); 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric void SetErrorToGenericError(); 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric void SetErrorString(const char *err_str); 580b57cec5SDimitry Andric 5906c3fb27SDimitry Andric #ifndef SWIG 6006c3fb27SDimitry Andric __attribute__((format(printf, 2, 3))) 6106c3fb27SDimitry Andric #else 6206c3fb27SDimitry Andric // clang-format off 6306c3fb27SDimitry Andric %varargs(3, char *str = NULL) SetErrorStringWithFormat; 6406c3fb27SDimitry Andric // clang-format on 6506c3fb27SDimitry Andric #endif 6606c3fb27SDimitry Andric int SetErrorStringWithFormat(const char *format, ...); 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric explicit operator bool() const; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric bool IsValid() const; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric bool GetDescription(lldb::SBStream &description); 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric protected: 750b57cec5SDimitry Andric friend class SBBreakpoint; 760b57cec5SDimitry Andric friend class SBBreakpointLocation; 770b57cec5SDimitry Andric friend class SBBreakpointName; 780b57cec5SDimitry Andric friend class SBCommandReturnObject; 790b57cec5SDimitry Andric friend class SBCommunication; 80*0fca6ea1SDimitry Andric friend class SBSaveCoreOptions; 810b57cec5SDimitry Andric friend class SBData; 820b57cec5SDimitry Andric friend class SBDebugger; 83bdd1243dSDimitry Andric friend class SBFile; 845f757f3fSDimitry Andric friend class SBFormat; 850b57cec5SDimitry Andric friend class SBHostOS; 860b57cec5SDimitry Andric friend class SBPlatform; 870b57cec5SDimitry Andric friend class SBProcess; 880b57cec5SDimitry Andric friend class SBReproducer; 890b57cec5SDimitry Andric friend class SBStructuredData; 900b57cec5SDimitry Andric friend class SBTarget; 910b57cec5SDimitry Andric friend class SBThread; 920b57cec5SDimitry Andric friend class SBTrace; 930b57cec5SDimitry Andric friend class SBValue; 94bdd1243dSDimitry Andric friend class SBValueList; 950b57cec5SDimitry Andric friend class SBWatchpoint; 960b57cec5SDimitry Andric 97fe6060f1SDimitry Andric friend class lldb_private::ScriptInterpreter; 9806c3fb27SDimitry Andric friend class lldb_private::python::SWIGBridge; 9906c3fb27SDimitry Andric 10006c3fb27SDimitry Andric SBError(const lldb_private::Status &error); 101fe6060f1SDimitry Andric 1020b57cec5SDimitry Andric lldb_private::Status *get(); 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric lldb_private::Status *operator->(); 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric const lldb_private::Status &operator*() const; 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andric lldb_private::Status &ref(); 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric void SetError(const lldb_private::Status &lldb_error); 1110b57cec5SDimitry Andric 1120b57cec5SDimitry Andric private: 1130b57cec5SDimitry Andric std::unique_ptr<lldb_private::Status> m_opaque_up; 1140b57cec5SDimitry Andric 1150b57cec5SDimitry Andric void CreateIfNeeded(); 1160b57cec5SDimitry Andric }; 1170b57cec5SDimitry Andric 1180b57cec5SDimitry Andric } // namespace lldb 1190b57cec5SDimitry Andric 1205ffd83dbSDimitry Andric #endif // LLDB_API_SBERROR_H 121