diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/DebugStub.cs b/source2/Compiler/Cosmos.Compiler.DebugStub/DebugStub.cs
index a7584024b..22c676e89 100644
--- a/source2/Compiler/Cosmos.Compiler.DebugStub/DebugStub.cs
+++ b/source2/Compiler/Cosmos.Compiler.DebugStub/DebugStub.cs
@@ -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();
- EAX.RotateRight(8); // Should be ShiftRight, but its no in X# ops yet
- Call();
+ Call();
Label = "DebugStub_SendStack_SendByte";
ESI.Compare(Memory["DebugEBP", 32]);
diff --git a/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs b/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs
index 00810f7c4..538d11974 100644
--- a/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs
+++ b/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs
@@ -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);
diff --git a/source2/Debug/Cosmos.Debug.Common/DebugConnectorPipeServer.cs b/source2/Debug/Cosmos.Debug.Common/DebugConnectorPipeServer.cs
index 3a6e1834d..465e2e28d 100644
--- a/source2/Debug/Cosmos.Debug.Common/DebugConnectorPipeServer.cs
+++ b/source2/Debug/Cosmos.Debug.Common/DebugConnectorPipeServer.cs
@@ -8,9 +8,7 @@ using System.Threading;
namespace Cosmos.Debug.Common
{
- ///
- /// Used for Vmware.
- ///
+ /// Used for Vmware. VMWare uses a pipe to expose guest serial ports to the host.
public class DebugConnectorPipeServer : DebugConnectorStream {
public DebugConnectorPipeServer() {
diff --git a/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs b/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs
index 0e3b11a21..bbb855dde 100644
--- a/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs
+++ b/source2/Debug/Cosmos.Debug.Common/DebugConnectorStream.cs
@@ -58,14 +58,26 @@ namespace Cosmos.Debug.Common {
}
base.Dispose();
}
-
+
+ protected Action 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 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) {
diff --git a/source2/Debug/Cosmos.Debug.VSDebugEngine/ReadMe.html b/source2/Debug/Cosmos.Debug.VSDebugEngine/ReadMe.html
index 608708d2f..1fcb7767b 100644
--- a/source2/Debug/Cosmos.Debug.VSDebugEngine/ReadMe.html
+++ b/source2/Debug/Cosmos.Debug.VSDebugEngine/ReadMe.html
@@ -16,9 +16,13 @@
Debugging via Hive
- Program: /RootSuffix Exp "M:\source\Cosmos\source\Cosmos.sln"
-
- Parameters: /RootSuffix Exp "M:\source\Cosmos\source\Cosmos.sln"
+ Program: C:\Program Files (x86)\Microsoft Visual Studio
+ 10.0\Common7\IDE\devenv.exe
+
+ Parameters: /RootSuffix Exp "M:\source\Cosmos\source\Cosmos.sln"
+
+ Can also debug non hive, but some exceptions are not masked.