Faster stepping.

This commit is contained in:
kudzu_cp 2012-08-12 15:29:07 +00:00
parent ad815d3d97
commit 263281a2f0
2 changed files with 41 additions and 28 deletions

View file

@ -25,7 +25,9 @@ namespace Cosmos.Debug.VSDebugEngine {
protected readonly NameValueCollection mDebugInfo; protected readonly NameValueCollection mDebugInfo;
protected LaunchType mLaunch; protected LaunchType mLaunch;
internal DebugInfo mDebugInfoDb; internal DebugInfo mDebugInfoDb;
private int mProcessExitEventSent = 0; protected int mProcessExitEventSent = 0;
// Cached stack frame. See comments in AD7Thread regading this.
public IEnumDebugFrameInfo2 mStackFrame;
// Connection to target environment. Usually serial but is // Connection to target environment. Usually serial but is
// abstracted to allow other transports (ethernet, etc) // abstracted to allow other transports (ethernet, etc)
@ -261,6 +263,7 @@ namespace Cosmos.Debug.VSDebugEngine {
} }
} }
mStackFrame = null;
mCurrentAddress = aAddress; mCurrentAddress = aAddress;
if (xBoundBreakpoints.Count == 0) { if (xBoundBreakpoints.Count == 0) {
// if no matching breakpoints are found then its one of the following: // if no matching breakpoints are found then its one of the following:

View file

@ -9,10 +9,10 @@ using Cosmos.Debug.Common;
namespace Cosmos.Debug.VSDebugEngine { namespace Cosmos.Debug.VSDebugEngine {
// This class implements IDebugThread2 which represents a thread running in a program. // This class implements IDebugThread2 which represents a thread running in a program.
public class AD7Thread : IDebugThread2 { public class AD7Thread : IDebugThread2 {
readonly AD7Engine mEngine; protected readonly AD7Engine mEngine;
protected readonly AD7Process mProcess;
//readonly DebuggedThread m_debuggedThread; //readonly DebuggedThread m_debuggedThread;
const string ThreadNameString = "Cosmos Kernel Main Thread"; const string ThreadNameString = "Cosmos Kernel Main Thread";
protected AD7Process mProcess;
public AD7Thread(AD7Engine aEngine, AD7Process aProcess) { //, DebuggedThread debuggedThread) public AD7Thread(AD7Engine aEngine, AD7Process aProcess) { //, DebuggedThread debuggedThread)
mEngine = aEngine; mEngine = aEngine;
@ -38,35 +38,45 @@ namespace Cosmos.Debug.VSDebugEngine {
// Real engines will most likely want to cache this information to avoid recomputing it each time it is asked for, // Real engines will most likely want to cache this information to avoid recomputing it each time it is asked for,
// and or construct it on demand instead of walking the entire stack. // and or construct it on demand instead of walking the entire stack.
int IDebugThread2.EnumFrameInfo(enum_FRAMEINFO_FLAGS aFieldSpec, uint aRadix, out IEnumDebugFrameInfo2 oEnumObject) { int IDebugThread2.EnumFrameInfo(enum_FRAMEINFO_FLAGS aFieldSpec, uint aRadix, out IEnumDebugFrameInfo2 oEnumObject) {
// Ask the lower-level to perform a stack walk on this thread // Check mStackFrame, not address because it is possible for 2 sequential breaks to be on the same address
//m_engine.DebuggedProcess.DoStackWalk(this.m_debuggedThread); // but in that case we would need a new stack frame.
oEnumObject = null; //
try { // EnumFrameInfo is called several times on each break becuase "different callers can call with different flags".
//System.Collections.Generic.List<X86ThreadContext> stackFrames = this.m_debuggedThread.StackFrames; // We ignore flags through and always return full, but EnumFrameInfo gets called half a dozen times which is slow
//int numStackFrames = stackFrames.Count; // if we refresh each and every time. So we cache our info.
FRAMEINFO[] xFrameInfoArray; if (mProcess.mStackFrame == null) {
// Ask the lower-level to perform a stack walk on this thread
//m_engine.DebuggedProcess.DoStackWalk(this.m_debuggedThread);
oEnumObject = null;
try {
//System.Collections.Generic.List<X86ThreadContext> stackFrames = this.m_debuggedThread.StackFrames;
//int numStackFrames = stackFrames.Count;
FRAMEINFO[] xFrameInfoArray;
//if (numStackFrames == 0) { //if (numStackFrames == 0) {
// failed to walk any frames. Only return the top frame. // failed to walk any frames. Only return the top frame.
xFrameInfoArray = new FRAMEINFO[1];
AD7StackFrame xFrame = new AD7StackFrame(mEngine, this, mProcess);
xFrame.SetFrameInfo((enum_FRAMEINFO_FLAGS)aFieldSpec, out xFrameInfoArray[0]);
//} else {
//frameInfoArray = new FRAMEINFO[numStackFrames];
//for (int i = 0; i < numStackFrames; i++) { xFrameInfoArray = new FRAMEINFO[1];
//AD7StackFrame frame = new AD7StackFrame(m_engine, this, stackFrames[i]); var xFrame = new AD7StackFrame(mEngine, this, mProcess);
//frame.SetFrameInfo(dwFieldSpec, out frameInfoArray[i]); xFrame.SetFrameInfo((enum_FRAMEINFO_FLAGS)aFieldSpec, out xFrameInfoArray[0]);
//}
//}
oEnumObject = new AD7FrameInfoEnum(xFrameInfoArray); //} else {
} catch (Exception e) { //frameInfoArray = new FRAMEINFO[numStackFrames];
//catch (ComponentException e) { //for (int i = 0; i < numStackFrames; i++) {
// return e.HResult; //AD7StackFrame frame = new AD7StackFrame(m_engine, this, stackFrames[i]);
//} //frame.SetFrameInfo(dwFieldSpec, out frameInfoArray[i]);
return EngineUtils.UnexpectedException(e); //}
//}
mProcess.mStackFrame = new AD7FrameInfoEnum(xFrameInfoArray);
} catch (Exception e) {
//catch (ComponentException e) {
// return e.HResult;
//}
return EngineUtils.UnexpectedException(e);
}
} }
oEnumObject = mProcess.mStackFrame;
return VSConstants.S_OK; return VSConstants.S_OK;
} }