2014-12-06 15:07:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|
|
|
|
{
|
|
|
|
|
public partial class BreakpointControl : UserControl
|
|
|
|
|
{
|
|
|
|
|
public IDebuggable Core { get; set; }
|
|
|
|
|
public GenericDebugger ParentDebugger { get; set; }
|
|
|
|
|
private readonly BreakpointList Breakpoints = new BreakpointList();
|
|
|
|
|
|
|
|
|
|
public BreakpointControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
BreakpointView.QueryItemText += BreakPointView_QueryItemText;
|
|
|
|
|
BreakpointView.VirtualMode = true;
|
|
|
|
|
Breakpoints.Callback = BreakpointCallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BreakpointControl_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BreakPointView_QueryItemText(int index, int column, out string text)
|
|
|
|
|
{
|
|
|
|
|
text = string.Empty;
|
|
|
|
|
switch (column)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
text = string.Format("{0:X4}", Breakpoints[index].Address);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
text = Breakpoints[index].Type.ToString();
|
|
|
|
|
break;
|
2014-12-10 22:47:09 +00:00
|
|
|
|
case 2:
|
|
|
|
|
text = Breakpoints[index].Name;
|
|
|
|
|
break;
|
2014-12-06 15:07:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BreakpointCallback()
|
|
|
|
|
{
|
|
|
|
|
GlobalWin.MainForm.PauseEmulator();
|
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateValues()
|
|
|
|
|
{
|
|
|
|
|
if (this.Enabled)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GenerateUI()
|
|
|
|
|
{
|
|
|
|
|
if (Core.MemoryCallbacksAvailable())
|
|
|
|
|
{
|
2014-12-07 19:38:42 +00:00
|
|
|
|
foreach (var callback in Core.MemoryCallbacks)
|
|
|
|
|
{
|
2014-12-10 22:47:09 +00:00
|
|
|
|
Breakpoints.Add(new Breakpoint(Core, callback));
|
2014-12-07 19:38:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-10 22:47:09 +00:00
|
|
|
|
BreakpointView.ItemCount = Breakpoints.Count;
|
2014-12-07 19:38:42 +00:00
|
|
|
|
BreakpointView.Refresh();
|
2014-12-06 15:07:01 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
Breakpoints.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddBreakpointButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-12-10 22:47:09 +00:00
|
|
|
|
var b = new AddBreakpointDialog();
|
2014-12-06 15:07:01 +00:00
|
|
|
|
if (b.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
Breakpoints.Add(Core, b.Address, b.BreakType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakpointView.ItemCount = Breakpoints.Count;
|
|
|
|
|
UpdateBreakpointRemoveButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<int> SelectedIndices
|
|
|
|
|
{
|
|
|
|
|
get { return BreakpointView.SelectedIndices.Cast<int>(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Breakpoint> SelectedItems
|
|
|
|
|
{
|
|
|
|
|
get { return SelectedIndices.Select(index => Breakpoints[index]); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveBreakpointButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (BreakpointView.SelectedIndices.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var items = SelectedItems.ToList();
|
|
|
|
|
if (items.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
Breakpoints.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakpointView.ItemCount = Breakpoints.Count;
|
|
|
|
|
UpdateBreakpointRemoveButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateBreakpointRemoveButton()
|
|
|
|
|
{
|
|
|
|
|
RemoveBreakpointButton.Enabled = BreakpointView.SelectedIndices.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|