mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-22 22:09:12 +00:00
This commit is contained in:
parent
792b43516b
commit
cfb4e0a35f
8 changed files with 98 additions and 47 deletions
|
|
@ -192,12 +192,46 @@ namespace Cosmos.Compiler.DebugStub {
|
|||
public class WriteALToComPort : CodeBlock {
|
||||
// Input: AL
|
||||
// Output: None
|
||||
// Modifies: EAX, EDX, ESI
|
||||
// Modifies: EDX, ESI
|
||||
public override void Assemble() {
|
||||
EAX.Push();
|
||||
ESI = ESP;
|
||||
Call("WriteByteToComPort");
|
||||
EAX.Pop(); // Is a local var, cant use Return(4). X# issues the return.
|
||||
// Is a local var, cant use Return(4). X# issues the return.
|
||||
// This also allow the function to preserve EAX.
|
||||
EAX.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
public class WriteAXToComPort : CodeBlock {
|
||||
// Input: AX
|
||||
// Output: None
|
||||
// Modifies: EDX, ESI
|
||||
public override void Assemble() {
|
||||
EAX.Push();
|
||||
ESI = ESP;
|
||||
Call("WriteByteToComPort");
|
||||
Call("WriteByteToComPort");
|
||||
// Is a local var, cant use Return(4). X# issues the return.
|
||||
// This also allow the function to preserve EAX.
|
||||
EAX.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
public class WriteEAXToComPort : CodeBlock {
|
||||
// Input: EAX
|
||||
// Output: None
|
||||
// Modifies: EDX, ESI
|
||||
public override void Assemble() {
|
||||
EAX.Push();
|
||||
ESI = ESP;
|
||||
Call("WriteByteToComPort");
|
||||
Call("WriteByteToComPort");
|
||||
Call("WriteByteToComPort");
|
||||
Call("WriteByteToComPort");
|
||||
// Is a local var, cant use Return(4). X# issues the return.
|
||||
// This also allow the function to preserve EAX.
|
||||
EAX.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,11 +329,9 @@ namespace Cosmos.Compiler.DebugStub {
|
|||
ESI = Memory["DebugESP", 32];
|
||||
|
||||
// Send number of bytes
|
||||
ESI = Memory["DebugEBP", 32];
|
||||
EAX = Memory["DebugEBP", 32];
|
||||
EAX.Sub(ESI);
|
||||
Call<DebugStub.WriteALToComPort>();
|
||||
EAX.RotateRight(8); // Should be ShiftRight, but its no in X# ops yet
|
||||
Call<DebugStub.WriteALToComPort>();
|
||||
Call<DebugStub.WriteAXToComPort>();
|
||||
|
||||
Label = "DebugStub_SendStack_SendByte";
|
||||
ESI.Compare(Memory["DebugEBP", 32]);
|
||||
|
|
|
|||
|
|
@ -291,8 +291,9 @@ namespace Cosmos.Debug.Common
|
|||
|
||||
case DsMsgType.Stack:
|
||||
DoDebugMsg("DC Recv: Stack");
|
||||
Next(128, PacketStack);
|
||||
Next(-1, PacketStack);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Exceptions crash VS.
|
||||
MessageBox.Show("Unknown debug command");
|
||||
|
|
@ -368,7 +369,7 @@ namespace Cosmos.Debug.Common
|
|||
|
||||
protected void PacketStack(byte[] aPacket)
|
||||
{
|
||||
mData = aPacket.ToArray();
|
||||
mData = aPacket;
|
||||
if (CmdStack != null)
|
||||
{
|
||||
CmdStack(mData);
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ using System.Threading;
|
|||
|
||||
namespace Cosmos.Debug.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for Vmware.
|
||||
/// </summary>
|
||||
/// Used for Vmware. VMWare uses a pipe to expose guest serial ports to the host.
|
||||
public class DebugConnectorPipeServer : DebugConnectorStream {
|
||||
|
||||
public DebugConnectorPipeServer() {
|
||||
|
|
|
|||
|
|
@ -58,14 +58,26 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
|
||||
protected Action<byte[]> mCompleted; // Action to call after size received
|
||||
protected void SizePacket(byte[] aPacket) {
|
||||
int xSize = aPacket[0] + aPacket[1] << 8;
|
||||
Next(xSize, mCompleted);
|
||||
}
|
||||
|
||||
protected override void Next(int aPacketSize, Action<byte[]> aCompleted) {
|
||||
var xIncoming = new Incoming() {
|
||||
Packet = new byte[aPacketSize]
|
||||
, Stream = mStream
|
||||
, Completed = aCompleted
|
||||
};
|
||||
mStream.BeginRead(xIncoming.Packet, 0, aPacketSize, new AsyncCallback(DoRead), xIncoming);
|
||||
var xIncoming = new Incoming();
|
||||
if (aPacketSize == -1) {
|
||||
// Variable size packet, split into two reads
|
||||
mCompleted = aCompleted;
|
||||
aPacketSize = 2;
|
||||
xIncoming.Completed = SizePacket;
|
||||
} else {
|
||||
xIncoming.Completed = aCompleted;
|
||||
}
|
||||
xIncoming.Packet = new byte[aPacketSize];
|
||||
xIncoming.Stream = mStream;
|
||||
mStream.BeginRead(xIncoming.Packet, 0, aPacketSize, new AsyncCallback(DoRead), xIncoming);
|
||||
}
|
||||
|
||||
protected void DoRead(IAsyncResult aResult) {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,13 @@
|
|||
<h3>
|
||||
Debugging via Hive</h3>
|
||||
<p>
|
||||
Program: /RootSuffix Exp "M:\source\Cosmos\source\Cosmos.sln"</p>
|
||||
<p>
|
||||
Parameters: /RootSuffix Exp "M:\source\Cosmos\source\Cosmos.sln"</p>
|
||||
Program: C:\Program Files (x86)\Microsoft Visual Studio
|
||||
10.0\Common7\IDE\devenv.exe</p>
|
||||
<p>
|
||||
Parameters: /RootSuffix Exp "<a
|
||||
href="file:///M:/source/Cosmos/source/Cosmos.sln">M:\source\Cosmos\source\Cosmos.sln</a>"</p>
|
||||
<p>
|
||||
Can also debug non hive, but some exceptions are not masked.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -56,13 +56,18 @@ namespace Cosmos.Cosmos_VS_Windows
|
|||
{
|
||||
mCommand = new Queue<byte>();
|
||||
mMessage = new Queue<byte[]>();
|
||||
|
||||
// There are a lot of threading issues in VSIP, and the WPF dispatchers do not work
|
||||
// So instead we use a stack and a timer to poll it for data.
|
||||
System.Timers.Timer xTimer = new System.Timers.Timer(250);
|
||||
xTimer.AutoReset = true;
|
||||
xTimer.Elapsed += new System.Timers.ElapsedEventHandler(ProcessMessage);
|
||||
xTimer.Start();
|
||||
|
||||
PipeThread.DataPacketReceived += new Action<byte, byte[]>(PipeThread_DataPacketReceived);
|
||||
var xServerThread = new Thread(PipeThread.ThreadStartServer);
|
||||
xServerThread.Start();
|
||||
|
||||
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
Name="CosmosStackUserControl"
|
||||
Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}">
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<TextBox Name="tboxSourceFrame" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="300" Width="150" />
|
||||
<TextBox Name="tboxSourceStack" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="150" Height="300" />
|
||||
</WrapPanel>
|
||||
<DockPanel>
|
||||
<TextBox DockPanel.Dock="Left" Name="tboxSourceFrame" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" Width="160" Text="[EBP + 124] 0x12345678" />
|
||||
<TextBox Name="tboxSourceStack" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" Text="0x12345678" />
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ using System.Windows.Shapes;
|
|||
|
||||
namespace Cosmos.Cosmos_VS_Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for StackUC.xaml
|
||||
/// </summary>
|
||||
public partial class StackUC : UserControl
|
||||
{
|
||||
public StackUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
tboxSourceFrame.Text = "";
|
||||
tboxSourceStack.Text = "";
|
||||
}
|
||||
|
||||
public void UpdateFrame(byte[] aData)
|
||||
|
|
@ -30,34 +30,33 @@ namespace Cosmos.Cosmos_VS_Windows
|
|||
string xData = BitConverter.ToString(aData);
|
||||
xData = xData.Trim();
|
||||
xData = xData.Replace("-", "");
|
||||
if (xData.Length == 256)
|
||||
{
|
||||
for (int i = 0; i < 256; i += 8)
|
||||
{
|
||||
string xTemp = xData.Substring(i, 8);
|
||||
tboxSourceFrame.Text += ("EBP + " + xOffset.ToString() + " : " + xTemp + "\n");
|
||||
xOffset += 4;
|
||||
}
|
||||
if (xData.Length == 256) {
|
||||
for (int i = 0; i < 256; i += 8) {
|
||||
string xTemp = xData.Substring(i, 8);
|
||||
tboxSourceFrame.Text += ("[EBP + " + xOffset + "] " + xTemp + "\n");
|
||||
xOffset += 4;
|
||||
}
|
||||
} else {
|
||||
tboxSourceFrame.Text = "Error loading the frame.";
|
||||
}
|
||||
else tboxSourceFrame.Text = "Error loading the frame.";
|
||||
}
|
||||
|
||||
public void UpdateStack(byte[] aData)
|
||||
{
|
||||
int xOffset = -124;
|
||||
string xData = BitConverter.ToString(aData);
|
||||
xData = xData.Trim();
|
||||
xData = xData.Replace("-", "");
|
||||
if (xData.Length == 256)
|
||||
{
|
||||
for (int i = 0; i < 256; i += 8)
|
||||
{
|
||||
string xTemp = xData.Substring(i, 8);
|
||||
tboxSourceStack.Text += ("EBP + " + xOffset.ToString() + " : " + xTemp + "\n");
|
||||
xOffset += 4;
|
||||
}
|
||||
|
||||
if (xData.Length == 256) {
|
||||
var xSB = new StringBuilder();
|
||||
xSB.AppendLine("Stack Contents");
|
||||
for (int i = 0; i < 256; i += 8) {
|
||||
xSB.AppendLine("0x" + xData.Substring(i, 8));
|
||||
}
|
||||
tboxSourceStack.Text = xSB.ToString();
|
||||
} else {
|
||||
tboxSourceStack.Text = "Error loading the stack.";
|
||||
}
|
||||
else tboxSourceStack.Text = "Error loading the stack.";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue