From b92fab88b6080e3706baf22f541b565e2e80568c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Sep 2020 13:41:29 -0700 Subject: [PATCH] Debugger: Add formats to breakpoint logging. --- Core/Debugger/Breakpoints.cpp | 47 ++++++++++++++++++++++++++++++++--- Windows/ppsspp.rc | 11 ++++---- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index f3501a370c..c988712be3 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -24,6 +24,7 @@ #include "Core/Debugger/Breakpoints.h" #include "Core/Debugger/SymbolMap.h" #include "Core/Host.h" +#include "Core/MemMap.h" #include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSDebugInterface.h" #include "Core/MIPS/JitCommon/JitCommon.h" @@ -689,17 +690,55 @@ bool CBreakPoints::EvaluateLogFormat(DebugInterface *cpu, const std::string &fmt if (expression.empty()) { result += "{}"; } else { + int type = 'x'; + if (expression.length() > 2 && expression[expression.length() - 2] == ':') { + switch (expression[expression.length() - 1]) { + case 'd': + case 'f': + case 'p': + case 's': + case 'x': + type = expression[expression.length() - 1]; + expression.resize(expression.length() - 2); + break; + + default: + // Assume a ternary. + break; + } + } + if (!cpu->initExpression(expression.c_str(), exp)) { return false; } - u32 expResult; - char resultString[32]; - if (!cpu->parseExpression(exp, expResult)) { + union { + int i; + u32 u; + float f; + } expResult; + char resultString[256]; + if (!cpu->parseExpression(exp, expResult.u)) { return false; } - snprintf(resultString, 32, "%08x", expResult); + switch (type) { + case 'd': + snprintf(resultString, sizeof(resultString), "%d", expResult.i); + break; + case 'f': + snprintf(resultString, sizeof(resultString), "%f", expResult.f); + break; + case 'p': + snprintf(resultString, sizeof(resultString), "%08x[%08x]", expResult.u, Memory::IsValidAddress(expResult.u) ? Memory::Read_U32(expResult.u) : 0); + break; + case 's': + snprintf(resultString, sizeof(resultString) - 1, "%s", Memory::IsValidAddress(expResult.u) ? Memory::GetCharPointer(expResult.u) : "(invalid)"); + break; + case 'x': + snprintf(resultString, sizeof(resultString), "%08x", expResult.u); + break; + } result += resultString; } diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index f47d373935..5dcb0806a8 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -351,7 +351,7 @@ BEGIN CONTROL "",IDC_TABDATATYPE,"SysTabControl32",TCS_BUTTONS,0,1,205,15 END -IDD_BREAKPOINT DIALOGEX 0, 0, 236, 109 +IDD_BREAKPOINT DIALOGEX 0, 0, 236, 119 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Breakpoint" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -369,10 +369,11 @@ BEGIN EDITTEXT IDC_BREAKPOINT_CONDITION,41,49,187,14,ES_AUTOHSCROLL LTEXT "Log fmt",IDC_STATIC,7,71,31,8 EDITTEXT IDC_BREAKPOINT_LOG_FORMAT,41,69,187,14,ES_AUTOHSCROLL - CONTROL "Break",IDC_BREAKPOINT_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,41,91,41,10 - CONTROL "Log",IDC_BREAKPOINT_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,91,27,10 - DEFPUSHBUTTON "OK",IDC_BREAKPOINT_OK,144,88,41,14 - PUSHBUTTON "Cancel",IDC_BREAKPOINT_CANCEL,186,88,42,14 + LTEXT "Use {a1+a2} or {s1:d} to log expressions",IDC_STATIC,41,85,187,8 + CONTROL "Break",IDC_BREAKPOINT_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,41,101,41,10 + CONTROL "Log",IDC_BREAKPOINT_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,101,27,10 + DEFPUSHBUTTON "OK",IDC_BREAKPOINT_OK,144,98,41,14 + PUSHBUTTON "Cancel",IDC_BREAKPOINT_CANCEL,186,98,42,14 END IDD_DUMPMEMORY DIALOGEX 0, 0, 230, 85