Cosmos/source2/Debug/Cosmos.Debug.GDB/FormCallStack.cs
kudzu_cp 7951702138
2010-07-12 15:02:13 +00:00

67 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Cosmos.Debug.GDB {
public partial class FormCallStack : Form {
protected class CallStack {
public readonly UInt32 Address;
public readonly string Label;
public CallStack(string aInput) {
var xSplit = aInput.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
Address = Global.FromHex(xSplit[1]);
Label = xSplit[3];
}
public override string ToString() {
if (Label.Length > 0) {
return Label;
}
return Address.ToString("X8");
}
}
public FormCallStack() {
InitializeComponent();
}
public void Update() {
var xResult = GDB.SendCmd("where");
lboxCallStack.BeginUpdate();
try {
lboxCallStack.Items.Clear();
foreach (var x in xResult) {
//#0 0x0056d5df in DebugStub_Start ()
//#1 0x0057572b in System_Void__Cosmos_User_Kernel_Program_Init____DOT__00000001 ()
//#2 0x00550018 in Before_Kernel_Stack ()
//#3 0x005a5427 in __ENGINE_ENTRYPOINT__ ()
//~Backtrace stopped: frame did not save the PC
if (x.StartsWith("#")) {
lboxCallStack.Items.Add(new CallStack(x));
}
}
} finally {
lboxCallStack.EndUpdate();
}
}
private void menuCallStackGoto_Click(object sender, EventArgs e) {
var x = (CallStack)lboxCallStack.SelectedItem;
if (x != null) {
Windows.mMainForm.ResetRegisters();
// Address doesn't work for some reason
Windows.mMainForm.Disassemble(x.Label);
}
}
private void lboxCallStack_DoubleClick(object sender, EventArgs e) {
menuCallStackGoto.PerformClick();
}
}
}