diff --git a/Source/Core/Core/PowerPC/Expression.cpp b/Source/Core/Core/PowerPC/Expression.cpp index e4f84664d1..b25149c41f 100644 --- a/Source/Core/Core/PowerPC/Expression.cpp +++ b/Source/Core/Core/PowerPC/Expression.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,8 @@ #include "Common/BitUtils.h" #include "Common/CommonTypes.h" +#include "Common/Logging/Log.h" +#include "Core/Core.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" @@ -195,6 +198,8 @@ double Expression::Evaluate() const SynchronizeBindings(SynchronizeDirection::To); + Reporting(result); + return result; } @@ -235,6 +240,29 @@ void Expression::SynchronizeBindings(SynchronizeDirection dir) const } } +void Expression::Reporting(const double result) const +{ + bool is_nan = std::isnan(result); + std::string message; + + for (auto* v = m_vars->head; v != nullptr; v = v->next) + { + if (std::isnan(v->value)) + is_nan = true; + + fmt::format_to(std::back_inserter(message), " {}={}", v->name, v->value); + } + + if (is_nan) + { + message.append("\nBreakpoint condition encountered a NaN"); + Core::DisplayMessage("Breakpoint condition has encountered a NaN.", 2000); + } + + if (result != 0.0 || is_nan) + NOTICE_LOG_FMT(MEMMAP, "Breakpoint condition returned: {}. Vars:{}", result, message); +} + std::string Expression::GetText() const { return m_text; diff --git a/Source/Core/Core/PowerPC/Expression.h b/Source/Core/Core/PowerPC/Expression.h index 031b796ffe..7fb5370328 100644 --- a/Source/Core/Core/PowerPC/Expression.h +++ b/Source/Core/Core/PowerPC/Expression.h @@ -60,6 +60,7 @@ private: Expression(std::string_view text, ExprPointer ex, ExprVarListPointer vars); void SynchronizeBindings(SynchronizeDirection dir) const; + void Reporting(const double result) const; std::string m_text; ExprPointer m_expr; diff --git a/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp b/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp index b645377457..d28c2dc61e 100644 --- a/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp @@ -261,6 +261,11 @@ void NewBreakpointDialog::ShowConditionHelp() "p = r3 + 0x8, p == 0x8003510 && read_u32(p) != 0\n" "Write and break: r4 = 8, 1\n" "Write and continue: f3 = f1 + f2, 0\n" - "The condition must always be last\n"); + "The condition must always be last\n\n" + "All variables will be printed in the Memory Interface log, if there's a hit or a NaN " + "result. To check for issues, assign a variable to your equation, so it can be printed.\n\n" + "Note: All values are internally converted to Doubles for calculations. It's possible for " + "them to go out of range or to become NaN. A warning will be given if NaN is returned, and " + "the var that became NaN will be logged."); ModalMessageBox::information(this, tr("Conditional help"), message); }