GPGX - trace logging support, the output is very bad, needs to be cleaned up
This commit is contained in:
parent
dfb0cf37d8
commit
e5b6921c7d
|
@ -771,37 +771,38 @@
|
|||
<Compile Include="Consoles\Sega\gpgx\GenDbgHlp.cs" />
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.cs" />
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.ICodeDataLogger.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IDebuggable.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IDisassembler.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IDriveLight.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IEmulator.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IInputPollable.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IMemoryDomains.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.ISaveRam.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.ISettable.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IStatable.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.ITraceable.cs" />
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGX.IVideoProvider.cs">
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
<DependentUpon>GPGX.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\gpgx\GPGXControlConverter.cs" />
|
||||
<Compile Include="Consoles\Sega\gpgx\LibGPGX.cs" />
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using System;
|
||||
using System.Text;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
||||
{
|
||||
public partial class GPGX
|
||||
{
|
||||
private readonly ITraceable Tracer;
|
||||
|
||||
// TODO: move this to BaseImplementations and make the TraceFromCallback settable by the core
|
||||
public class CallbackBasedTraceBuffer : ITraceable
|
||||
{
|
||||
public CallbackBasedTraceBuffer(IDebuggable debuggableCore)
|
||||
{
|
||||
if (!debuggableCore.MemoryCallbacksAvailable())
|
||||
{
|
||||
throw new InvalidOperationException("Memory callbacks are required");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var dummy = debuggableCore.GetCpuFlagsAndRegisters();
|
||||
}
|
||||
catch(NotImplementedException)
|
||||
{
|
||||
throw new InvalidOperationException("GetCpuFlagsAndRegisters is required");
|
||||
}
|
||||
|
||||
Buffer = new StringBuilder();
|
||||
Header = "Instructions";
|
||||
DebuggableCore = debuggableCore;
|
||||
|
||||
}
|
||||
|
||||
private readonly IDebuggable DebuggableCore;
|
||||
|
||||
private readonly StringBuilder Buffer;
|
||||
|
||||
private bool _enabled;
|
||||
|
||||
private void TraceFromCallback()
|
||||
{
|
||||
var regs = DebuggableCore.GetCpuFlagsAndRegisters();
|
||||
foreach(var r in regs)
|
||||
{
|
||||
Buffer.Append(string.Format("{0} {1}", r.Key, r.Value.Value));
|
||||
}
|
||||
|
||||
Buffer.AppendLine();
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_enabled = value;
|
||||
DebuggableCore.MemoryCallbacks.Remove(TraceFromCallback);
|
||||
|
||||
if (_enabled)
|
||||
{
|
||||
DebuggableCore.MemoryCallbacks.Add(new TracingMemoryCallback(TraceFromCallback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Header { get; set; }
|
||||
|
||||
public string Contents
|
||||
{
|
||||
get { return Buffer.ToString(); }
|
||||
}
|
||||
|
||||
public string TakeContents()
|
||||
{
|
||||
string s = Buffer.ToString();
|
||||
Buffer.Clear();
|
||||
return s;
|
||||
}
|
||||
|
||||
public void Put(string content)
|
||||
{
|
||||
if (_enabled)
|
||||
{
|
||||
Buffer.AppendLine(content);
|
||||
}
|
||||
}
|
||||
|
||||
public class TracingMemoryCallback : IMemoryCallback
|
||||
{
|
||||
public TracingMemoryCallback(Action callback)
|
||||
{
|
||||
Callback = callback;
|
||||
}
|
||||
|
||||
public MemoryCallbackType Type
|
||||
{
|
||||
get { return MemoryCallbackType.Execute; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Trace Logging"; }
|
||||
}
|
||||
|
||||
public Action Callback { get; private set; }
|
||||
|
||||
public uint? Address
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
)]
|
||||
public partial class GPGX : IEmulator, ISyncSoundProvider, IVideoProvider, ISaveRam, IStatable, IRegionable,
|
||||
IInputPollable, IDebuggable, IDriveLight, ICodeDataLogger, IDisassemblable
|
||||
{
|
||||
{
|
||||
static GPGX AttachedCore = null;
|
||||
|
||||
DiscSystem.Disc CD;
|
||||
|
@ -161,6 +161,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
InitMemCallbacks();
|
||||
KillMemCallbacks();
|
||||
|
||||
Tracer = new CallbackBasedTraceBuffer(this);
|
||||
(ServiceProvider as BasicServiceProvider).Register<ITraceable>(Tracer);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue