// Retrieves a list of the stack frames for this thread. // For the sample engine, enumerating the stack frames requires walking the callstack in the debuggee for this thread // and coverting that to an implementation of IEnumDebugFrameInfo2. // 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. int IDebugThread2.EnumFrameInfo(enum_FRAMEINFO_FLAGS dwFieldSpec, uint nRadix, out IEnumDebugFrameInfo2 enumObject) { // Ask the lower-level to perform a stack walk on this thread m_engine.DebuggedProcess.DoStackWalk(this.m_debuggedThread); enumObject = null; try { System.Collections.Generic.List <X86ThreadContext> stackFrames = this.m_debuggedThread.StackFrames; int numStackFrames = stackFrames.Count; FRAMEINFO[] frameInfoArray; if (numStackFrames == 0) { // failed to walk any frames. Only return the top frame. frameInfoArray = new FRAMEINFO[1]; AD7StackFrame frame = new AD7StackFrame(m_engine, this, GetThreadContext()); frame.SetFrameInfo(dwFieldSpec, out frameInfoArray[0]); } else { frameInfoArray = new FRAMEINFO[numStackFrames]; for (int i = 0; i < numStackFrames; i++) { AD7StackFrame frame = new AD7StackFrame(m_engine, this, stackFrames[i]); frame.SetFrameInfo(dwFieldSpec, out frameInfoArray[i]); } } enumObject = new AD7FrameInfoEnum(frameInfoArray); return(Constants.S_OK); } catch (ComponentException e) { return(e.HResult); } catch (Exception e) { return(EngineUtils.UnexpectedException(e)); } }
// Retrieves a list of the stack frames for this thread. // For the sample engine, enumerating the stack frames requires walking the callstack in the debuggee for this thread // and coverting that to an implementation of IEnumDebugFrameInfo2. // 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. int IDebugThread2.EnumFrameInfo(enum_FRAMEINFO_FLAGS dwFieldSpec, uint nRadix, out IEnumDebugFrameInfo2 enumObject) { // Ask the lower-level to perform a stack walk on this thread m_engine.DebuggedProcess.DoStackWalk(this.m_debuggedThread); enumObject = null; try { System.Collections.Generic.List<X86ThreadContext> stackFrames = this.m_debuggedThread.StackFrames; int numStackFrames = stackFrames.Count; FRAMEINFO[] frameInfoArray; if (numStackFrames == 0) { // failed to walk any frames. Only return the top frame. frameInfoArray = new FRAMEINFO[1]; AD7StackFrame frame = new AD7StackFrame(m_engine, this, GetThreadContext()); frame.SetFrameInfo(dwFieldSpec, out frameInfoArray[0]); } else { frameInfoArray = new FRAMEINFO[numStackFrames]; for (int i = 0; i < numStackFrames; i++) { AD7StackFrame frame = new AD7StackFrame(m_engine, this, stackFrames[i]); frame.SetFrameInfo(dwFieldSpec, out frameInfoArray[i]); } } enumObject = new AD7FrameInfoEnum(frameInfoArray); return Constants.S_OK; } catch (ComponentException e) { return e.HResult; } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }