Adding modules/functions to the debugger.

This commit is contained in:
Ben Vanik
2015-06-08 21:12:40 -07:00
parent 9d7d6df476
commit 573f190a43
47 changed files with 1427 additions and 128 deletions

View File

@@ -11,6 +11,8 @@ using WeifenLuo.WinFormsUI.Docking;
namespace Xenia.Debug.UI.Controls {
public partial class BaseDocument : DockContent {
public static MainWindow MainWindow;
public BaseDocument() {
InitializeComponent();
}

View File

@@ -11,6 +11,8 @@ using WeifenLuo.WinFormsUI.Docking;
namespace Xenia.Debug.UI.Controls {
public partial class BasePanel : DockContent {
public static MainWindow MainWindow;
public BasePanel() {
InitializeComponent();
}

View File

@@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Xenia.Debug.UI.Controls;
using Xenia.Debug.UI.Views;
using Xenia.Debug.Utilities;
@@ -36,6 +37,9 @@ namespace Xenia.Debug.UI {
public MainWindow() {
InitializeComponent();
BasePanel.MainWindow = this;
BaseDocument.MainWindow = this;
dockPanel = new DockPanel();
dockPanel.Dock = System.Windows.Forms.DockStyle.Fill;
dockPanel.DockBackColor = System.Drawing.SystemColors.AppWorkspace;
@@ -76,7 +80,7 @@ namespace Xenia.Debug.UI {
Debugger.StateChanged += Debugger_StateChanged;
Debugger_StateChanged(this, Debugger.CurrentState);
Debugger.CurrentContext.Changed += CurrentContext_Changed;
CurrentContext_Changed();
CurrentContext_Changed(Debugger.CurrentContext);
Debugger.Attach();
}
@@ -102,7 +106,7 @@ namespace Xenia.Debug.UI {
controlToolStrip.Enabled = enabled;
}
private void CurrentContext_Changed() {
private void CurrentContext_Changed(Context sender) {
bool enabled = false;
switch (Debugger.CurrentContext.RunState) {
case RunState.Updating:
@@ -157,6 +161,11 @@ namespace Xenia.Debug.UI {
dockPanel.ResumeLayout(true, true);
}
public void OpenFunction(Function function) {
var document = codeDocuments[0];
document.Show(function);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
//if (keyData == (Keys.Control | Keys.F)) {
// MessageBox.Show("What the Ctrl+F?");

View File

@@ -19,10 +19,10 @@ namespace Xenia.Debug.UI.Views {
this.debugger = debugger;
debugger.BreakpointList.Changed += UpdateBreakpointsList;
UpdateBreakpointsList();
UpdateBreakpointsList(debugger.BreakpointList);
}
private void UpdateBreakpointsList() {
private void UpdateBreakpointsList(BreakpointList sender) {
breakpointsListView.BeginUpdate();
breakpointsListView.Items.Clear();
foreach (Breakpoint breakpoint in debugger.BreakpointList) {

View File

@@ -1,4 +1,6 @@
namespace Xenia.Debug.UI.Views {
using System;
namespace Xenia.Debug.UI.Views {
partial class CodeDocument {
/// <summary>
/// Required designer variable.
@@ -24,6 +26,12 @@
/// </summary>
private void InitializeComponent() {
this.sourceTextBox = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.disasmMachineCodeCheckBox = new System.Windows.Forms.CheckBox();
this.disasmOptimizedHirCheckBox = new System.Windows.Forms.CheckBox();
this.disasmUnoptimizedHirCheckBox = new System.Windows.Forms.CheckBox();
this.disasmPpcCheckBox = new System.Windows.Forms.CheckBox();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// sourceTextBox
@@ -31,20 +39,93 @@
this.sourceTextBox.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.sourceTextBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.sourceTextBox.HideSelection = false;
this.sourceTextBox.Location = new System.Drawing.Point(12, 75);
this.sourceTextBox.MaxLength = 99999;
this.sourceTextBox.Multiline = true;
this.sourceTextBox.Name = "sourceTextBox";
this.sourceTextBox.Size = new System.Drawing.Size(740, 586);
this.sourceTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.sourceTextBox.Size = new System.Drawing.Size(740, 563);
this.sourceTextBox.TabIndex = 0;
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Controls.Add(this.disasmMachineCodeCheckBox);
this.panel1.Controls.Add(this.disasmOptimizedHirCheckBox);
this.panel1.Controls.Add(this.disasmUnoptimizedHirCheckBox);
this.panel1.Controls.Add(this.disasmPpcCheckBox);
this.panel1.Location = new System.Drawing.Point(12, 644);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(740, 17);
this.panel1.TabIndex = 1;
//
// disasmMachineCodeCheckBox
//
this.disasmMachineCodeCheckBox.AutoSize = true;
this.disasmMachineCodeCheckBox.Checked = true;
this.disasmMachineCodeCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.disasmMachineCodeCheckBox.Location = new System.Drawing.Point(302, 0);
this.disasmMachineCodeCheckBox.Name = "disasmMachineCodeCheckBox";
this.disasmMachineCodeCheckBox.Size = new System.Drawing.Size(95, 17);
this.disasmMachineCodeCheckBox.TabIndex = 3;
this.disasmMachineCodeCheckBox.Text = "Machine Code";
this.disasmMachineCodeCheckBox.UseVisualStyleBackColor = true;
this.disasmMachineCodeCheckBox.CheckedChanged += new System.EventHandler(this.DisasmCheckBoxChanged);
//
// disasmOptimizedHirCheckBox
//
this.disasmOptimizedHirCheckBox.AutoSize = true;
this.disasmOptimizedHirCheckBox.Checked = true;
this.disasmOptimizedHirCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.disasmOptimizedHirCheckBox.Location = new System.Drawing.Point(202, 0);
this.disasmOptimizedHirCheckBox.Name = "disasmOptimizedHirCheckBox";
this.disasmOptimizedHirCheckBox.Size = new System.Drawing.Size(94, 17);
this.disasmOptimizedHirCheckBox.TabIndex = 2;
this.disasmOptimizedHirCheckBox.Text = "Optimized HIR";
this.disasmOptimizedHirCheckBox.UseVisualStyleBackColor = true;
this.disasmOptimizedHirCheckBox.CheckedChanged += new System.EventHandler(this.DisasmCheckBoxChanged);
//
// disasmUnoptimizedHirCheckBox
//
this.disasmUnoptimizedHirCheckBox.AutoSize = true;
this.disasmUnoptimizedHirCheckBox.Checked = true;
this.disasmUnoptimizedHirCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.disasmUnoptimizedHirCheckBox.Location = new System.Drawing.Point(90, 0);
this.disasmUnoptimizedHirCheckBox.Name = "disasmUnoptimizedHirCheckBox";
this.disasmUnoptimizedHirCheckBox.Size = new System.Drawing.Size(106, 17);
this.disasmUnoptimizedHirCheckBox.TabIndex = 1;
this.disasmUnoptimizedHirCheckBox.Text = "Unoptimized HIR";
this.disasmUnoptimizedHirCheckBox.UseVisualStyleBackColor = true;
this.disasmUnoptimizedHirCheckBox.CheckedChanged += new System.EventHandler(this.DisasmCheckBoxChanged);
//
// disasmPpcCheckBox
//
this.disasmPpcCheckBox.AutoSize = true;
this.disasmPpcCheckBox.Checked = true;
this.disasmPpcCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.disasmPpcCheckBox.Location = new System.Drawing.Point(0, 0);
this.disasmPpcCheckBox.Name = "disasmPpcCheckBox";
this.disasmPpcCheckBox.Size = new System.Drawing.Size(84, 17);
this.disasmPpcCheckBox.TabIndex = 0;
this.disasmPpcCheckBox.Text = "Source PPC";
this.disasmPpcCheckBox.UseVisualStyleBackColor = true;
this.disasmPpcCheckBox.CheckedChanged += new System.EventHandler(this.DisasmCheckBoxChanged);
//
// CodeDocument
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(764, 673);
this.Controls.Add(this.panel1);
this.Controls.Add(this.sourceTextBox);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "CodeDocument";
this.Text = "Code";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -53,5 +134,10 @@
#endregion
private System.Windows.Forms.TextBox sourceTextBox;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.CheckBox disasmMachineCodeCheckBox;
private System.Windows.Forms.CheckBox disasmOptimizedHirCheckBox;
private System.Windows.Forms.CheckBox disasmUnoptimizedHirCheckBox;
private System.Windows.Forms.CheckBox disasmPpcCheckBox;
}
}

View File

@@ -14,9 +14,67 @@ namespace Xenia.Debug.UI.Views {
public partial class CodeDocument : BaseDocument {
private readonly Debugger debugger;
private Function function;
public CodeDocument(Debugger debugger) {
InitializeComponent();
this.debugger = debugger;
}
public async void Show(Function function) {
this.function = function;
this.sourceTextBox.Text = "Loading...";
await function.Invalidate();
UpdateSourceTextBox();
}
private void UpdateSourceTextBox() {
string combinedString = "";
if (disasmPpcCheckBox.Checked) {
combinedString += "Source PPC" + Environment.NewLine;
if (function.DisasmPpc != null) {
combinedString += function.DisasmPpc;
} else {
combinedString += "(unavailable)";
}
combinedString += Environment.NewLine + Environment.NewLine;
}
if (disasmUnoptimizedHirCheckBox.Checked) {
combinedString += "Unoptimized HIR" + Environment.NewLine;
if (function.DisasmHirUnoptimized != null) {
combinedString += function.DisasmHirUnoptimized;
} else {
combinedString += "(unavailable)";
}
combinedString += Environment.NewLine + Environment.NewLine;
}
if (disasmOptimizedHirCheckBox.Checked) {
combinedString += "Optimized HIR" + Environment.NewLine;
if (function.DisasmHirOptimized != null) {
combinedString += function.DisasmHirOptimized;
} else {
combinedString += "(unavailable)";
}
combinedString += Environment.NewLine + Environment.NewLine;
}
if (disasmMachineCodeCheckBox.Checked) {
combinedString += "Machine Code" + Environment.NewLine;
if (function.DisasmMachineCode != null) {
combinedString += function.DisasmMachineCode;
} else {
combinedString += "(unavailable)";
}
combinedString += Environment.NewLine + Environment.NewLine;
}
this.sourceTextBox.Text = combinedString;
}
private void DisasmCheckBoxChanged(object sender, EventArgs e) {
UpdateSourceTextBox();
}
}
}

View File

@@ -28,15 +28,17 @@
this.functionsListBox = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// moduleComboBox
// modulesComboBox
//
this.modulesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.modulesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.modulesComboBox.FormattingEnabled = true;
this.modulesComboBox.Location = new System.Drawing.Point(12, 12);
this.modulesComboBox.Name = "moduleComboBox";
this.modulesComboBox.Name = "modulesComboBox";
this.modulesComboBox.Size = new System.Drawing.Size(234, 21);
this.modulesComboBox.TabIndex = 0;
this.modulesComboBox.SelectedIndexChanged += new System.EventHandler(this.modulesComboBox_SelectedIndexChanged);
//
// filterTextBox
//
@@ -48,6 +50,7 @@
this.filterTextBox.Name = "filterTextBox";
this.filterTextBox.Size = new System.Drawing.Size(234, 20);
this.filterTextBox.TabIndex = 1;
this.filterTextBox.TextChanged += new System.EventHandler(this.filterTextBox_TextChanged);
//
// functionsListBox
//
@@ -59,6 +62,7 @@
this.functionsListBox.Name = "functionsListBox";
this.functionsListBox.Size = new System.Drawing.Size(234, 524);
this.functionsListBox.TabIndex = 2;
this.functionsListBox.SelectedIndexChanged += new System.EventHandler(this.functionsListBox_SelectedIndexChanged);
//
// FunctionsPanel
//
@@ -68,6 +72,7 @@
this.Controls.Add(this.functionsListBox);
this.Controls.Add(this.filterTextBox);
this.Controls.Add(this.modulesComboBox);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "FunctionsPanel";
this.Text = "Functions";
this.ResumeLayout(false);

View File

@@ -18,17 +18,84 @@ namespace Xenia.Debug.UI.Views {
InitializeComponent();
this.debugger = debugger;
RefreshFunctionList();
debugger.ModuleList.Changed += UpdateModulesList;
UpdateModulesList();
UpdateModulesList(debugger.ModuleList);
}
private void UpdateModulesList() {
private void UpdateModulesList(ModuleList sender) {
modulesComboBox.BeginUpdate();
modulesComboBox.Items.Clear();
foreach (Module module in debugger.ModuleList) {
modulesComboBox.Items.Add("Module A");
modulesComboBox.Items.Add(module);
module.Changed += Module_Changed;
}
modulesComboBox.EndUpdate();
}
private void Module_Changed(KernelObject sender) {
if (modulesComboBox.SelectedItem != sender) {
return;
}
RefreshFunctionList();
}
private void modulesComboBox_SelectedIndexChanged(object sender, EventArgs e) {
if (modulesComboBox.SelectedItem == null) {
return;
}
var module = (Module)modulesComboBox.SelectedItem;
RefreshFunctionList();
}
private void RefreshFunctionList() {
if (modulesComboBox.SelectedItem == null) {
functionsListBox.Items.Clear();
functionsListBox.Enabled = false;
filterTextBox.Enabled = false;
return;
}
functionsListBox.Enabled = true;
filterTextBox.Enabled = true;
var module = (Module)modulesComboBox.SelectedItem;
functionsListBox.BeginUpdate();
functionsListBox.Items.Clear();
foreach (Function function in module) {
functionsListBox.Items.Add(function);
}
functionsListBox.EndUpdate();
}
private void filterTextBox_TextChanged(object sender, EventArgs e) {
var module = (Module)modulesComboBox.SelectedItem;
var filter = filterTextBox.Text.ToLowerInvariant();
functionsListBox.BeginUpdate();
functionsListBox.Items.Clear();
foreach (Function function in module) {
if (filter.Length == 0 || function.LowerName.Contains(filter)) {
functionsListBox.Items.Add(function);
}
}
functionsListBox.EndUpdate();
}
private void functionsListBox_SelectedIndexChanged(object sender, EventArgs e) {
var function = (Function)functionsListBox.SelectedItem;
if (function == null) {
return;
}
MainWindow.OpenFunction(function);
}
}
}

View File

@@ -23,10 +23,15 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
System.Windows.Forms.ColumnHeader columnHeader1;
System.Windows.Forms.ColumnHeader columnHeader2;
System.Windows.Forms.ColumnHeader columnHeader3;
System.Windows.Forms.ColumnHeader columnHeader4;
this.modulesListView = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SuspendLayout();
//
// modulesListView
@@ -35,9 +40,10 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.modulesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3});
columnHeader1,
columnHeader2,
columnHeader3,
columnHeader4});
this.modulesListView.Location = new System.Drawing.Point(12, 12);
this.modulesListView.Name = "modulesListView";
this.modulesListView.Size = new System.Drawing.Size(748, 206);
@@ -45,12 +51,32 @@
this.modulesListView.UseCompatibleStateImageBehavior = false;
this.modulesListView.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
columnHeader1.Text = "Handle";
//
// columnHeader2
//
columnHeader2.Text = "Type";
columnHeader2.Width = 80;
//
// columnHeader3
//
columnHeader3.Text = "Name";
columnHeader3.Width = 120;
//
// columnHeader4
//
columnHeader4.Text = "Path";
columnHeader4.Width = 300;
//
// ModulesPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(772, 230);
this.Controls.Add(this.modulesListView);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "ModulesPanel";
this.Text = "Modules";
this.ResumeLayout(false);
@@ -60,8 +86,5 @@
#endregion
private System.Windows.Forms.ListView modulesListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
}
}

View File

@@ -19,14 +19,21 @@ namespace Xenia.Debug.UI.Views {
this.debugger = debugger;
debugger.ModuleList.Changed += UpdateModulesList;
UpdateModulesList();
UpdateModulesList(debugger.ModuleList);
}
private void UpdateModulesList() {
private void UpdateModulesList(ModuleList sender) {
modulesListView.BeginUpdate();
modulesListView.Items.Clear();
foreach (Module module in debugger.ModuleList) {
modulesListView.Items.Add("Module A");
var item = new ListViewItem(new string[]{
module.Handle.ToString("X4"),
module.ModuleType == xe.debug.proto.ModuleType.Kernel ? "Kernel"
: "User",
module.Name,
module.Path,
});
modulesListView.Items.Add(item);
}
modulesListView.EndUpdate();
}

View File

@@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="columnHeader1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="columnHeader2.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="columnHeader3.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="columnHeader4.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@@ -19,10 +19,10 @@ namespace Xenia.Debug.UI.Views {
this.debugger = debugger;
debugger.ThreadList.Changed += UpdateThreadList;
UpdateThreadList();
UpdateThreadList(debugger.ThreadList);
}
private void UpdateThreadList() {
private void UpdateThreadList(ThreadList sender) {
threadsListView.BeginUpdate();
threadsListView.Items.Clear();
foreach (Thread thread in debugger.ThreadList) {