mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-13 03:31:22 +00:00
DebugStub ACK functioning.
This commit is contained in:
parent
f7db3e0db1
commit
59450f9e86
5 changed files with 53 additions and 17 deletions
|
|
@ -21,6 +21,9 @@
|
|||
generates warnings about dword being ignored new Push { DestinationReg = GetId()
|
||||
}; } |<br />
|
||||
AL.Push does not work at all.</p>
|
||||
<p>
|
||||
EAX = Memory["lable"] does same as addressof.. you have to specify size... size
|
||||
should be infreered and never use teh value o lable</p>
|
||||
<h3>
|
||||
X#milation would need to be implemented.</li>
|
||||
<li>One of the goals of Cosmos is the need to write very little assembly, so only
|
||||
|
|
|
|||
|
|
@ -9,19 +9,22 @@ using System.Windows.Forms;
|
|||
namespace Cosmos.Debug.Common.CDebugger
|
||||
{
|
||||
public abstract class DebugConnector: IDisposable {
|
||||
//TODO: These should not be this way and should in fact
|
||||
// be checked or better yet done by constructor arguments
|
||||
// but that puts a restriction on where the sub classes
|
||||
// are created.
|
||||
public Action<Exception> ConnectionLost;
|
||||
public Action<MsgType, UInt32> CmdTrace;
|
||||
public Action<string> CmdText;
|
||||
public Action CmdStarted;
|
||||
public Action<string> OnDebugMsg;
|
||||
|
||||
protected MsgType mCurrentMsgType;
|
||||
|
||||
public abstract void WaitConnect();
|
||||
|
||||
protected void DoDebugMsg(string aMsg) {
|
||||
if (OnDebugMsg != null) {
|
||||
OnDebugMsg(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool Connected {
|
||||
get;
|
||||
}
|
||||
|
|
@ -84,6 +87,20 @@ namespace Cosmos.Debug.Common.CDebugger
|
|||
}
|
||||
|
||||
public void SetBreakpoint(int aID, uint aAddress) {
|
||||
// Not needed as SendCommand will do it, but it saves
|
||||
// some execution, but more importantly stops it from
|
||||
// logging messages to debug output for events that
|
||||
// dont happen.
|
||||
if (!Connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAddress == 0) {
|
||||
DoDebugMsg("DS Cmd: BP " + aID + " deleted");
|
||||
} else {
|
||||
DoDebugMsg("DS Cmd: BP " + aID + " @ " + aAddress.ToString("X8").ToUpper());
|
||||
}
|
||||
|
||||
var xData = CreateCommand(Command.BreakOnAddress, 5);
|
||||
Array.Copy(BitConverter.GetBytes(aAddress), 0, xData, CmdSize, 4);
|
||||
xData[CmdSize + 4] = (byte)aID;
|
||||
|
|
@ -148,6 +165,7 @@ namespace Cosmos.Debug.Common.CDebugger
|
|||
|
||||
protected void PacketCmdCompleted(byte[] aPacket) {
|
||||
byte xCmdID = aPacket[0];
|
||||
DoDebugMsg("DS Msg: Cmd " + xCmdID + " Complete");
|
||||
WaitForMessage();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,11 +169,12 @@ namespace Cosmos.Debug.VSDebugEngine {
|
|||
mDbgConnector.CmdTrace += new Action<Cosmos.Compiler.Debug.MsgType, uint>(DbgCmdTrace);
|
||||
mDbgConnector.CmdText += new Action<string>(DbgCmdText);
|
||||
mDbgConnector.CmdStarted += new Action(DbgCmdStarted);
|
||||
mDbgConnector.ConnectionLost = new Action<Exception>(
|
||||
delegate {
|
||||
mEngine.Callback.OnProcessExit(0);
|
||||
}
|
||||
);
|
||||
mDbgConnector.OnDebugMsg += new Action<string>(delegate(string aMsg) {
|
||||
DebugMsg(aMsg);
|
||||
});
|
||||
mDbgConnector.ConnectionLost = new Action<Exception>( delegate {
|
||||
mEngine.Callback.OnProcessExit(0);
|
||||
} );
|
||||
|
||||
System.Threading.Thread.Sleep(250);
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Launching process: \"{0}\" {1}", mProcessStartInfo.FileName, mProcessStartInfo.Arguments).Trim());
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ namespace Cosmos.Debug.VSDebugEngine {
|
|||
for (int xID = 0; xID < MaxBP; xID++) {
|
||||
if (mActiveBPs[xID] == null) {
|
||||
mActiveBPs[xID] = aBBP;
|
||||
mEngine.mProcess.DebugMsg("Remote BP #" + xID + " @ " + aBBP.mAddress.ToString("X8").ToUpper());
|
||||
mDbgConnector.SetBreakpoint(xID, aBBP.mAddress);
|
||||
return xID;
|
||||
}
|
||||
|
|
@ -50,7 +49,6 @@ namespace Cosmos.Debug.VSDebugEngine {
|
|||
}
|
||||
|
||||
public void RemoteDisable(AD7BoundBreakpoint aBBP) {
|
||||
mEngine.mProcess.DebugMsg("Remote BP #" + aBBP.RemoteID + " deleted.");
|
||||
mActiveBPs[aBBP.RemoteID] = null;
|
||||
mDbgConnector.DeleteBreakpoint(aBBP.RemoteID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,8 +385,8 @@ namespace Cosmos.IL2CPU.X86 {
|
|||
|
||||
// Read Command ID
|
||||
Call("ReadALFromComPort");
|
||||
Memory["DebugStub_CommandID"] = AL;
|
||||
|
||||
Memory["DebugStub_CommandID", 32] = EAX;
|
||||
|
||||
// Get AL back so we can compare it, but also put it back for later
|
||||
EAX.Pop();
|
||||
EAX.Push();
|
||||
|
|
@ -394,28 +394,44 @@ namespace Cosmos.IL2CPU.X86 {
|
|||
AL.Compare((byte)Command.TraceOff);
|
||||
JumpIf(Flags.NotEqual, "DebugStub_ProcessCmd_TraceOff_After");
|
||||
Memory["DebugTraceMode", 32] = (int)Tracing.Off;
|
||||
Jump("DebugStub_ProcessCmd_Exit");
|
||||
Jump("DebugStub_ProcessCmd_ACK");
|
||||
Label = "DebugStub_ProcessCmd_TraceOff_After";
|
||||
|
||||
AL.Compare((byte)Command.TraceOn);
|
||||
JumpIf(Flags.NotEqual, "DebugStub_ProcessCmd_TraceOn_After");
|
||||
Memory["DebugTraceMode", 32] = (int)Tracing.On;
|
||||
Jump("DebugStub_ProcessCmd_Exit");
|
||||
Jump("DebugStub_ProcessCmd_ACK");
|
||||
Label = "DebugStub_ProcessCmd_TraceOn_After";
|
||||
|
||||
AL.Compare((byte)Command.Break);
|
||||
JumpIf(Flags.NotEqual, "DebugStub_ProcessCmd_Break_After");
|
||||
Call("DebugStub_Break");
|
||||
Jump("DebugStub_ProcessCmd_Exit");
|
||||
Jump("DebugStub_ProcessCmd_ACK");
|
||||
Label = "DebugStub_ProcessCmd_Break_After";
|
||||
|
||||
AL.Compare((byte)Command.BreakOnAddress);
|
||||
JumpIf(Flags.NotEqual, "DebugStub_ProcessCmd_BreakOnAddress_After");
|
||||
Call("DebugStub_BreakOnAddress");
|
||||
Jump("DebugStub_ProcessCmd_Exit");
|
||||
Jump("DebugStub_ProcessCmd_ACK");
|
||||
Label = "DebugStub_ProcessCmd_BreakOnAddress_After";
|
||||
|
||||
Label = "DebugStub_ProcessCmd_ACK";
|
||||
// We acknowledge receipt of the command, not processing of it.
|
||||
// We have to do this because sometimes callers do more processing
|
||||
// We ACK even ones we dont process here, but do not ACK Noop.
|
||||
// The buffers should be ok becuase more wont be sent till after our NACK
|
||||
// is received.
|
||||
// Right now our max cmd size is 2 + 5 = 7. UART buffer is 16.
|
||||
// We may need to revisit this in the future to ack not commands, but data chunks
|
||||
// and move them to a buffer.
|
||||
AL = (int)MsgType.CmdCompleted;
|
||||
Call("WriteALToComPort");
|
||||
EAX = Memory["DebugStub_CommandID", 32];
|
||||
Call("WriteALToComPort");
|
||||
|
||||
Label = "DebugStub_ProcessCmd_Exit";
|
||||
// Restore AL for callers who check the command and do
|
||||
// further processing, or for commands not handled by this routine.
|
||||
EAX.Pop();
|
||||
Return();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue