diff --git a/src/common/assert.h b/src/common/assert.h index 93965c2ec9..a80e6cc558 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -1,8 +1,8 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project -// SPDX-FileCopyrightText: 2014 Citra Emulator Project +// SPDX-FileCopyrightText:2013 Dolphin Emulator Project +// SPDX-FileCopyrightText:2014 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -22,66 +22,68 @@ void AssertFailSoftImpl(); #define YUZU_NO_INLINE __attribute__((noinline)) #endif -#define ASSERT(_a_) \ - ([&]() YUZU_NO_INLINE { \ - if (!(_a_)) [[unlikely]] { \ - LOG_CRITICAL(Debug, "Assert"); \ - AssertFailSoftImpl(); \ - } \ - }()) +// Note: We use an immediately-invoked lambda that takes the caller's __func__ as a parameter. +// This ensures logs show the real function name instead of the lambda's operator(). +#define ASSERT(_a_) \ + ([&](const char* __assert_func) YUZU_NO_INLINE { \ + if (!(_a_)) [[unlikely]] { \ + ::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, \ + ::Common::Log::Level::Critical, \ + __FILE__, __LINE__, __assert_func, \ + "Assertion failed"); \ + AssertFailSoftImpl(); \ + } \ + }(__func__)) -#define ASSERT_MSG(_a_, ...) \ - ([&]() YUZU_NO_INLINE { \ - if (!(_a_)) [[unlikely]] { \ - LOG_CRITICAL(Debug, "Assert\n" __VA_ARGS__); \ - AssertFailSoftImpl(); \ - } \ - }()) +#define ASSERT_MSG(_a_, fmt, ...) \ + ([&](const char* __assert_func) YUZU_NO_INLINE { \ + if (!(_a_)) [[unlikely]] { \ + ::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, \ + ::Common::Log::Level::Critical, \ + __FILE__, __LINE__, __assert_func, \ + "Assertion failed: " fmt, ##__VA_ARGS__); \ + AssertFailSoftImpl(); \ + } \ + }(__func__)) -#define UNREACHABLE() \ - do { \ - LOG_CRITICAL(Debug, "Unreachable"); \ - AssertFatalImpl(); \ - } while (0) +#define UNREACHABLE() \ + do { \ + ::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, ::Common::Log::Level::Critical, \ + __FILE__, __LINE__, __func__, "Unreachable"); \ + AssertFatalImpl(); \ + } while (0) -#define UNREACHABLE_MSG(...) \ - do { \ - LOG_CRITICAL(Debug, "Unreachable\n" __VA_ARGS__); \ - AssertFatalImpl(); \ - } while (0) +#define UNREACHABLE_MSG(fmt, ...) \ + do { \ + ::Common::Log::FmtLogMessage(::Common::Log::Class::Debug, ::Common::Log::Level::Critical, \ + __FILE__, __LINE__, __func__, \ + "Unreachable: " fmt, ##__VA_ARGS__); \ + AssertFatalImpl(); \ + } while (0) #ifdef _DEBUG #define DEBUG_ASSERT(_a_) ASSERT(_a_) #define DEBUG_ASSERT_MSG(_a_, ...) ASSERT_MSG(_a_, __VA_ARGS__) #else // not debug -#define DEBUG_ASSERT(_a_) \ - do { \ - } while (0) -#define DEBUG_ASSERT_MSG(_a_, _desc_, ...) \ - do { \ - } while (0) +#define DEBUG_ASSERT(_a_) \ + do { \ + } while (0) +#define DEBUG_ASSERT_MSG(_a_, _desc_, ...) \ + do { \ + } while (0) #endif -#define UNIMPLEMENTED() ASSERT_MSG(false, "Unimplemented code!") +#define UNIMPLEMENTED() ASSERT_MSG(false, "Unimplemented code path") #define UNIMPLEMENTED_MSG(...) ASSERT_MSG(false, __VA_ARGS__) -#define UNIMPLEMENTED_IF(cond) ASSERT_MSG(!(cond), "Unimplemented code!") +#define UNIMPLEMENTED_IF(cond) ASSERT_MSG(!(cond), "Unimplemented code path") #define UNIMPLEMENTED_IF_MSG(cond, ...) ASSERT_MSG(!(cond), __VA_ARGS__) // If the assert is ignored, execute _b_ -#define ASSERT_OR_EXECUTE(_a_, _b_) \ - do { \ - ASSERT(_a_); \ - if (!(_a_)) [[unlikely]] { \ - _b_ \ - } \ - } while (0) - -// If the assert is ignored, execute _b_ -#define ASSERT_OR_EXECUTE_MSG(_a_, _b_, ...) \ - do { \ - ASSERT_MSG(_a_, __VA_ARGS__); \ - if (!(_a_)) [[unlikely]] { \ - _b_ \ - } \ - } while (0) +#define ASSERT_OR_EXECUTE(_a_, _b_) \ + do { \ + ASSERT(_a_); \ + if (!(_a_)) [[unlikely]] { \ + _b_ \ + } \ + } while (0) diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp index 9d284e85a5..06b4388685 100644 --- a/src/core/hle/service/am/service/common_state_getter.cpp +++ b/src/core/hle/service/am/service/common_state_getter.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/hle/service/am/service/common_state_getter.h b/src/core/hle/service/am/service/common_state_getter.h index b9de8efc8d..233ed51050 100644 --- a/src/core/hle/service/am/service/common_state_getter.h +++ b/src/core/hle/service/am/service/common_state_getter.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later