From f79d8332a6ac2d563a532999c2bffe921a1dea45 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 23 Dec 2014 18:24:01 +0000 Subject: [PATCH] Debugger - fix how IMemoryCallbackSystem is used, breakpoint control no longer permanently disabled even when it is implemented in a core --- .../Debugger/GenericDebugger.IToolForm.cs | 25 +++++++++++++++++-- .../tools/Debugger/GenericDebugger.cs | 17 +++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs index 9afe4f9d36..621fa1b180 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs @@ -15,8 +15,8 @@ namespace BizHawk.Client.EmuHawk private IDisassemblable Disassembler { get; set; } [OptionalService] private IMemoryDomains MemoryDomainSource { get; set; } - [OptionalService] - private IMemoryCallbackSystem MCS { get; set; } + + private IMemoryCallbackSystem MemoryCallbacks { get { return Debuggable.MemoryCallbacks; } } private MemoryDomainList MemoryDomains { get { return MemoryDomainSource.MemoryDomains; } } @@ -28,6 +28,27 @@ namespace BizHawk.Client.EmuHawk #region Implementation checking + private bool CanUseMemoryCallbacks + { + get + { + if (Debuggable != null) + { + try + { + var result = Debuggable.MemoryCallbacks.HasReads; + return true; + } + catch (NotImplementedException) + { + return false; + } + } + + return false; + } + } + private bool CanDisassemble { get diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs index ec166ba345..6c01a05f30 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs @@ -91,11 +91,18 @@ namespace BizHawk.Client.EmuHawk RegisterPanel.ParentDebugger = this; RegisterPanel.GenerateUI(); - BreakPointControl1.Core = Debuggable; - BreakPointControl1.MCS = MCS; - BreakPointControl1.ParentDebugger = this; - BreakPointControl1.MemoryDomains = MemoryDomains; - BreakPointControl1.GenerateUI(); + if (CanUseMemoryCallbacks) + { + BreakPointControl1.Core = Debuggable; + BreakPointControl1.MCS = MemoryCallbacks; + BreakPointControl1.ParentDebugger = this; + BreakPointControl1.MemoryDomains = MemoryDomains; + BreakPointControl1.GenerateUI(); + } + else + { + DisableBreakpointBox(); + } StepIntoMenuItem.Enabled = StepIntoBtn.Enabled = CanStepInto; StepOutMenuItem.Enabled = StepOutBtn.Enabled = CanStepOut;