blob: e1960ef9a98311020a37c0ecaf3aa4040649442c [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- 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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02009#ifndef LLDB_API_SBERROR_H
10#define LLDB_API_SBERROR_H
Andrew Walbran3d2c1972020-04-07 12:24:26 +010011
12#include "lldb/API/SBDefines.h"
13
14namespace lldb {
15
16class LLDB_API SBError {
17public:
18 SBError();
19
20 SBError(const lldb::SBError &rhs);
21
22 ~SBError();
23
24 const SBError &operator=(const lldb::SBError &rhs);
25
26 const char *GetCString() const;
27
28 void Clear();
29
30 bool Fail() const;
31
32 bool Success() const;
33
34 uint32_t GetError() const;
35
36 lldb::ErrorType GetType() const;
37
38 void SetError(uint32_t err, lldb::ErrorType type);
39
40 void SetErrorToErrno();
41
42 void SetErrorToGenericError();
43
44 void SetErrorString(const char *err_str);
45
46 int SetErrorStringWithFormat(const char *format, ...)
47 __attribute__((format(printf, 2, 3)));
48
49 explicit operator bool() const;
50
51 bool IsValid() const;
52
53 bool GetDescription(lldb::SBStream &description);
54
55protected:
56 friend class SBBreakpoint;
57 friend class SBBreakpointLocation;
58 friend class SBBreakpointName;
59 friend class SBCommandReturnObject;
60 friend class SBCommunication;
61 friend class SBData;
62 friend class SBDebugger;
63 friend class SBHostOS;
64 friend class SBPlatform;
65 friend class SBProcess;
66 friend class SBReproducer;
67 friend class SBStructuredData;
68 friend class SBTarget;
69 friend class SBThread;
70 friend class SBTrace;
71 friend class SBValue;
72 friend class SBWatchpoint;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020073 friend class SBFile;
Andrew Walbran3d2c1972020-04-07 12:24:26 +010074
75 lldb_private::Status *get();
76
77 lldb_private::Status *operator->();
78
79 const lldb_private::Status &operator*() const;
80
81 lldb_private::Status &ref();
82
83 void SetError(const lldb_private::Status &lldb_error);
84
85private:
86 std::unique_ptr<lldb_private::Status> m_opaque_up;
87
88 void CreateIfNeeded();
89};
90
91} // namespace lldb
92
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020093#endif // LLDB_API_SBERROR_H