Breakpoint logging

This commit is contained in:
x1nixmzeng 2018-04-13 21:48:59 +01:00
parent 2d01a4815b
commit 182d22854d
4 changed files with 104 additions and 28 deletions

View File

@ -598,8 +598,16 @@ namespace CxbxDebugger
break;
case ExceptionCode.Breakpoint:
// TODO Handle
{
var Thread = DebugInstance.MainProcess.FindThread((uint)DebugEvent.dwThreadId);
if (Thread != null)
{
foreach (IDebuggerExceptionEvents Event in ExceptionEvents)
{
Event.OnBreakpoint(Thread, (uint)DebugInfo.ExceptionRecord.ExceptionAddress);
}
}
}
break;
case ExceptionCode.SingleStep:

View File

@ -38,6 +38,7 @@ namespace CxbxDebugger
public interface IDebuggerExceptionEvents
{
bool OnAccessViolation(DebuggerThread Thread, uint Code, uint Address);
void OnBreakpoint(DebuggerThread Thread, uint Address);
}
public interface IDebuggerFileEvents

View File

@ -88,10 +88,14 @@
this.diagBrowseCT = new System.Windows.Forms.OpenFileDialog();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.txDisassembly = new CxbxDebugger.RicherTextBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.listView2 = new System.Windows.Forms.ListView();
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.txDisassembly = new CxbxDebugger.RicherTextBox();
this.toolStrip1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.statusBar.SuspendLayout();
@ -712,6 +716,7 @@
//
// tabTweaks
//
this.tabTweaks.Controls.Add(this.listView2);
this.tabTweaks.Controls.Add(this.checkBox1);
this.tabTweaks.Controls.Add(this.listView1);
this.tabTweaks.Controls.Add(this.button2);
@ -741,13 +746,14 @@
//
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader5,
this.columnHeader8,
this.columnHeader4,
this.columnHeader7,
this.columnHeader6});
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(144, 6);
this.listView1.Location = new System.Drawing.Point(144, 9);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(598, 181);
this.listView1.Size = new System.Drawing.Size(349, 181);
this.listView1.TabIndex = 1;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
@ -755,17 +761,55 @@
// columnHeader4
//
this.columnHeader4.Text = "Description";
this.columnHeader4.Width = 200;
//
// columnHeader5
//
this.columnHeader5.Text = "Module";
this.columnHeader5.Width = 100;
this.columnHeader4.Width = 150;
//
// columnHeader6
//
this.columnHeader6.Text = "Offset";
this.columnHeader6.Width = 150;
this.columnHeader6.Text = "Type";
this.columnHeader6.Width = 80;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(6, 35);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(102, 17);
this.checkBox1.TabIndex = 3;
this.checkBox1.Text = "Apply on launch";
this.checkBox1.UseVisualStyleBackColor = true;
//
// listView2
//
this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader10,
this.columnHeader11});
this.listView2.FullRowSelect = true;
this.listView2.Location = new System.Drawing.Point(499, 9);
this.listView2.Name = "listView2";
this.listView2.Size = new System.Drawing.Size(243, 181);
this.listView2.TabIndex = 4;
this.listView2.UseCompatibleStateImageBehavior = false;
this.listView2.View = System.Windows.Forms.View.Details;
//
// columnHeader10
//
this.columnHeader10.Text = "Address";
this.columnHeader10.Width = 200;
//
// columnHeader11
//
this.columnHeader11.Text = "Name";
this.columnHeader11.Width = 200;
//
// columnHeader7
//
this.columnHeader7.Text = "Address";
this.columnHeader7.Width = 150;
//
// columnHeader8
//
this.columnHeader8.Text = "Active";
this.columnHeader8.Width = 50;
//
// txDisassembly
//
@ -782,16 +826,6 @@
this.txDisassembly.TabIndex = 1;
this.txDisassembly.Text = "";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(6, 35);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(102, 17);
this.checkBox1.TabIndex = 3;
this.checkBox1.Text = "Apply on launch";
this.checkBox1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -909,10 +943,14 @@
private System.Windows.Forms.Button button2;
private System.Windows.Forms.OpenFileDialog diagBrowseCT;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.ListView listView2;
private System.Windows.Forms.ColumnHeader columnHeader10;
private System.Windows.Forms.ColumnHeader columnHeader11;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.ColumnHeader columnHeader8;
}
}

View File

@ -425,6 +425,11 @@ namespace CxbxDebugger
return frm.DebugAsk(ExceptionMessage);
}
public void OnBreakpoint(DebuggerThread Thread, uint Address)
{
frm.DebugLog(string.Format("Breakpoing hit at 0x{0:X8}", Address));
}
public void OnFileOpened(DebuggerMessages.FileOpened Info)
{
if (Info.Succeeded)
@ -980,6 +985,15 @@ namespace CxbxDebugger
HandleDisasmGo();
}
private static System.Drawing.Color MakeColor(uint RGB)
{
int r = (int)(RGB & 0xFF);
int g = (int)((RGB >> 8) & 0xFF);
int b = (int)((RGB >> 16) & 0xFF);
return System.Drawing.Color.FromArgb(r, g, b);
}
private void button2_Click_1(object sender, EventArgs e)
{
if( diagBrowseCT.ShowDialog() == DialogResult.OK)
@ -994,14 +1008,29 @@ namespace CxbxDebugger
listView1.BeginUpdate();
listView1.Items.Clear();
foreach (var code in ct_data.CodeEntires)
foreach (var code in ct_data.CheatEntries)
{
var li = listView1.Items.Add(code.ModuleName);
var li = listView1.Items.Add("");
li.SubItems.Add(code.Description);
li.SubItems.Add(string.Format("{0:x8}", code.Address));
li.SubItems.Add(code.VariableType.ToString());
li.Checked = code.LastState.Activated;
li.ForeColor = MakeColor(code.Color);
}
listView1.EndUpdate();
listView2.BeginUpdate();
listView2.Items.Clear();
foreach (var code in ct_data.CodeEntires)
{
var li = listView2.Items.Add(string.Format("{0} +{1:X}", code.ModuleName, code.ModuleNameOffset));
li.SubItems.Add(code.Description);
}
listView2.EndUpdate();
}
}
}