From d8097a1c940957d3ee126b644e1eba02bf9dbef5 Mon Sep 17 00:00:00 2001 From: Sour Date: Tue, 25 Dec 2018 00:00:38 -0500 Subject: [PATCH] Debugger: Display read/written value when breaking execution --- Core/Debugger.cpp | 9 +++++---- Core/Debugger.h | 2 +- GUI.NET/Debugger/frmDebugger.cs | 8 +++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index d3f43ac0..3c403010 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -397,7 +397,7 @@ bool Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI if(needBreak && allowBreak) { //Found a matching breakpoint, stop execution Step(1); - SleepUntilResume(BreakSource::Breakpoint, breakpointId, type, operationInfo.Address, operationInfo.OperationType); + SleepUntilResume(BreakSource::Breakpoint, breakpointId, type, operationInfo.Address, operationInfo.Value, operationInfo.OperationType); return true; } else { return false; @@ -449,7 +449,7 @@ void Debugger::ProcessAllBreakpoints(OperationInfo &operationInfo, AddressTypeIn //Break on uninit memory read if(_memoryAccessCounter->IsAddressUninitialized(addressInfo)) { Step(1); - SleepUntilResume(BreakSource::BreakOnUninitMemoryRead, 0, BreakpointType::ReadRam, addr); + SleepUntilResume(BreakSource::BreakOnUninitMemoryRead, 0, BreakpointType::ReadRam, addr, value); return; } } @@ -874,7 +874,7 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin return true; } -bool Debugger::SleepUntilResume(BreakSource source, uint32_t breakpointId, BreakpointType bpType, uint16_t bpAddress, MemoryOperationType bpMemOpType) +bool Debugger::SleepUntilResume(BreakSource source, uint32_t breakpointId, BreakpointType bpType, uint16_t bpAddress, uint8_t bpValue, MemoryOperationType bpMemOpType) { int32_t stepCount = _stepCount.load(); if(stepCount > 0) { @@ -902,7 +902,8 @@ bool Debugger::SleepUntilResume(BreakSource source, uint32_t breakpointId, Break _breakSource = BreakSource::Unspecified; uint64_t param = ( - ((uint64_t)breakpointId << 32) | + ((uint64_t)breakpointId << 40) | + ((uint64_t)bpValue << 32) | ((uint64_t)(bpAddress & 0xFFFF) << 16) | ((uint64_t)((int)bpMemOpType & 0x0F) << 12) | ((uint64_t)(bpType & 0x0F) << 8) | diff --git a/Core/Debugger.h b/Core/Debugger.h index 4ea3d41b..e705e103 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -150,7 +150,7 @@ private: void UpdateCallstack(uint8_t currentInstruction, uint32_t addr); void ProcessStepConditions(uint16_t addr); - bool SleepUntilResume(BreakSource source, uint32_t breakpointId = 0, BreakpointType bpType = BreakpointType::Global, uint16_t bpAddress = 0, MemoryOperationType bpMemOpType = MemoryOperationType::Read); + bool SleepUntilResume(BreakSource source, uint32_t breakpointId = 0, BreakpointType bpType = BreakpointType::Global, uint16_t bpAddress = 0, uint8_t bpValue = 0, MemoryOperationType bpMemOpType = MemoryOperationType::Read); void AddDebugEvent(DebugEventType type, uint16_t address = -1, uint8_t value = 0, int16_t breakpointId = -1, int8_t ppuLatch = -1); diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index ffc66fe0..93d2b90a 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -498,7 +498,8 @@ namespace Mesen.GUI.Debugger if(ConfigManager.Config.DebugInfo.ShowBreakNotifications) { message = ResourceHelper.GetEnumText(source); if(source == BreakSource.Breakpoint) { - int breakpointId = (int)(param >> 32); + int breakpointId = (int)(param >> 40); + byte bpValue = (byte)((param >> 32) & 0xFF); BreakpointType bpType = (BreakpointType)(byte)((param >> 8) & 0x0F); InteropMemoryOperationType memOpType = (InteropMemoryOperationType)(byte)((param >> 12) & 0x0F); UInt16 bpAddress = (UInt16)(param >> 16); @@ -507,7 +508,7 @@ namespace Mesen.GUI.Debugger if(breakpointId >= 0 && breakpointId < breakpoints.Count) { Breakpoint bp = breakpoints[breakpointId]; if(bpType != BreakpointType.Global) { - message += ": " + ResourceHelper.GetEnumText(bpType) + " ($" + bpAddress.ToString("X4") + ")"; + message += ": " + ResourceHelper.GetEnumText(bpType) + " ($" + bpAddress.ToString("X4") + ":$" + bpValue.ToString("X2") + ")"; } if(!string.IsNullOrWhiteSpace(bp.Condition)) { string cond = bp.Condition.Trim(); @@ -520,7 +521,8 @@ namespace Mesen.GUI.Debugger } } else if(source == BreakSource.BreakOnUninitMemoryRead) { UInt16 address = (UInt16)(param >> 16); - message += " ($" + address.ToString("X4") + ")"; + byte value = (byte)((param >> 32) & 0xFF); + message += " ($" + address.ToString("X4") + ":$" + value.ToString("X2") + ")"; } else if(source == BreakSource.CpuStep || source == BreakSource.PpuStep) { //Don't display anything when breaking due to stepping message = null;