diff --git a/Source/Core/Common/Arm64Emitter.cpp b/Source/Core/Common/Arm64Emitter.cpp index 27dd33c9d0..d5171c2e95 100644 --- a/Source/Core/Common/Arm64Emitter.cpp +++ b/Source/Core/Common/Arm64Emitter.cpp @@ -577,13 +577,14 @@ void ARM64XEmitter::EncodeAddSubImmInst(u32 op, bool flags, u32 shift, u32 imm, void ARM64XEmitter::EncodeLogicalImmInst(u32 op, ARM64Reg Rd, ARM64Reg Rn, LogicalImm imm) { - ASSERT_MSG(DYNAREC, imm.valid, "Invalid logical immediate"); + ASSERT_MSG(DYNA_REC, imm.valid, "Invalid logical immediate"); // Sometimes Rd is fixed to SP, but can still be 32bit or 64bit. // Use Rn to determine bitness here. bool b64Bit = Is64Bit(Rn); - ASSERT_MSG(DYNAREC, b64Bit || !imm.n, "64-bit logical immediate does not fit in 32-bit register"); + ASSERT_MSG(DYNA_REC, b64Bit || !imm.n, + "64-bit logical immediate does not fit in 32-bit register"); Write32((b64Bit << 31) | (op << 29) | (0x24 << 23) | (imm.n << 22) | (imm.r << 16) | (imm.s << 10) | (DecodeReg(Rn) << 5) | DecodeReg(Rd)); diff --git a/Source/Core/Common/Assert.h b/Source/Core/Common/Assert.h index ba8a5718e7..865fdc8a18 100644 --- a/Source/Core/Common/Assert.h +++ b/Source/Core/Common/Assert.h @@ -13,10 +13,11 @@ { \ if (!(_a_)) \ { \ - if (!PanicYesNoFmt("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__)) \ + 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__)) \ Crash(); \ } \ } while (0) diff --git a/Source/Core/Common/MsgHandler.cpp b/Source/Core/Common/MsgHandler.cpp index c455beb3ed..26f0f0a89a 100644 --- a/Source/Core/Common/MsgHandler.cpp +++ b/Source/Core/Common/MsgHandler.cpp @@ -106,10 +106,11 @@ std::string GetStringT(const char* string) return s_str_translator(string); } -static bool ShowMessageAlert(std::string_view text, bool yes_no, MsgType style) +static bool ShowMessageAlert(std::string_view text, bool yes_no, Common::Log::LogType log_type, + MsgType style) { const char* caption = GetCaption(style); - ERROR_LOG_FMT(MASTER_LOG, "{}: {}", caption, text); + GENERIC_LOG_FMT(log_type, Common::Log::LogLevel::LERROR, "{}: {}", caption, text); // Panic alerts. if (style == MsgType::Warning && s_abort_on_panic_alert) @@ -129,11 +130,11 @@ static bool ShowMessageAlert(std::string_view text, bool yes_no, MsgType style) // This is the first stop for gui alerts where the log is updated and the // correct window is shown, when using fmt -bool MsgAlertFmtImpl(bool yes_no, MsgType style, fmt::string_view format, - const fmt::format_args& args) +bool MsgAlertFmtImpl(bool yes_no, MsgType style, Common::Log::LogType log_type, + fmt::string_view format, const fmt::format_args& args) { const auto message = fmt::vformat(format, args); - return ShowMessageAlert(message, yes_no, style); + return ShowMessageAlert(message, yes_no, log_type, style); } } // namespace Common diff --git a/Source/Core/Common/MsgHandler.h b/Source/Core/Common/MsgHandler.h index 435b8efe4e..7fcf4d5d09 100644 --- a/Source/Core/Common/MsgHandler.h +++ b/Source/Core/Common/MsgHandler.h @@ -10,6 +10,7 @@ #include #include "Common/FormatUtil.h" +#include "Common/Logging/Log.h" namespace Common { @@ -30,16 +31,18 @@ void RegisterStringTranslator(StringTranslator translator); std::string GetStringT(const char* string); -bool MsgAlertFmtImpl(bool yes_no, MsgType style, fmt::string_view format, - const fmt::format_args& args); +bool MsgAlertFmtImpl(bool yes_no, MsgType style, Common::Log::LogType log_type, + fmt::string_view format, const fmt::format_args& args); template -bool MsgAlertFmt(bool yes_no, MsgType style, const S& format, const Args&... args) +bool MsgAlertFmt(bool yes_no, MsgType style, Common::Log::LogType log_type, const S& format, + const Args&... args) { static_assert(NumFields == sizeof...(args), "Unexpected number of replacement fields in format string; did you pass too few or " "too many arguments?"); - return MsgAlertFmtImpl(yes_no, style, format, fmt::make_args_checked(format, args...)); + return MsgAlertFmtImpl(yes_no, style, log_type, format, + fmt::make_args_checked(format, args...)); } void SetEnableAlert(bool enable); @@ -55,51 +58,55 @@ std::string FmtFormatT(const char* string, Args&&... args) // Fmt-capable variants of the macros -#define GenericAlertFmt(yes_no, style, format, ...) \ +#define GenericAlertFmt(yes_no, style, log_type, format, ...) \ [&] { \ /* Use a macro-like name to avoid shadowing warnings */ \ constexpr auto GENERIC_ALERT_FMT_N = Common::CountFmtReplacementFields(format); \ - return Common::MsgAlertFmt(yes_no, style, FMT_STRING(format), \ - ##__VA_ARGS__); \ + return Common::MsgAlertFmt(yes_no, style, Common::Log::LogType::log_type, \ + FMT_STRING(format), ##__VA_ARGS__); \ }() -#define GenericAlertFmtT(yes_no, style, format, ...) \ +#define GenericAlertFmtT(yes_no, style, log_type, format, ...) \ [&] { \ static_assert(!Common::ContainsNonPositionalArguments(format), \ "Translatable strings must use positional arguments (e.g. {0} instead of {})"); \ /* Use a macro-like name to avoid shadowing warnings */ \ constexpr auto GENERIC_ALERT_FMT_N = Common::CountFmtReplacementFields(format); \ - return Common::MsgAlertFmt(yes_no, style, FMT_STRING(format), \ - ##__VA_ARGS__); \ + return Common::MsgAlertFmt(yes_no, style, Common::Log::LogType::log_type, \ + FMT_STRING(format), ##__VA_ARGS__); \ }() #define SuccessAlertFmt(format, ...) \ - GenericAlertFmt(false, Common::MsgType::Information, format, ##__VA_ARGS__) + GenericAlertFmt(false, Common::MsgType::Information, MASTER_LOG, format, ##__VA_ARGS__) #define PanicAlertFmt(format, ...) \ - GenericAlertFmt(false, Common::MsgType::Warning, format, ##__VA_ARGS__) + GenericAlertFmt(false, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__) #define PanicYesNoFmt(format, ...) \ - GenericAlertFmt(true, Common::MsgType::Warning, format, ##__VA_ARGS__) + GenericAlertFmt(true, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__) #define AskYesNoFmt(format, ...) \ - GenericAlertFmt(true, Common::MsgType::Question, format, ##__VA_ARGS__) + GenericAlertFmt(true, Common::MsgType::Question, MASTER_LOG, format, ##__VA_ARGS__) #define CriticalAlertFmt(format, ...) \ - GenericAlertFmt(false, Common::MsgType::Critical, format, ##__VA_ARGS__) + GenericAlertFmt(false, Common::MsgType::Critical, MASTER_LOG, format, ##__VA_ARGS__) // Use these macros (that do the same thing) if the message should be translated. #define SuccessAlertFmtT(format, ...) \ - GenericAlertFmtT(false, Common::MsgType::Information, format, ##__VA_ARGS__) + GenericAlertFmtT(false, Common::MsgType::Information, MASTER_LOG, format, ##__VA_ARGS__) #define PanicAlertFmtT(format, ...) \ - GenericAlertFmtT(false, Common::MsgType::Warning, format, ##__VA_ARGS__) + GenericAlertFmtT(false, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__) #define PanicYesNoFmtT(format, ...) \ - GenericAlertFmtT(true, Common::MsgType::Warning, format, ##__VA_ARGS__) + GenericAlertFmtT(true, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__) #define AskYesNoFmtT(format, ...) \ - GenericAlertFmtT(true, Common::MsgType::Question, format, ##__VA_ARGS__) + GenericAlertFmtT(true, Common::MsgType::Question, MASTER_LOG, format, ##__VA_ARGS__) #define CriticalAlertFmtT(format, ...) \ - GenericAlertFmtT(false, Common::MsgType::Critical, format, ##__VA_ARGS__) + GenericAlertFmtT(false, Common::MsgType::Critical, MASTER_LOG, format, ##__VA_ARGS__) + +// Variant that takes a log type, used by the assert macros +#define PanicYesNoFmtAssert(log_type, format, ...) \ + GenericAlertFmt(true, Common::MsgType::Warning, log_type, format, ##__VA_ARGS__) diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 3d20bc867f..acef7e507a 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -300,7 +300,7 @@ u16 SDSP::ReadRegister(size_t reg) const case DSP_REG_ACM1: return r.ac[reg - DSP_REG_ACM0].m; default: - ASSERT_MSG(DSP_CORE, 0, "cannot happen"); + ASSERT_MSG(DSPLLE, 0, "cannot happen"); return 0; } } diff --git a/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp b/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp index 88e6f2ce65..8ca18e2a36 100644 --- a/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp +++ b/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp @@ -687,7 +687,7 @@ u16 Interpreter::OpReadRegister(int reg_) case DSP_REG_ACM1: return state.r.ac[reg - DSP_REG_ACM0].m; default: - ASSERT_MSG(DSP_INT, 0, "cannot happen"); + ASSERT_MSG(DSPLLE, 0, "cannot happen"); return 0; } } diff --git a/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp index fe147247ad..684d4c718d 100644 --- a/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp @@ -440,7 +440,7 @@ void RegCache::Reset(BitSet32 pregs) { for (preg_t i : pregs) { - ASSERT_MSG(DYNAREC, !m_regs[i].IsAway(), + ASSERT_MSG(DYNA_REC, !m_regs[i].IsAway(), "Attempted to reset a loaded register (did you mean to flush it?)"); m_regs[i].SetFlushed(); } diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp index 1dff57eef4..f0de18458f 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp @@ -36,7 +36,7 @@ void Arm64RegCache::ResetRegisters(BitSet32 regs) OpArg& reg = m_guest_registers[i]; ARM64Reg host_reg = reg.GetReg(); - ASSERT_MSG(DYNAREC, host_reg == ARM64Reg::INVALID_REG, + ASSERT_MSG(DYNA_REC, host_reg == ARM64Reg::INVALID_REG, "Attempted to reset a loaded register (did you mean to flush it?)"); reg.Flush(); } diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 43662edb8b..6df37b47df 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -296,7 +296,7 @@ static void HotplugThreadFunc() udev* const udev = udev_new(); Common::ScopeGuard udev_guard([udev] { udev_unref(udev); }); - ASSERT_MSG(PAD, udev != nullptr, "Couldn't initialize libudev."); + ASSERT_MSG(CONTROLLERINTERFACE, udev != nullptr, "Couldn't initialize libudev."); // Set up monitoring udev_monitor* const monitor = udev_monitor_new_from_netlink(udev, "udev"); @@ -366,7 +366,7 @@ static void StartHotplugThread() } s_wakeup_eventfd = eventfd(0, 0); - ASSERT_MSG(PAD, s_wakeup_eventfd != -1, "Couldn't create eventfd."); + ASSERT_MSG(CONTROLLERINTERFACE, s_wakeup_eventfd != -1, "Couldn't create eventfd."); s_hotplug_thread = std::thread(HotplugThreadFunc); } @@ -406,7 +406,7 @@ void PopulateDevices() // this ever changes, hopefully udev will take care of this. udev* const udev = udev_new(); - ASSERT_MSG(PAD, udev != nullptr, "Couldn't initialize libudev."); + ASSERT_MSG(CONTROLLERINTERFACE, udev != nullptr, "Couldn't initialize libudev."); // List all input devices udev_enumerate* const enumerate = udev_enumerate_new(udev);