LCOV - code coverage report
Current view: top level - src/util - check.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 0.0 % 19 0
Test Date: 2026-10-23 05:39:29 Functions: 0.0 % 5 0
Branches: 0.0 % 24 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2022-present The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <util/check.h>
       6                 :             : 
       7                 :             : #include <bitcoin-build-config.h> // IWYU pragma: keep
       8                 :             : 
       9                 :             : #include <clientversion.h>
      10                 :             : #include <tinyformat.h>
      11                 :             : 
      12                 :             : #include <cstdio>
      13                 :             : #include <cstdlib>
      14                 :             : #include <source_location>
      15                 :             : #include <string>
      16                 :             : #include <string_view>
      17                 :             : 
      18                 :           0 : std::string StrFormatInternalBug(std::string_view msg, const std::source_location& loc)
      19                 :             : {
      20                 :           0 :     return strprintf("Internal bug detected: %s\n%s:%d (%s)\n"
      21                 :             :                      "%s %s\n"
      22                 :             :                      "Please report this issue here: %s\n",
      23   [ #  #  #  # ]:           0 :                      msg, loc.file_name(), loc.line(), loc.function_name(),
      24   [ #  #  #  # ]:           0 :                      CLIENT_NAME, FormatFullVersion(), CLIENT_BUGREPORT);
      25                 :             : }
      26                 :             : 
      27                 :           0 : std::string StrFormatFailedCheck(std::string_view assertion)
      28                 :             : {
      29                 :           0 :     return strprintf("`%s` check failed", assertion);
      30                 :             : }
      31                 :             : 
      32                 :           0 : NonFatalCheckError::NonFatalCheckError(std::string_view msg, const std::source_location& loc)
      33         [ #  # ]:           0 :     : std::runtime_error{StrFormatInternalBug(msg, loc)}
      34                 :             : {
      35                 :           0 : }
      36                 :             : 
      37                 :             : bool g_detail_test_only_CheckFailuresAreExceptionsNotAborts{false};
      38                 :             : 
      39                 :           0 : void internal_abort_helper(const std::source_location& loc, std::string_view error_msg)
      40                 :             : {
      41         [ #  # ]:           0 :     if (g_detail_test_only_CheckFailuresAreExceptionsNotAborts) {
      42         [ #  # ]:           0 :         throw NonFatalCheckError{error_msg, loc};
      43                 :             :     }
      44   [ #  #  #  #  :           0 :     auto str = strprintf("%s:%s %s: %s.\n", loc.file_name(), loc.line(), loc.function_name(), error_msg);
                   #  # ]
      45   [ #  #  #  # ]:           0 :     fwrite(str.data(), 1, str.size(), stderr);
      46                 :           0 :     std::abort();
      47                 :           0 : }
      48                 :             : 
      49                 :           0 : void internal_non_fatal_helper(const std::source_location& loc, std::string_view error_msg)
      50                 :             : {
      51                 :           0 :     if constexpr (G_ABORT_ON_FAILED_ASSUME) {
      52                 :           0 :         internal_abort_helper(loc, error_msg);
      53                 :             :     }
      54                 :             :     throw NonFatalCheckError{error_msg, loc};
      55                 :             : }
      56                 :             : 
      57                 :             : std::atomic<bool> g_enable_dynamic_fuzz_determinism{false};
        

Generated by: LCOV version 2.5.0-full