llvm/lldb/source/Utility/Status.cpp

//===-- Status.cpp --------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "lldb/Utility/Status.h"

#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/VASPrintf.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/FormatProviders.h"

#include <cerrno>
#include <cstdarg>
#include <string>
#include <system_error>

#ifdef __APPLE__
#include <mach/mach.h>
#endif

#ifdef _WIN32
#include <windows.h>
#endif
#include <cstdint>

namespace llvm {
class raw_ostream;
}

usingnamespacelldb;
usingnamespacelldb_private;

char CloneableError::ID;
char CloneableECError::ID;
char MachKernelError::ID;
char Win32Error::ID;
char ExpressionErrorBase::ID;

namespace {
/// A std::error_code category for eErrorTypeGeneric.
class LLDBGenericCategory : public std::error_category {};
LLDBGenericCategory &lldb_generic_category() {}
} // namespace

Status::Status() :{}

static llvm::Error ErrorFromEnums(Status::ValueType err, ErrorType type,
                                  std::string msg) {}

Status::Status(ValueType err, ErrorType type, std::string msg)
    :{}

// This logic is confusing because C++ calls the traditional (posix) errno codes
// "generic errors", while we use the term "generic" to mean completely
// arbitrary (text-based) errors.
Status::Status(std::error_code EC)
    :{}

Status::Status(std::string err_str)
    :{}

const Status &Status::operator=(Status &&other) {}

Status Status::FromErrorStringWithFormat(const char *format, ...) {}

/// Creates a deep copy of all known errors and converts all other
/// errors to a new llvm::StringError.
static llvm::Error CloneError(const llvm::Error &error) {}

Status Status::FromError(llvm::Error error) {}

llvm::Error Status::ToError() const {}

Status::~Status() {}

#ifdef _WIN32
static std::string RetrieveWin32ErrorString(uint32_t error_code) {
  char *buffer = nullptr;
  std::string message;
  // Retrieve win32 system error.
  // First, attempt to load a en-US message
  if (::FormatMessageA(
          FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
              FORMAT_MESSAGE_MAX_WIDTH_MASK,
          NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
          (LPSTR)&buffer, 0, NULL)) {
    message.assign(buffer);
    ::LocalFree(buffer);
  }
  // If the previous didn't work, use the default OS language
  else if (::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                                FORMAT_MESSAGE_FROM_SYSTEM |
                                FORMAT_MESSAGE_MAX_WIDTH_MASK,
                            NULL, error_code, 0, (LPSTR)&buffer, 0, NULL)) {
    message.assign(buffer);
    ::LocalFree(buffer);
  }
  return message;
}
#endif

std::string MachKernelError::message() const {}

std::string Win32Error::message() const {}

std::unique_ptr<CloneableError> MachKernelError::Clone() const {}

std::unique_ptr<CloneableError> Win32Error::Clone() const {}

// Get the error value as a NULL C string. The error string will be fetched and
// cached on demand. The cached error string value will remain until the error
// value is changed or cleared.
const char *Status::AsCString(const char *default_error_str) const {}

// Clear the error and any cached error string that it might contain.
void Status::Clear() {}

Status::ValueType Status::GetError() const {}

static ErrorType ErrorCodeToErrorType(std::error_code ec) {}

ErrorType CloneableECError::GetErrorType() const {}

lldb::ErrorType MachKernelError::GetErrorType() const {}

lldb::ErrorType Win32Error::GetErrorType() const {}

lldb::ErrorType ExpressionErrorBase::GetErrorType() const {}

ErrorType Status::GetType() const {}

bool Status::Fail() const {}

Status Status::FromErrno() {}

// Returns true if the error code in this object is considered a successful
// return value.
bool Status::Success() const {}

void llvm::format_provider<lldb_private::Status>::format(
    const lldb_private::Status &error, llvm::raw_ostream &OS,
    llvm::StringRef Options) {}

const char *lldb_private::ExpressionResultAsCString(ExpressionResults result) {}