mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Add callstack to conditional breakpoints. Checks entire stack for value.
Use: callstack(0x80000000). !callstack(value) works as a 'does not contain'. Add strings to expr.h conditionals. Use quotations: callstack("anim") to check symbols/name.
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Debugger/Debugger_SymbolMap.h"
|
||||
#include "Core/PowerPC/MMU.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
@ -102,7 +103,35 @@ static double CastFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||
return Common::BitCast<T>(static_cast<U>(expr_eval(&vec_nth(args, 0))));
|
||||
}
|
||||
|
||||
static std::array<expr_func, 21> g_expr_funcs{{
|
||||
static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||
{
|
||||
if (vec_len(args) != 1)
|
||||
return 0;
|
||||
|
||||
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
||||
bool success = Dolphin_Debugger::GetCallstack(stack);
|
||||
if (!success)
|
||||
return 0;
|
||||
|
||||
double num = expr_eval(&vec_nth(args, 0));
|
||||
if (!std::isnan(num))
|
||||
{
|
||||
u32 address = static_cast<u32>(num);
|
||||
return std::any_of(stack.begin(), stack.end(),
|
||||
[address](const auto& s) { return s.vAddress == address; });
|
||||
}
|
||||
|
||||
const char* cstr = expr_get_str(&vec_nth(args, 0));
|
||||
if (cstr != nullptr)
|
||||
{
|
||||
return std::any_of(stack.begin(), stack.end(),
|
||||
[cstr](const auto& s) { return s.Name.find(cstr) != std::string::npos; });
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static std::array<expr_func, 22> g_expr_funcs{{
|
||||
// For internal storage and comparisons, everything is auto-converted to Double.
|
||||
// If u64 ints are added, this could produce incorrect results.
|
||||
{"read_u8", HostReadFunc<u8>},
|
||||
@ -124,6 +153,7 @@ static std::array<expr_func, 21> g_expr_funcs{{
|
||||
{"s16", CastFunc<s16, u16>},
|
||||
{"u32", CastFunc<u32>},
|
||||
{"s32", CastFunc<s32, u32>},
|
||||
{"callstack", CallstackFunc},
|
||||
{},
|
||||
}};
|
||||
|
||||
|
@ -324,6 +324,7 @@ void BreakpointDialog::ShowConditionHelp()
|
||||
"Functions:\n"
|
||||
"Set a register: r1 = 8\n"
|
||||
"Casts: s8(0xff). Available: s8, u8, s16, u16, s32, u32\n"
|
||||
"Callstack: callstack(0x80123456), callstack(\"anim\")\n"
|
||||
"Read Memory: read_u32(0x80000000). Available: u8, s8, u16, s16, u32, s32, f32, f64\n"
|
||||
"Write Memory: write_u32(r3, 0x80000000). Available: u8, u16, u32, f32, f64\n"
|
||||
"*currently writing will always be triggered\n"
|
||||
@ -342,6 +343,8 @@ void BreakpointDialog::ShowConditionHelp()
|
||||
"Write and break: r4 = 8, 1\n"
|
||||
"Write and continue: f3 = f1 + f2, 0\n"
|
||||
"The condition must always be last\n\n"
|
||||
"Strings should only be used in callstack() and \"quoted\". Do not assign strings to a "
|
||||
"variable.\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 "
|
||||
|
Reference in New Issue
Block a user