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; }
|
2015-01-14 21:55:48 +00:00
|
|
|
|
|
2014-12-15 03:19:23 +00:00
|
|
|
|
[OptionalService]
|
|
|
|
|
private IDisassemblable Disassembler { get; set; }
|
2015-01-14 21:55:48 +00:00
|
|
|
|
|
2017-08-02 03:05:17 +00:00
|
|
|
|
[RequiredService]
|
2015-01-14 21:55:48 +00:00
|
|
|
|
private IMemoryDomains MemoryDomains { 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-31 23:34:28 +00:00
|
|
|
|
|
|
|
|
|
private RegisterValue PCRegister
|
|
|
|
|
{
|
|
|
|
|
get { return Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName]; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-18 02:42:53 +00:00
|
|
|
|
#region Implementation checking
|
|
|
|
|
|
2017-04-23 16:42:26 +00:00
|
|
|
|
// TODO: be cachey with checks that depend on catching exceptions
|
2014-12-23 18:24:01 +00:00
|
|
|
|
private bool CanUseMemoryCallbacks
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Debuggable != null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-02-22 16:16:05 +00:00
|
|
|
|
var result = Debuggable.MemoryCallbacks.HasReads;
|
2014-12-23 18:24:01 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2015-02-06 00:56:54 +00:00
|
|
|
|
var pc = (uint)PCRegister.Value;
|
2014-12-18 02:42:53 +00:00
|
|
|
|
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
|
|
|
|
|
|
2016-08-13 20:31:04 +00:00
|
|
|
|
public void NewUpdate(ToolFormUpdateType type) { }
|
|
|
|
|
|
2014-12-06 00:03:36 +00:00
|
|
|
|
public void UpdateValues()
|
|
|
|
|
{
|
2015-01-24 03:10:21 +00:00
|
|
|
|
// Nothing to do
|
2014-12-06 00:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-20 13:48:56 +00:00
|
|
|
|
private void FullUpdate()
|
|
|
|
|
{
|
|
|
|
|
RegisterPanel.UpdateValues();
|
2016-02-25 17:38:44 +00:00
|
|
|
|
UpdatePC();
|
2014-12-20 13:48:56 +00:00
|
|
|
|
UpdateDisassembler();
|
2015-01-25 19:50:54 +00:00
|
|
|
|
BreakPointControl1.UpdateValues();
|
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; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|