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
|
2014-12-06 00:03:36 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class GenericDebugger : IToolForm
|
|
|
|
|
{
|
2014-12-15 03:19:23 +00:00
|
|
|
|
[RequiredService]
|
2014-12-20 13:36:22 +00:00
|
|
|
|
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; }
|
2014-12-23 18:24:01 +00:00
|
|
|
|
|
|
|
|
|
private IMemoryCallbackSystem MemoryCallbacks { get { return Debuggable.MemoryCallbacks; } }
|
2014-12-15 22:25:06 +00:00
|
|
|
|
|
2015-01-13 22:18:07 +00:00
|
|
|
|
private IMemoryDomainList MemoryDomains { get { return MemoryDomainSource.MemoryDomains; } }
|
2014-12-14 14:30:46 +00:00
|
|
|
|
|
2014-12-20 20:33:54 +00:00
|
|
|
|
private uint PC
|
2014-12-14 14:30:46 +00:00
|
|
|
|
{
|
2014-12-20 03:19:33 +00:00
|
|
|
|
// TODO: is this okay for N64?
|
2014-12-20 20:33:54 +00:00
|
|
|
|
get { return (uint)Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].Value; }
|
2014-12-14 14:30:46 +00:00
|
|
|
|
}
|
2014-12-13 23:15:39 +00:00
|
|
|
|
|
2014-12-18 02:42:53 +00:00
|
|
|
|
#region Implementation checking
|
|
|
|
|
|
2014-12-23 18:24:01 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-20 13:12:03 +00:00
|
|
|
|
private bool CanSetCpu
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Disassembler.Cpu = Disassembler.Cpu;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (NotImplementedException)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-20 13:36:22 +00:00
|
|
|
|
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
|
|
|
|
|
|
2014-12-06 00:03:36 +00:00
|
|
|
|
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();
|
2014-12-14 14:30:46 +00:00
|
|
|
|
UpdateDisassembler();
|
2014-12-06 00:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2014-12-06 00:03:36 +00:00
|
|
|
|
public void FastUpdate()
|
|
|
|
|
{
|
2014-12-23 17:49:05 +00:00
|
|
|
|
// Nothing to do
|
2014-12-06 00:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Restart()
|
|
|
|
|
{
|
2014-12-23 17:44:59 +00:00
|
|
|
|
DisengageDebugger();
|
|
|
|
|
EngageDebugger();
|
2014-12-06 00:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AskSaveChanges()
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UpdateBefore
|
|
|
|
|
{
|
|
|
|
|
get { return false; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|