chromium/base/check.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/check.h"

#include <optional>

#include "base/check_op.h"
#include "base/check_version_internal.h"
#include "base/debug/alias.h"
#include "base/debug/dump_without_crashing.h"
#include "base/logging.h"
#include "base/thread_annotations.h"
#include "base/types/cxx23_to_underlying.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_NACL)
// Forward declaring this ptr for code simplicity below, we'll never dereference
// it under NaCl.
namespace base::debug {
class CrashKeyString;
}  // namespace base::debug
#else
#include "base/debug/crash_logging.h"
#endif  // !BUILDFLAG(IS_NACL)

namespace logging {

namespace {

LogSeverity GetDumpSeverity() {}

LogSeverity GetNotFatalUntilSeverity(base::NotFatalUntil fatal_milestone) {}

LogSeverity GetCheckSeverity(base::NotFatalUntil fatal_milestone) {}

base::debug::CrashKeyString* GetNotReachedCrashKey() {}

base::debug::CrashKeyString* GetDCheckCrashKey() {}

base::debug::CrashKeyString* GetDumpWillBeCheckCrashKey() {}

void DumpWithoutCrashing(base::debug::CrashKeyString* message_key,
                         const std::string& crash_string,
                         const base::Location& location,
                         base::NotFatalUntil fatal_milestone) {}

class NotReachedLogMessage : public LogMessage {};

class DCheckLogMessage : public LogMessage {};

class CheckLogMessage : public LogMessage {};

#if BUILDFLAG(IS_WIN)
class DCheckWin32ErrorLogMessage : public Win32ErrorLogMessage {
 public:
  DCheckWin32ErrorLogMessage(const base::Location& location,
                             SystemErrorCode err)
      : Win32ErrorLogMessage(location.file_name(),
                             location.line_number(),
                             LOGGING_DCHECK,
                             err),
        location_(location) {}
  ~DCheckWin32ErrorLogMessage() override {
    if (severity() != logging::LOGGING_FATAL) {
      DumpWithoutCrashing(GetDCheckCrashKey(), BuildCrashString(), location_,
                          base::NotFatalUntil::NoSpecifiedMilestoneInternal);
    }
  }

 private:
  const base::Location location_;
};
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
class DCheckErrnoLogMessage : public ErrnoLogMessage {};
#endif  // BUILDFLAG(IS_WIN)

}  // namespace

CheckError CheckError::Check(const char* condition,
                             base::NotFatalUntil fatal_milestone,
                             const base::Location& location) {}

CheckError CheckError::CheckOp(char* log_message_str,
                               base::NotFatalUntil fatal_milestone,
                               const base::Location& location) {}

CheckError CheckError::DCheck(const char* condition,
                              const base::Location& location) {}

CheckError CheckError::DCheckOp(char* log_message_str,
                                const base::Location& location) {}

CheckError CheckError::DumpWillBeCheck(const char* condition,
                                       const base::Location& location) {}

CheckError CheckError::DumpWillBeCheckOp(char* log_message_str,
                                         const base::Location& location) {}

CheckError CheckError::PCheck(const char* condition,
                              const base::Location& location) {}

CheckError CheckError::PCheck(const base::Location& location) {}

CheckError CheckError::DPCheck(const char* condition,
                               const base::Location& location) {}

CheckError CheckError::DumpWillBeNotReachedNoreturn(
    const base::Location& location) {}

CheckError CheckError::NotImplemented(const char* function,
                                      const base::Location& location) {}

std::ostream& CheckError::stream() {}

CheckError::~CheckError() {}

CheckError::CheckError(LogMessage* log_message) :{}

NotReachedError NotReachedError::NotReached(base::NotFatalUntil fatal_milestone,
                                            const base::Location& location) {}

void NotReachedError::TriggerNotReached() {}

NotReachedError::~NotReachedError() = default;

NotReachedNoreturnError::NotReachedNoreturnError(const base::Location& location)
    :{}

// Note: This function ends up in crash stack traces. If its full name changes,
// the crash server's magic signature logic needs to be updated. See
// cl/306632920.
NotReachedNoreturnError::~NotReachedNoreturnError() {}

void RawCheckFailure(const char* message) {}

}  // namespace logging