diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2022-12-04 14:16:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-04 14:16:12 +0100 |
| commit | 2b93d5e0d781f0a0d700cc201b5c4498dc722f05 (patch) | |
| tree | fa2e466b28477f8a6d583be1e0c6a04806f73ec5 /Source | |
| parent | 2bd47d14352253f3dd472bc32b5989e431557afb (diff) | |
| parent | 76bf1b5f7d77323a407de90b3714208771901e88 (diff) | |
Merge pull request #11273 from TryTwo/PR_Conditional_BP_Callstack
Debugger: add callstack to conditional breakpoints
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/PowerPC/Expression.cpp | 32 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/BreakpointDialog.cpp | 3 |
2 files changed, 34 insertions, 1 deletions
diff --git a/Source/Core/Core/PowerPC/Expression.cpp b/Source/Core/Core/PowerPC/Expression.cpp index b25149c41f..87b3a5624a 100644 --- a/Source/Core/Core/PowerPC/Expression.cpp +++ b/Source/Core/Core/PowerPC/Expression.cpp @@ -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}, {}, }}; diff --git a/Source/Core/DolphinQt/Debugger/BreakpointDialog.cpp b/Source/Core/DolphinQt/Debugger/BreakpointDialog.cpp index 91dff3baf5..6c9edd54c4 100644 --- a/Source/Core/DolphinQt/Debugger/BreakpointDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/BreakpointDialog.cpp @@ -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 " |
