LLDB mainline
SBError.h
Go to the documentation of this file.
1//===-- SBError.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_SBERROR_H
10#define LLDB_API_SBERROR_H
11
12#include "lldb/API/SBDefines.h"
13
14namespace lldb_private {
16namespace python {
17class SWIGBridge;
18}
19} // namespace lldb_private
20
21namespace lldb {
22
24public:
25 SBError();
26
27 SBError(const lldb::SBError &rhs);
28
29 SBError(const char *message);
30
32
33 const SBError &operator=(const lldb::SBError &rhs);
34
35 /// Get the error string as a NULL terminated UTF8 c-string.
36 ///
37 /// This SBError object owns the returned string and this object must be kept
38 /// around long enough to use the returned string.
39 const char *GetCString() const;
40
41 void Clear();
42
43 bool Fail() const;
44
45 bool Success() const;
46
47 /// Get the error code.
48 uint32_t GetError() const;
49
50 /// Get the error in machine-readable form. Particularly useful for
51 /// compiler diagnostics.
53
55
56 void SetError(uint32_t err, lldb::ErrorType type);
57
58 void SetErrorToErrno();
59
61
62 void SetErrorString(const char *err_str);
63
64#ifndef SWIG
65 __attribute__((format(printf, 2, 3)))
66#else
67 // clang-format off
68 %varargs(3, char *str = NULL) SetErrorStringWithFormat;
69 // clang-format on
70#endif
71 int SetErrorStringWithFormat(const char *format, ...);
72
73 explicit operator bool() const;
74
75 bool IsValid() const;
76
77 bool GetDescription(lldb::SBStream &description);
78
79protected:
80 friend class SBBreakpoint;
82 friend class SBBreakpointName;
84 friend class SBCommunication;
85 friend class SBSaveCoreOptions;
86 friend class SBData;
87 friend class SBDebugger;
88 friend class SBFile;
89 friend class SBFormat;
90 friend class SBFrame;
91 friend class SBHostOS;
92 friend class SBPlatform;
93 friend class SBProcess;
94 friend class SBReproducer;
95 friend class SBStructuredData;
96 friend class SBTarget;
97 friend class SBThread;
98 friend class SBTrace;
99 friend class SBValue;
100 friend class SBValueList;
101 friend class SBWatchpoint;
102
104 friend class lldb_private::python::SWIGBridge;
105
107
109
111
112 const lldb_private::Status &operator*() const;
113
115
116 void SetError(lldb_private::Status &&lldb_error);
117
118private:
119 std::unique_ptr<lldb_private::Status> m_opaque_up;
120
121 void CreateIfNeeded();
122};
123
124} // namespace lldb
125
126#endif // LLDB_API_SBERROR_H
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_API
Definition SBDefines.h:28
uint32_t GetError() const
Get the error code.
Definition SBError.cpp:91
friend class SBWatchpoint
Definition SBError.h:101
bool GetDescription(lldb::SBStream &description)
Definition SBError.cpp:201
friend class SBFile
Definition SBError.h:88
bool Success() const
Definition SBError.cpp:81
std::unique_ptr< lldb_private::Status > m_opaque_up
Definition SBError.h:119
friend class SBValueList
Definition SBError.h:100
friend class SBStructuredData
Definition SBError.h:95
friend class SBFormat
Definition SBError.h:89
friend class SBCommandReturnObject
Definition SBError.h:83
friend class SBProcess
Definition SBError.h:93
friend class SBSaveCoreOptions
Definition SBError.h:85
void SetErrorString(const char *err_str)
Definition SBError.cpp:150
friend class SBDebugger
Definition SBError.h:87
void SetError(uint32_t err, lldb::ErrorType type)
Definition SBError.cpp:124
friend class SBTarget
Definition SBError.h:96
friend class SBBreakpoint
Definition SBError.h:80
bool Fail() const
Definition SBError.cpp:70
const SBError & operator=(const lldb::SBError &rhs)
Definition SBError.cpp:45
friend class SBValue
Definition SBError.h:99
lldb_private::Status & ref()
Definition SBError.cpp:191
lldb::ErrorType GetType() const
Definition SBError.cpp:114
const lldb_private::Status & operator*() const
Definition SBError.cpp:196
friend class SBTrace
Definition SBError.h:98
friend class SBThread
Definition SBError.h:97
friend class SBReproducer
Definition SBError.h:94
friend class SBHostOS
Definition SBError.h:91
void SetErrorToGenericError()
Definition SBError.cpp:143
const char * GetCString() const
Get the error string as a NULL terminated UTF8 c-string.
Definition SBError.cpp:55
lldb_private::Status * operator->()
Definition SBError.cpp:187
bool IsValid() const
Definition SBError.cpp:172
SBStructuredData GetErrorData() const
Get the error in machine-readable form.
Definition SBError.cpp:102
void SetErrorToErrno()
Definition SBError.cpp:136
void CreateIfNeeded()
Definition SBError.cpp:182
friend class SBFrame
Definition SBError.h:90
lldb_private::Status * get()
Definition SBError.cpp:189
__attribute__((format(printf, 2, 3))) int SetErrorStringWithFormat(const char *format
friend class SBData
Definition SBError.h:86
friend class SBBreakpointName
Definition SBError.h:82
void Clear()
Definition SBError.cpp:63
friend class SBBreakpointLocation
Definition SBError.h:81
friend class SBPlatform
Definition SBError.h:92
friend class SBCommunication
Definition SBError.h:84
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.