Navigate disassembly history
This commit is contained in:
parent
5f806441b4
commit
e84d9f7919
|
@ -45,10 +45,11 @@
|
|||
this.tabContainer = new System.Windows.Forms.TabControl();
|
||||
this.tabDisassembly = new System.Windows.Forms.TabPage();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.txDisassembly = new CxbxDebugger.RicherTextBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.btnDisassemble = new System.Windows.Forms.Button();
|
||||
this.txDisassemblyAddr = new System.Windows.Forms.TextBox();
|
||||
this.btnNext = new System.Windows.Forms.Button();
|
||||
this.btnPrev = new System.Windows.Forms.Button();
|
||||
this.btnGo = new System.Windows.Forms.Button();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.cbDisAddr = new System.Windows.Forms.ComboBox();
|
||||
this.tabBreakpoints = new System.Windows.Forms.TabPage();
|
||||
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
|
@ -82,6 +83,7 @@
|
|||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.lbDebug = new System.Windows.Forms.ListBox();
|
||||
this.diagSaveMemory = new System.Windows.Forms.SaveFileDialog();
|
||||
this.txDisassembly = new CxbxDebugger.RicherTextBox();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.tableLayoutPanel3.SuspendLayout();
|
||||
this.statusBar.SuspendLayout();
|
||||
|
@ -91,7 +93,6 @@
|
|||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
this.splitContainer2.Panel2.SuspendLayout();
|
||||
this.splitContainer2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.tabBreakpoints.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
|
||||
this.splitContainer3.Panel1.SuspendLayout();
|
||||
|
@ -272,63 +273,80 @@
|
|||
// splitContainer2
|
||||
//
|
||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
|
||||
this.splitContainer2.IsSplitterFixed = true;
|
||||
this.splitContainer2.Location = new System.Drawing.Point(3, 3);
|
||||
this.splitContainer2.Name = "splitContainer2";
|
||||
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
this.splitContainer2.Panel1.Controls.Add(this.txDisassembly);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.btnNext);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.btnPrev);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.btnGo);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.label6);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.cbDisAddr);
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.groupBox3);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.txDisassembly);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(742, 187);
|
||||
this.splitContainer2.SplitterDistance = 519;
|
||||
this.splitContainer2.SplitterDistance = 34;
|
||||
this.splitContainer2.TabIndex = 2;
|
||||
//
|
||||
// txDisassembly
|
||||
// btnNext
|
||||
//
|
||||
this.txDisassembly.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.txDisassembly.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txDisassembly.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.txDisassembly.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txDisassembly.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txDisassembly.Location = new System.Drawing.Point(0, 0);
|
||||
this.txDisassembly.Name = "txDisassembly";
|
||||
this.txDisassembly.ReadOnly = true;
|
||||
this.txDisassembly.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
|
||||
this.txDisassembly.Size = new System.Drawing.Size(519, 187);
|
||||
this.txDisassembly.TabIndex = 1;
|
||||
this.txDisassembly.Text = "";
|
||||
this.btnNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnNext.Location = new System.Drawing.Point(690, 3);
|
||||
this.btnNext.Name = "btnNext";
|
||||
this.btnNext.Size = new System.Drawing.Size(49, 23);
|
||||
this.btnNext.TabIndex = 3;
|
||||
this.btnNext.Text = "Next";
|
||||
this.btnNext.UseVisualStyleBackColor = true;
|
||||
this.btnNext.Click += new System.EventHandler(this.button4_Click);
|
||||
//
|
||||
// groupBox3
|
||||
// btnPrev
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.btnDisassemble);
|
||||
this.groupBox3.Controls.Add(this.txDisassemblyAddr);
|
||||
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox3.Location = new System.Drawing.Point(0, 0);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(219, 187);
|
||||
this.groupBox3.TabIndex = 0;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Disassemble Address";
|
||||
this.btnPrev.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnPrev.Location = new System.Drawing.Point(620, 3);
|
||||
this.btnPrev.Name = "btnPrev";
|
||||
this.btnPrev.Size = new System.Drawing.Size(64, 23);
|
||||
this.btnPrev.TabIndex = 2;
|
||||
this.btnPrev.Text = "Previous";
|
||||
this.btnPrev.UseVisualStyleBackColor = true;
|
||||
this.btnPrev.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// btnDisassemble
|
||||
// btnGo
|
||||
//
|
||||
this.btnDisassemble.Location = new System.Drawing.Point(6, 45);
|
||||
this.btnDisassemble.Name = "btnDisassemble";
|
||||
this.btnDisassemble.Size = new System.Drawing.Size(207, 23);
|
||||
this.btnDisassemble.TabIndex = 1;
|
||||
this.btnDisassemble.Text = "Go";
|
||||
this.btnDisassemble.UseVisualStyleBackColor = true;
|
||||
this.btnDisassemble.Click += new System.EventHandler(this.button1_Click_1);
|
||||
this.btnGo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnGo.Location = new System.Drawing.Point(539, 3);
|
||||
this.btnGo.Name = "btnGo";
|
||||
this.btnGo.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnGo.TabIndex = 1;
|
||||
this.btnGo.Text = "Go";
|
||||
this.btnGo.UseVisualStyleBackColor = true;
|
||||
this.btnGo.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// txDisassemblyAddr
|
||||
// label6
|
||||
//
|
||||
this.txDisassemblyAddr.Location = new System.Drawing.Point(6, 19);
|
||||
this.txDisassemblyAddr.Name = "txDisassemblyAddr";
|
||||
this.txDisassemblyAddr.Size = new System.Drawing.Size(207, 20);
|
||||
this.txDisassemblyAddr.TabIndex = 0;
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(3, 8);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(123, 13);
|
||||
this.label6.TabIndex = 2;
|
||||
this.label6.Text = "Disassemble by address:";
|
||||
//
|
||||
// cbDisAddr
|
||||
//
|
||||
this.cbDisAddr.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cbDisAddr.FormattingEnabled = true;
|
||||
this.cbDisAddr.Location = new System.Drawing.Point(132, 5);
|
||||
this.cbDisAddr.Name = "cbDisAddr";
|
||||
this.cbDisAddr.Size = new System.Drawing.Size(401, 21);
|
||||
this.cbDisAddr.TabIndex = 0;
|
||||
this.cbDisAddr.SelectedIndexChanged += new System.EventHandler(this.cbDisAddr_SelectedIndexChanged);
|
||||
this.cbDisAddr.KeyDown += new System.Windows.Forms.KeyEventHandler(this.comboBox1_KeyDown);
|
||||
//
|
||||
// tabBreakpoints
|
||||
//
|
||||
|
@ -682,6 +700,21 @@
|
|||
//
|
||||
this.diagSaveMemory.Filter = "Any Type|*.*";
|
||||
//
|
||||
// txDisassembly
|
||||
//
|
||||
this.txDisassembly.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.txDisassembly.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txDisassembly.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.txDisassembly.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txDisassembly.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txDisassembly.Location = new System.Drawing.Point(0, 0);
|
||||
this.txDisassembly.Name = "txDisassembly";
|
||||
this.txDisassembly.ReadOnly = true;
|
||||
this.txDisassembly.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
|
||||
this.txDisassembly.Size = new System.Drawing.Size(742, 149);
|
||||
this.txDisassembly.TabIndex = 1;
|
||||
this.txDisassembly.Text = "";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -701,11 +734,10 @@
|
|||
this.tabContainer.ResumeLayout(false);
|
||||
this.tabDisassembly.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.PerformLayout();
|
||||
this.splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
|
||||
this.splitContainer2.ResumeLayout(false);
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.tabBreakpoints.ResumeLayout(false);
|
||||
this.splitContainer3.Panel1.ResumeLayout(false);
|
||||
this.splitContainer3.Panel2.ResumeLayout(false);
|
||||
|
@ -779,9 +811,6 @@
|
|||
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
|
||||
private System.Windows.Forms.ToolStripComboBox cbFrames;
|
||||
private System.Windows.Forms.ToolStripLabel toolStripLabel2;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Button btnDisassemble;
|
||||
private System.Windows.Forms.TextBox txDisassemblyAddr;
|
||||
private System.Windows.Forms.SplitContainer splitContainer5;
|
||||
private System.Windows.Forms.TextBox txFilter;
|
||||
private System.Windows.Forms.Label label3;
|
||||
|
@ -792,6 +821,11 @@
|
|||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
private System.Windows.Forms.Button btnGo;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.ComboBox cbDisAddr;
|
||||
private System.Windows.Forms.Button btnNext;
|
||||
private System.Windows.Forms.Button btnPrev;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -542,18 +542,18 @@ namespace CxbxDebugger
|
|||
return false;
|
||||
}
|
||||
|
||||
static private bool ReadAddress(TextBox Source, ref uint Out)
|
||||
static private bool ReadAddress(string Source, ref uint Out)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Source.Text.StartsWith("0x"))
|
||||
if (Source.StartsWith("0x"))
|
||||
{
|
||||
Out = Convert.ToUInt32(Source.Text.Substring(2), 16);
|
||||
Out = Convert.ToUInt32(Source.Substring(2), 16);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uint.TryParse(Source.Text, out Out))
|
||||
if (uint.TryParse(Source, out Out))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -564,10 +564,27 @@ namespace CxbxDebugger
|
|||
return false;
|
||||
}
|
||||
|
||||
static private bool ReadAddress(ComboBox Source, ref uint Out)
|
||||
{
|
||||
string SelString = Source.Text;
|
||||
|
||||
if ( ReadAddress(SelString, ref Out) )
|
||||
{
|
||||
// Only add new addresses
|
||||
if (Source.SelectedIndex == -1)
|
||||
{
|
||||
Source.Items.Insert(0, SelString);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private byte[] ReadMemory()
|
||||
{
|
||||
uint addr = 0;
|
||||
if (!ReadAddress(txAddress, ref addr))
|
||||
if (!ReadAddress(txAddress.Text, ref addr))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -666,7 +683,7 @@ namespace CxbxDebugger
|
|||
if (EP != 0)
|
||||
{
|
||||
string LinkName = string.Format("{0} +{1:x}", Name, Address - EP);
|
||||
string Link = string.Format("{0:x8}", Address);
|
||||
string Link = string.Format("0x{0:x8}", Address);
|
||||
|
||||
tb.InsertLink(LinkName, Link);
|
||||
}
|
||||
|
@ -679,17 +696,22 @@ namespace CxbxDebugger
|
|||
|
||||
private void DumpDisassembly(uint DisAddress)
|
||||
{
|
||||
// No threads
|
||||
if (DebugThreads.Count == 0)
|
||||
return;
|
||||
|
||||
// Read preceeding bytes for more context
|
||||
// TODO: This MUST align with a previous instruction or our disassembler will fail
|
||||
uint OffsetAddr = DisAddress; // -16
|
||||
|
||||
byte[] data = DebugThreads[0].OwningProcess.ReadMemoryBlock(new IntPtr(OffsetAddr), 64);
|
||||
|
||||
txDisassembly.Clear();
|
||||
|
||||
// Dump requested after crashing - and read memory handles this silently
|
||||
if(data == null)
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
txDisassembly.BeginUpdate();
|
||||
txDisassembly.Clear();
|
||||
|
||||
// TODO: Needs refactoring
|
||||
|
||||
|
@ -733,6 +755,7 @@ namespace CxbxDebugger
|
|||
});
|
||||
}
|
||||
|
||||
txDisassembly.EndUpdate();
|
||||
txDisassembly.Select(0, 0);
|
||||
}
|
||||
|
||||
|
@ -858,20 +881,14 @@ namespace CxbxDebugger
|
|||
private void ShowDisassemblyAt(string Address)
|
||||
{
|
||||
tabContainer.SelectedTab = tabDisassembly;
|
||||
txDisassemblyAddr.Text = string.Format("0x{0}", Address);
|
||||
|
||||
|
||||
uint addr = 0;
|
||||
if (ReadAddress(txDisassemblyAddr, ref addr))
|
||||
{
|
||||
DumpDisassembly(addr);
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
uint addr = 0;
|
||||
if (ReadAddress(txDisassemblyAddr, ref addr))
|
||||
if (ReadAddress(Address, ref addr))
|
||||
{
|
||||
// Insert disassembly history
|
||||
// TODO: Keep symbol name
|
||||
cbDisAddr.Items.Insert(0, Address);
|
||||
cbDisAddr.Text = Address;
|
||||
DumpDisassembly(addr);
|
||||
}
|
||||
}
|
||||
|
@ -908,5 +925,56 @@ namespace CxbxDebugger
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void HandleDisasmGo()
|
||||
{
|
||||
uint addr = 0;
|
||||
if (ReadAddress(cbDisAddr, ref addr))
|
||||
{
|
||||
DumpDisassembly(addr);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDisasmGo(int Offset)
|
||||
{
|
||||
int TargetIndex = cbDisAddr.SelectedIndex + Offset;
|
||||
|
||||
if (TargetIndex < 0)
|
||||
return;
|
||||
|
||||
if (TargetIndex < cbDisAddr.Items.Count)
|
||||
{
|
||||
cbDisAddr.SelectedIndex = TargetIndex;
|
||||
HandleDisasmGo();
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
HandleDisasmGo();
|
||||
}
|
||||
|
||||
private void comboBox1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if( e.KeyCode == Keys.Enter )
|
||||
{
|
||||
HandleDisasmGo();
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
HandleDisasmGo(1);
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
HandleDisasmGo(-1);
|
||||
}
|
||||
|
||||
private void cbDisAddr_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
HandleDisasmGo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,18 +144,24 @@
|
|||
<metadata name="splitContainer2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="btnNext.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="btnPrev.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="btnGo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="cbDisAddr.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="txDisassembly.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="groupBox3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="btnDisassemble.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="txDisassemblyAddr.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="tabBreakpoints.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
|
Loading…
Reference in New Issue