Debugger - implement trace logger
This commit is contained in:
parent
4a96e58a24
commit
00523ca5aa
|
@ -39,17 +39,22 @@
|
||||||
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.RestoreDefaultsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.RestoreDefaultsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.TracerBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
|
||||||
|
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
|
this.TracerBox.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
|
this.menuStrip1.ClickThrough = true;
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.fileToolStripMenuItem,
|
this.fileToolStripMenuItem,
|
||||||
this.OptionsSubMenu});
|
this.OptionsSubMenu});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(638, 24);
|
this.menuStrip1.Size = new System.Drawing.Size(685, 24);
|
||||||
this.menuStrip1.TabIndex = 1;
|
this.menuStrip1.TabIndex = 1;
|
||||||
this.menuStrip1.Text = "menuStrip1";
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
|
@ -65,7 +70,7 @@
|
||||||
//
|
//
|
||||||
this.ExitMenuItem.Name = "ExitMenuItem";
|
this.ExitMenuItem.Name = "ExitMenuItem";
|
||||||
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
||||||
this.ExitMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.ExitMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||||
this.ExitMenuItem.Text = "&Close";
|
this.ExitMenuItem.Text = "&Close";
|
||||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
@ -123,11 +128,54 @@
|
||||||
this.RestoreDefaultsMenuItem.Text = "Restore Defaults";
|
this.RestoreDefaultsMenuItem.Text = "Restore Defaults";
|
||||||
this.RestoreDefaultsMenuItem.Click += new System.EventHandler(this.RestoreDefaultsMenuItem_Click);
|
this.RestoreDefaultsMenuItem.Click += new System.EventHandler(this.RestoreDefaultsMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// TracerBox
|
||||||
|
//
|
||||||
|
this.TracerBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.TracerBox.Controls.Add(this.TraceView);
|
||||||
|
this.TracerBox.Location = new System.Drawing.Point(12, 27);
|
||||||
|
this.TracerBox.Name = "TracerBox";
|
||||||
|
this.TracerBox.Size = new System.Drawing.Size(407, 521);
|
||||||
|
this.TracerBox.TabIndex = 7;
|
||||||
|
this.TracerBox.TabStop = false;
|
||||||
|
this.TracerBox.Text = "Trace log";
|
||||||
|
//
|
||||||
|
// TraceView
|
||||||
|
//
|
||||||
|
this.TraceView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.TraceView.BlazingFast = false;
|
||||||
|
this.TraceView.CheckBoxes = true;
|
||||||
|
this.TraceView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
|
this.Script});
|
||||||
|
this.TraceView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.TraceView.FullRowSelect = true;
|
||||||
|
this.TraceView.GridLines = true;
|
||||||
|
this.TraceView.HideSelection = false;
|
||||||
|
this.TraceView.ItemCount = 0;
|
||||||
|
this.TraceView.Location = new System.Drawing.Point(8, 18);
|
||||||
|
this.TraceView.Name = "TraceView";
|
||||||
|
this.TraceView.SelectAllInProgress = false;
|
||||||
|
this.TraceView.selectedItem = -1;
|
||||||
|
this.TraceView.Size = new System.Drawing.Size(393, 491);
|
||||||
|
this.TraceView.TabIndex = 4;
|
||||||
|
this.TraceView.TabStop = false;
|
||||||
|
this.TraceView.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.TraceView.UseCustomBackground = true;
|
||||||
|
this.TraceView.View = System.Windows.Forms.View.Details;
|
||||||
|
//
|
||||||
|
// Script
|
||||||
|
//
|
||||||
|
this.Script.Text = "Instructions";
|
||||||
|
this.Script.Width = 599;
|
||||||
|
//
|
||||||
// GenericDebugger
|
// GenericDebugger
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(638, 560);
|
this.ClientSize = new System.Drawing.Size(685, 560);
|
||||||
|
this.Controls.Add(this.TracerBox);
|
||||||
this.Controls.Add(this.menuStrip1);
|
this.Controls.Add(this.menuStrip1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
|
@ -137,6 +185,7 @@
|
||||||
this.Load += new System.EventHandler(this.GenericDebugger_Load);
|
this.Load += new System.EventHandler(this.GenericDebugger_Load);
|
||||||
this.menuStrip1.ResumeLayout(false);
|
this.menuStrip1.ResumeLayout(false);
|
||||||
this.menuStrip1.PerformLayout();
|
this.menuStrip1.PerformLayout();
|
||||||
|
this.TracerBox.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -154,5 +203,8 @@
|
||||||
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem RestoreDefaultsMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem RestoreDefaultsMenuItem;
|
||||||
|
private System.Windows.Forms.GroupBox TracerBox;
|
||||||
|
private VirtualListView TraceView;
|
||||||
|
public System.Windows.Forms.ColumnHeader Script;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
public void UpdateValues()
|
public void UpdateValues()
|
||||||
{
|
{
|
||||||
// TODO
|
UpdateTraceLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FastUpdate()
|
public void FastUpdate()
|
||||||
|
|
|
@ -7,6 +7,8 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
|
@ -16,11 +18,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private int _defaultWidth;
|
private int _defaultWidth;
|
||||||
private int _defaultHeight;
|
private int _defaultHeight;
|
||||||
|
|
||||||
|
private IDebuggable Core;
|
||||||
|
private readonly List<string> _instructions = new List<string>();
|
||||||
|
|
||||||
public GenericDebugger()
|
public GenericDebugger()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
TopMost = Global.Config.GenericDebuggerSettings.TopMost;
|
TopMost = Global.Config.GenericDebuggerSettings.TopMost;
|
||||||
Closing += (o, e) => Shutdown();
|
Closing += (o, e) => DisengageDebugger();
|
||||||
|
|
||||||
|
TraceView.QueryItemText += TraceView_QueryItemText;
|
||||||
|
TraceView.VirtualMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenericDebugger_Load(object sender, EventArgs e)
|
private void GenericDebugger_Load(object sender, EventArgs e)
|
||||||
|
@ -37,13 +45,60 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Size = Global.Config.GenericDebuggerSettings.WindowSize;
|
Size = Global.Config.GenericDebuggerSettings.WindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Global.Emulator.CanDebug())
|
||||||
|
{
|
||||||
|
Core = Global.Emulator.AsDebuggable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
EngageDebugger();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Shutdown()
|
private void EngageDebugger()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Core.Tracer.Enabled = true;
|
||||||
|
}
|
||||||
|
catch (NotImplementedException)
|
||||||
|
{
|
||||||
|
TracerBox.Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisengageDebugger()
|
||||||
{
|
{
|
||||||
SaveConfigSettings();
|
SaveConfigSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateTraceLog()
|
||||||
|
{
|
||||||
|
if (TracerBox.Enabled)
|
||||||
|
{
|
||||||
|
var instructions = Core.Tracer.TakeContents().Split('\n');
|
||||||
|
if (!string.IsNullOrWhiteSpace(instructions[0]))
|
||||||
|
{
|
||||||
|
_instructions.AddRange(instructions.Where(str => !string.IsNullOrEmpty(str)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_instructions.Count >= Global.Config.TraceLoggerMaxLines)
|
||||||
|
{
|
||||||
|
_instructions.RemoveRange(0, _instructions.Count - Global.Config.TraceLoggerMaxLines);
|
||||||
|
}
|
||||||
|
|
||||||
|
TraceView.ItemCount = _instructions.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TraceView_QueryItemText(int index, int column, out string text)
|
||||||
|
{
|
||||||
|
text = index < _instructions.Count ? _instructions[index] : string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveConfigSettings()
|
private void SaveConfigSettings()
|
||||||
{
|
{
|
||||||
if (Global.Config.GenericDebuggerSettings.SaveWindowPosition)
|
if (Global.Config.GenericDebuggerSettings.SaveWindowPosition)
|
||||||
|
|
Loading…
Reference in New Issue