Common/Assert: Actually use the ASSERT_MSG's log type parameter
Since it was unused, nonexistent values were used in a few places. I've replaced them.
This commit is contained in:
parent
bab3ff0157
commit
558de04cfc
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <fmt/format.h>
|
||||
|
||||
#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 <std::size_t NumFields, typename S, typename... Args>
|
||||
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<Args...>(format, args...));
|
||||
return MsgAlertFmtImpl(yes_no, style, log_type, format,
|
||||
fmt::make_args_checked<Args...>(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<GENERIC_ALERT_FMT_N>(yes_no, style, FMT_STRING(format), \
|
||||
##__VA_ARGS__); \
|
||||
return Common::MsgAlertFmt<GENERIC_ALERT_FMT_N>(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<GENERIC_ALERT_FMT_N>(yes_no, style, FMT_STRING(format), \
|
||||
##__VA_ARGS__); \
|
||||
return Common::MsgAlertFmt<GENERIC_ALERT_FMT_N>(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__)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue