Add logging and error reporting to Breakpoint Conditionals.

This commit is contained in:
TryTwo 2022-10-08 14:54:10 -07:00
parent 1ed6028af4
commit e2df81b0c1
3 changed files with 35 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}