Asm stepping

This commit is contained in:
kudzu_cp 2012-07-29 17:22:15 +00:00
parent 6a11a87aee
commit 8e6d7e893e
2 changed files with 51 additions and 46 deletions

View file

@ -10,7 +10,8 @@ using System.Windows.Forms;
namespace Cosmos.Debug.Common {
public abstract class DebugConnector : IDisposable {
public Action<Exception> ConnectionLost;
public Action<byte, UInt32> CmdTrace;
public Action<UInt32> CmdTrace;
public Action<UInt32> CmdBreak;
public Action<byte[]> CmdMethodContext;
public Action<string> CmdText;
public Action CmdStarted;
@ -255,11 +256,15 @@ namespace Cosmos.Debug.Common {
// Could change to an array, but really not much benefit
switch (mCurrentMsgType) {
case Ds2Vs.TracePoint:
case Ds2Vs.BreakPoint:
DoDebugMsg("DC Recv: TracePoint / BreakPoint");
DoDebugMsg("DC Recv: TracePoint");
Next(4, PacketTracePoint);
break;
case Ds2Vs.BreakPoint:
DoDebugMsg("DC Recv: BreakPoint");
Next(4, PacketBreakPoint);
break;
case Ds2Vs.Message:
DoDebugMsg("DC Recv: Message");
Next(2, PacketTextSize);
@ -432,7 +437,12 @@ namespace Cosmos.Debug.Common {
// WaitForMessage must be first. CmdTrace issues
// more commands and if we dont issue this, the pipe wont be waiting for a response.
WaitForMessage();
CmdTrace(mCurrentMsgType, GetUInt32(aPacket, 0));
CmdTrace(GetUInt32(aPacket, 0));
}
protected void PacketBreakPoint(byte[] aPacket) {
WaitForMessage();
CmdBreak(GetUInt32(aPacket, 0));
}
protected void PacketText(byte[] aPacket) {

View file

@ -116,7 +116,8 @@ namespace Cosmos.Debug.VSDebugEngine {
throw new Exception("No debug connector found.");
}
mDbgConnector.Connected = DebugConnectorConnected;
mDbgConnector.CmdTrace += new Action<byte, uint>(DbgCmdTrace);
mDbgConnector.CmdBreak += new Action<UInt32>(DbgCmdBreak);
mDbgConnector.CmdTrace += new Action<UInt32>(DbgCmdTrace);
mDbgConnector.CmdText += new Action<string>(DbgCmdText);
mDbgConnector.CmdStarted += new Action(DbgCmdStarted);
mDbgConnector.OnDebugMsg += new Action<string>(DebugMsg);
@ -253,52 +254,46 @@ namespace Cosmos.Debug.VSDebugEngine {
}
}
void DbgCmdTrace(byte arg1, uint arg2) {
DebugMsg("DbgCmdTrace");
switch (arg1) {
case Ds2Vs.BreakPoint: {
// When doing a CALL, the return address is pushed, but that's the address of the next instruction, after CALL. call is 5 bytes (for now?)
// Dont need to correct the address, becuase DebugStub does it for us.
var xActualAddress = arg2;
DebugMsg("BP hit @ " + xActualAddress.ToString("X8").ToUpper());
void DbgCmdTrace(UInt32 aAddress) {
DebugMsg("TraceReceived: " + aAddress);
}
var xActionPoints = new List<object>();
var xBoundBreakpoints = new List<IDebugBoundBreakpoint2>();
void DbgCmdBreak(UInt32 aAddress) {
DebugMsg("DbgCmdBreak " + aAddress);
// Search the BPs and find the ones that match our address
foreach (var xBP in mEngine.BPMgr.mPendingBPs) {
foreach (var xBBP in xBP.mBoundBPs) {
if (xBBP.mAddress == xActualAddress) {
xBoundBreakpoints.Add(xBBP);
}
}
}
// When doing a CALL, the return address is pushed, but that's the address of the next instruction, after CALL. call is 5 bytes (for now?)
// Dont need to correct the address, becuase DebugStub does it for us.
DebugMsg("BP hit @ " + aAddress.ToString("X8").ToUpper());
mCurrentAddress = xActualAddress;
// if no matching breakpoint, its either a stepping operation, or a code based break
if (xBoundBreakpoints.Count == 0) {
// Is it a result of stepping operation?
if (mEngine.AfterBreak) {
RequestFullDebugStubUpdate();
mCallback.OnStepComplete();
} else {
RequestFullDebugStubUpdate();
// Code based break. Tell VS to break.
mCallback.OnBreakpoint(mThread, new ReadOnlyCollection<IDebugBoundBreakpoint2>(xBoundBreakpoints));
}
} else {
// Found a bound breakpoint
RequestFullDebugStubUpdate();
mCallback.OnBreakpoint(mThread, new ReadOnlyCollection<IDebugBoundBreakpoint2>(xBoundBreakpoints));
mEngine.AfterBreak = true;
}
break;
var xActionPoints = new List<object>();
var xBoundBreakpoints = new List<IDebugBoundBreakpoint2>();
// Search the BPs and find the ones that match our address
foreach (var xBP in mEngine.BPMgr.mPendingBPs) {
foreach (var xBBP in xBP.mBoundBPs) {
if (xBBP.mAddress == aAddress) {
xBoundBreakpoints.Add(xBBP);
}
}
}
default: {
DebugMsg("TraceReceived: " + arg1);
break;
}
mCurrentAddress = aAddress;
// if no matching breakpoint, its either a stepping operation, or a code based break
if (xBoundBreakpoints.Count == 0) {
// Is it a result of stepping operation?
if (mEngine.AfterBreak) {
RequestFullDebugStubUpdate();
mCallback.OnStepComplete();
} else {
RequestFullDebugStubUpdate();
// Code based break. Tell VS to break.
mCallback.OnBreakpoint(mThread, new ReadOnlyCollection<IDebugBoundBreakpoint2>(xBoundBreakpoints));
}
} else {
// Found a bound breakpoint
RequestFullDebugStubUpdate();
mCallback.OnBreakpoint(mThread, new ReadOnlyCollection<IDebugBoundBreakpoint2>(xBoundBreakpoints));
mEngine.AfterBreak = true;
}
}