From 8e6d7e893e7d078b5615dea5043d8262f7580de2 Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Sun, 29 Jul 2012 17:22:15 +0000 Subject: [PATCH] Asm stepping --- .../Cosmos.Debug.Common/DebugConnector.cs | 18 ++++- .../AD7.Impl/AD7Process.cs | 79 +++++++++---------- 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs b/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs index d7f097b84..83b82db81 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs +++ b/source2/Debug/Cosmos.Debug.Common/DebugConnector.cs @@ -10,7 +10,8 @@ using System.Windows.Forms; namespace Cosmos.Debug.Common { public abstract class DebugConnector : IDisposable { public Action ConnectionLost; - public Action CmdTrace; + public Action CmdTrace; + public Action CmdBreak; public Action CmdMethodContext; public Action 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) { diff --git a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs index 9412d8885..23f3be6fa 100644 --- a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs +++ b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs @@ -116,7 +116,8 @@ namespace Cosmos.Debug.VSDebugEngine { throw new Exception("No debug connector found."); } mDbgConnector.Connected = DebugConnectorConnected; - mDbgConnector.CmdTrace += new Action(DbgCmdTrace); + mDbgConnector.CmdBreak += new Action(DbgCmdBreak); + mDbgConnector.CmdTrace += new Action(DbgCmdTrace); mDbgConnector.CmdText += new Action(DbgCmdText); mDbgConnector.CmdStarted += new Action(DbgCmdStarted); mDbgConnector.OnDebugMsg += new Action(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(); - var xBoundBreakpoints = new List(); + 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(xBoundBreakpoints)); - } - } else { - // Found a bound breakpoint - RequestFullDebugStubUpdate(); - mCallback.OnBreakpoint(mThread, new ReadOnlyCollection(xBoundBreakpoints)); - mEngine.AfterBreak = true; - } - break; + var xActionPoints = new List(); + var xBoundBreakpoints = new List(); + + // 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(xBoundBreakpoints)); + } + } else { + // Found a bound breakpoint + RequestFullDebugStubUpdate(); + mCallback.OnBreakpoint(mThread, new ReadOnlyCollection(xBoundBreakpoints)); + mEngine.AfterBreak = true; } }