SBError.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #ifndef LLDB_API_SBERROR_H
  9. #define LLDB_API_SBERROR_H
  10. #include "lldb/API/SBDefines.h"
  11. namespace lldb_private {
  12. class ScriptInterpreter;
  13. } // namespace lldb_private
  14. namespace lldb {
  15. class LLDB_API SBError {
  16. public:
  17. SBError();
  18. SBError(const lldb::SBError &rhs);
  19. ~SBError();
  20. const SBError &operator=(const lldb::SBError &rhs);
  21. const char *GetCString() const;
  22. void Clear();
  23. bool Fail() const;
  24. bool Success() const;
  25. uint32_t GetError() const;
  26. lldb::ErrorType GetType() const;
  27. void SetError(uint32_t err, lldb::ErrorType type);
  28. void SetErrorToErrno();
  29. void SetErrorToGenericError();
  30. void SetErrorString(const char *err_str);
  31. int SetErrorStringWithFormat(const char *format, ...)
  32. __attribute__((format(printf, 2, 3)));
  33. explicit operator bool() const;
  34. bool IsValid() const;
  35. bool GetDescription(lldb::SBStream &description);
  36. protected:
  37. friend class SBBreakpoint;
  38. friend class SBBreakpointLocation;
  39. friend class SBBreakpointName;
  40. friend class SBCommandReturnObject;
  41. friend class SBCommunication;
  42. friend class SBData;
  43. friend class SBDebugger;
  44. friend class SBHostOS;
  45. friend class SBPlatform;
  46. friend class SBProcess;
  47. friend class SBReproducer;
  48. friend class SBStructuredData;
  49. friend class SBTarget;
  50. friend class SBThread;
  51. friend class SBTrace;
  52. friend class SBValue;
  53. friend class SBWatchpoint;
  54. friend class SBFile;
  55. friend class lldb_private::ScriptInterpreter;
  56. lldb_private::Status *get();
  57. lldb_private::Status *operator->();
  58. const lldb_private::Status &operator*() const;
  59. lldb_private::Status &ref();
  60. void SetError(const lldb_private::Status &lldb_error);
  61. private:
  62. std::unique_ptr<lldb_private::Status> m_opaque_up;
  63. void CreateIfNeeded();
  64. };
  65. } // namespace lldb
  66. #endif // LLDB_API_SBERROR_H