2015-09-26 16:39:47 -04:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-09-26 16:39:47 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-11-20 11:33:47 +01:00
|
|
|
#include "Common/Common.h"
|
2015-09-26 16:39:47 -04:00
|
|
|
#include "Common/CommonFuncs.h"
|
|
|
|
#include "Common/Logging/Log.h"
|
|
|
|
#include "Common/MsgHandler.h"
|
|
|
|
|
2018-03-14 20:34:35 -04:00
|
|
|
#define ASSERT_MSG(_t_, _a_, _fmt_, ...) \
|
2018-03-16 12:06:24 -04:00
|
|
|
do \
|
2015-09-26 16:39:47 -04:00
|
|
|
{ \
|
2018-03-16 12:06:24 -04:00
|
|
|
if (!(_a_)) \
|
|
|
|
{ \
|
2021-11-10 18:34:28 -08:00
|
|
|
if (!PanicYesNoFmtAssert(_t_, \
|
|
|
|
"An error occurred.\n\n" _fmt_ "\n\n" \
|
|
|
|
" Condition: {}\n File: {}\n Line: {}\n Function: {}\n\n" \
|
|
|
|
"Ignore and continue?", \
|
|
|
|
##__VA_ARGS__, #_a_, __FILE__, __LINE__, __func__)) \
|
2018-03-16 12:06:24 -04:00
|
|
|
Crash(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2015-09-26 16:39:47 -04:00
|
|
|
|
2021-11-10 13:39:36 -08:00
|
|
|
#define DEBUG_ASSERT_MSG(_t_, _a_, _fmt_, ...) \
|
2018-03-16 12:06:24 -04:00
|
|
|
do \
|
2015-09-26 16:39:47 -04:00
|
|
|
{ \
|
2021-10-21 12:11:07 -07:00
|
|
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LogLevel::LDEBUG) \
|
2021-11-10 13:39:36 -08:00
|
|
|
ASSERT_MSG(_t_, _a_, _fmt_, ##__VA_ARGS__); \
|
2018-03-16 12:06:24 -04:00
|
|
|
} while (0)
|
2015-09-26 16:39:47 -04:00
|
|
|
|
2018-03-14 20:34:35 -04:00
|
|
|
#define ASSERT(_a_) \
|
2018-03-16 12:06:24 -04:00
|
|
|
do \
|
|
|
|
{ \
|
2021-11-10 13:39:36 -08:00
|
|
|
if (!(_a_)) \
|
|
|
|
{ \
|
2021-11-10 14:42:49 -08:00
|
|
|
if (!PanicYesNoFmt("An error occurred.\n\n" \
|
|
|
|
" Condition: {}\n File: {}\n Line: {}\n Function: {}\n\n" \
|
|
|
|
"Ignore and continue?", \
|
|
|
|
#_a_, __FILE__, __LINE__, __func__)) \
|
2021-11-10 13:39:36 -08:00
|
|
|
Crash(); \
|
|
|
|
} \
|
2018-03-16 12:06:24 -04:00
|
|
|
} while (0)
|
2015-09-26 16:39:47 -04:00
|
|
|
|
2018-03-16 12:57:36 -04:00
|
|
|
#define DEBUG_ASSERT(_a_) \
|
2018-03-16 12:06:24 -04:00
|
|
|
do \
|
|
|
|
{ \
|
2021-10-21 12:11:07 -07:00
|
|
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LogLevel::LDEBUG) \
|
2018-03-16 12:06:24 -04:00
|
|
|
ASSERT(_a_); \
|
|
|
|
} while (0)
|