003 File Manager
Current Path:
/usr/src/contrib/llvm-project/lldb/include/lldb/Utility
usr
/
src
/
contrib
/
llvm-project
/
lldb
/
include
/
lldb
/
Utility
/
📁
..
📄
AnsiTerminal.h
(4.97 KB)
📄
ArchSpec.h
(17.08 KB)
📄
Args.h
(13.72 KB)
📄
Baton.h
(2.25 KB)
📄
Broadcaster.h
(17.55 KB)
📄
CompletionRequest.h
(9.23 KB)
📄
Connection.h
(6.42 KB)
📄
ConstString.h
(17.92 KB)
📄
DataBuffer.h
(3.39 KB)
📄
DataBufferHeap.h
(3.65 KB)
📄
DataBufferLLVM.h
(1.17 KB)
📄
DataEncoder.h
(8.45 KB)
📄
DataExtractor.h
(39.18 KB)
📄
Endian.h
(865 B)
📄
Environment.h
(2.68 KB)
📄
Event.h
(6.64 KB)
📄
FileSpec.h
(15.41 KB)
📄
Flags.h
(3.39 KB)
📄
GDBRemote.h
(4.15 KB)
📄
IOObject.h
(1.38 KB)
📄
Iterable.h
(5.5 KB)
📄
LLDBAssert.h
(911 B)
📄
Listener.h
(5.2 KB)
📄
Log.h
(10.51 KB)
📄
Logging.h
(2.27 KB)
📄
NameMatches.h
(716 B)
📄
Predicate.h
(8.08 KB)
📄
ProcessInfo.h
(7.92 KB)
📄
RangeMap.h
(23.05 KB)
📄
RegisterValue.h
(7.08 KB)
📄
RegularExpression.h
(3.2 KB)
📄
Reproducer.h
(13.25 KB)
📄
ReproducerInstrumentation.h
(39.38 KB)
📄
Scalar.h
(11.27 KB)
📄
SelectHelper.h
(2.53 KB)
📄
SharedCluster.h
(1.69 KB)
📄
State.h
(2.54 KB)
📄
Status.h
(7.31 KB)
📄
Stream.h
(14.34 KB)
📄
StreamCallback.h
(978 B)
📄
StreamString.h
(1.23 KB)
📄
StreamTee.h
(4.52 KB)
📄
StringExtractor.h
(3.13 KB)
📄
StringExtractorGDBRemote.h
(6.12 KB)
📄
StringLexer.h
(1.31 KB)
📄
StringList.h
(3.47 KB)
📄
StructuredData.h
(15.49 KB)
📄
TildeExpressionResolver.h
(2.42 KB)
📄
Timeout.h
(2.45 KB)
📄
Timer.h
(1.87 KB)
📄
TraceOptions.h
(1.79 KB)
📄
UUID.h
(3.74 KB)
📄
UriParser.h
(1.01 KB)
📄
UserID.h
(2.8 KB)
📄
UserIDResolver.h
(1.8 KB)
📄
VASPrintf.h
(636 B)
📄
VMRange.h
(3.06 KB)
📄
XcodeSDK.h
(2.85 KB)
Editing: Status.h
//===-- Status.h ------------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_UTILITY_STATUS_H #define LLDB_UTILITY_STATUS_H #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include <cstdarg> #include <stdint.h> #include <string> #include <system_error> #include <type_traits> namespace llvm { class raw_ostream; } namespace lldb_private { /// \class Status Status.h "lldb/Utility/Status.h" An error handling class. /// /// This class is designed to be able to hold any error code that can be /// encountered on a given platform. The errors are stored as a value of type /// Status::ValueType. This value should be large enough to hold any and all /// errors that the class supports. Each error has an associated type that is /// of type lldb::ErrorType. New types can be added to support new error /// types, and architecture specific types can be enabled. In the future we /// may wish to switch to a registration mechanism where new error types can /// be registered at runtime instead of a hard coded scheme. /// /// All errors in this class also know how to generate a string representation /// of themselves for printing results and error codes. The string value will /// be fetched on demand and its string value will be cached until the error /// is cleared of the value of the error changes. class Status { public: /// Every error value that this object can contain needs to be able to fit /// into ValueType. typedef uint32_t ValueType; Status(); /// Initialize the error object with a generic success value. /// /// \param[in] err /// An error code. /// /// \param[in] type /// The type for \a err. explicit Status(ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric); Status(std::error_code EC); explicit Status(const char *format, ...) __attribute__((format(printf, 2, 3))); ~Status(); // llvm::Error support explicit Status(llvm::Error error) { *this = std::move(error); } const Status &operator=(llvm::Error error); llvm::Error ToError() const; /// Get the error string associated with the current error. // /// Gets the error value as a NULL terminated C string. The error string /// will be fetched and cached on demand. The error string will be retrieved /// from a callback that is appropriate for the type of the error and will /// be cached until the error value is changed or cleared. /// /// \return /// The error as a NULL terminated C string value if the error /// is valid and is able to be converted to a string value, /// NULL otherwise. const char *AsCString(const char *default_error_str = "unknown error") const; /// Clear the object state. /// /// Reverts the state of this object to contain a generic success value and /// frees any cached error string value. void Clear(); /// Test for error condition. /// /// \return /// \b true if this object contains an error, \b false /// otherwise. bool Fail() const; /// Access the error value. /// /// \return /// The error value. ValueType GetError() const; /// Access the error type. /// /// \return /// The error type enumeration value. lldb::ErrorType GetType() const; /// Set accessor from a kern_return_t. /// /// Set accessor for the error value to \a err and the error type to \c /// MachKernel. /// /// \param[in] err /// A mach error code. void SetMachError(uint32_t err); void SetExpressionError(lldb::ExpressionResults, const char *mssg); int SetExpressionErrorWithFormat(lldb::ExpressionResults, const char *format, ...) __attribute__((format(printf, 3, 4))); /// Set accessor with an error value and type. /// /// Set accessor for the error value to \a err and the error type to \a /// type. /// /// \param[in] err /// A mach error code. /// /// \param[in] type /// The type for \a err. void SetError(ValueType err, lldb::ErrorType type); /// Set the current error to errno. /// /// Update the error value to be \c errno and update the type to be \c /// Status::POSIX. void SetErrorToErrno(); /// Set the current error to a generic error. /// /// Update the error value to be \c LLDB_GENERIC_ERROR and update the type /// to be \c Status::Generic. void SetErrorToGenericError(); /// Set the current error string to \a err_str. /// /// Set accessor for the error string value for a generic errors, or to /// supply additional details above and beyond the standard error strings /// that the standard type callbacks typically provide. This allows custom /// strings to be supplied as an error explanation. The error string value /// will remain until the error value is cleared or a new error value/type /// is assigned. /// /// \param err_str /// The new custom error string to copy and cache. void SetErrorString(llvm::StringRef err_str); /// Set the current error string to a formatted error string. /// /// \param format /// A printf style format string int SetErrorStringWithFormat(const char *format, ...) __attribute__((format(printf, 2, 3))); int SetErrorStringWithVarArg(const char *format, va_list args); template <typename... Args> void SetErrorStringWithFormatv(const char *format, Args &&... args) { SetErrorString(llvm::formatv(format, std::forward<Args>(args)...).str()); } /// Test for success condition. /// /// Returns true if the error code in this object is considered a successful /// return value. /// /// \return /// \b true if this object contains an value that describes /// success (non-erro), \b false otherwise. bool Success() const; /// Test for a failure due to a generic interrupt. /// /// Returns true if the error code in this object was caused by an /// interrupt. At present only supports Posix EINTR. /// /// \return /// \b true if this object contains an value that describes /// failure due to interrupt, \b false otherwise. bool WasInterrupted() const; protected: /// Member variables ValueType m_code; ///< Status code as an integer value. lldb::ErrorType m_type; ///< The type of the above error code. mutable std::string m_string; ///< A string representation of the error code. }; } // namespace lldb_private namespace llvm { template <> struct format_provider<lldb_private::Status> { static void format(const lldb_private::Status &error, llvm::raw_ostream &OS, llvm::StringRef Options); }; } #define LLDB_ERRORF(status, fmt, ...) \ do { \ if (status) { \ (status)->SetErrorStringWithFormat((fmt), __VA_ARGS__); \ } \ } while (0); #endif // LLDB_UTILITY_STATUS_H
Upload File
Create Folder