BizHawk/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs

174 lines
2.8 KiB
C#
Raw Normal View History

2014-12-13 23:15:39 +00:00
using System;
using System.Collections.Generic;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class GenericDebugger : IToolForm
{
2014-12-15 03:19:23 +00:00
[RequiredService]
private IDebuggable Debuggable { get; set; }
2014-12-15 03:19:23 +00:00
[OptionalService]
private IDisassemblable Disassembler { get; set; }
[OptionalService]
private IMemoryDomains MemoryDomainSource { get; set; }
private IMemoryCallbackSystem MemoryCallbacks { get { return Debuggable.MemoryCallbacks; } }
private IMemoryDomainList MemoryDomains { get { return MemoryDomainSource.MemoryDomains; } }
private uint PC
{
// TODO: is this okay for N64?
get { return (uint)Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].Value; }
}
2014-12-13 23:15:39 +00:00
2014-12-18 02:42:53 +00:00
#region Implementation checking
private bool CanUseMemoryCallbacks
{
get
{
if (Debuggable != null)
{
try
{
var result = Debuggable.MemoryCallbacks.HasReads;
return true;
}
catch (NotImplementedException)
{
return false;
}
}
return false;
}
}
2014-12-18 02:42:53 +00:00
private bool CanDisassemble
{
get
{
if (Disassembler == null)
{
return false;
}
try
{
var pc = PC;
return true;
}
catch (NotImplementedException)
{
return false;
}
}
}
private bool CanSetCpu
{
get
{
try
{
Disassembler.Cpu = Disassembler.Cpu;
return true;
}
catch (NotImplementedException)
{
return false;
}
}
}
private bool CanStepInto
{
get
{
try
{
return Debuggable.CanStep(StepType.Into);
}
catch (NotImplementedException)
{
return false;
}
}
}
private bool CanStepOver
{
get
{
try
{
return Debuggable.CanStep(StepType.Over);
}
catch (NotImplementedException)
{
return false;
}
}
}
private bool CanStepOut
{
get
{
try
{
return Debuggable.CanStep(StepType.Out);
}
catch (NotImplementedException)
{
return false;
}
}
}
2014-12-18 02:42:53 +00:00
#endregion
public void UpdateValues()
{
2014-12-20 13:48:56 +00:00
// TODO: probably none of this
2014-12-06 13:42:59 +00:00
RegisterPanel.UpdateValues();
UpdateDisassembler();
}
2014-12-20 13:48:56 +00:00
private void FullUpdate()
{
RegisterPanel.UpdateValues();
UpdateDisassembler();
2014-12-23 17:49:05 +00:00
// TODO: check for new breakpoints and add them to the Breakpoint list?
2014-12-20 13:48:56 +00:00
}
public void FastUpdate()
{
2014-12-23 17:49:05 +00:00
// Nothing to do
}
public void Restart()
{
2014-12-23 17:44:59 +00:00
DisengageDebugger();
EngageDebugger();
}
public bool AskSaveChanges()
{
// TODO
return true;
}
public bool UpdateBefore
{
get { return false; }
}
}
}