diff options
| author | TryTwo <taolas@gmail.com> | 2022-10-08 14:54:10 -0700 |
|---|---|---|
| committer | TryTwo <taolas@gmail.com> | 2022-10-23 08:22:35 -0700 |
| commit | e2df81b0c157c0da2cdac99feb42e3004dc2e499 (patch) | |
| tree | 0cf49e8ae734a3edb10a2585f8f9d2e49e49277b | |
| parent | 1ed6028af415075e7cc2b251415dd97ee477002b (diff) | |
Add logging and error reporting to Breakpoint Conditionals.
| -rw-r--r-- | Source/Core/Core/PowerPC/Expression.cpp | 28 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/Expression.h | 1 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp | 7 |
3 files changed, 35 insertions, 1 deletions
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 <algorithm> #include <cstdlib> +#include <fmt/format.h> #include <optional> #include <string> #include <string_view> @@ -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); } |
