public AD7StackFrame(AD7Engine engine, AD7Thread thread, X86ThreadContext threadContext) { m_engine = engine; m_thread = thread; m_threadContext = threadContext; // Try to get source information for this location. If symbols for this file have not been found, this will fail. m_hasSource = m_engine.DebuggedProcess.GetSourceInformation( m_threadContext.eip, ref m_documentName, ref m_functionName, ref m_lineNum, ref m_numParameters, ref m_numLocals); // If source information is available, create the collections of locals and parameters and populate them with // values from the debuggee. if (m_hasSource) { if (m_numParameters > 0) { m_parameters = new VariableInformation[m_numParameters]; m_engine.DebuggedProcess.GetFunctionArgumentsByIP(m_threadContext.eip, m_threadContext.ebp, m_parameters); } if (m_numLocals > 0) { m_locals = new VariableInformation[m_numLocals]; m_engine.DebuggedProcess.GetFunctionLocalsByIP(m_threadContext.eip, m_threadContext.ebp, m_locals); } } }
public void OnLoadComplete(DebuggedThread thread) { AD7Thread ad7Thread = (AD7Thread)thread.Client; AD7LoadCompleteEvent eventObject = new AD7LoadCompleteEvent(); Send(eventObject, AD7LoadCompleteEvent.IID, ad7Thread); }
public void OnAsyncBreakComplete(DebuggedThread thread) { // This will get called when the engine receives the breakpoint event that is created when the user // hits the pause button in vs. Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); AD7Thread ad7Thread = (AD7Thread)thread.Client; AD7AsyncBreakCompleteEvent eventObject = new AD7AsyncBreakCompleteEvent(); Send(eventObject, AD7AsyncBreakCompleteEvent.IID, ad7Thread); }
public void OnThreadExit(DebuggedThread debuggedThread, uint exitCode) { Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); AD7Thread ad7Thread = (AD7Thread)debuggedThread.Client; Debug.Assert(ad7Thread != null); AD7ThreadDestroyEvent eventObject = new AD7ThreadDestroyEvent(exitCode); Send(eventObject, AD7ThreadDestroyEvent.IID, ad7Thread); }
// Only for NPL stepping public void OnStepComplete(DebuggedThread debuggedThread) { Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); AD7Thread ad7Thread = (AD7Thread)debuggedThread.Client; Debug.Assert(ad7Thread != null); AD7StepCompleteEvent eventObject = new AD7StepCompleteEvent(); Send(eventObject, AD7StepCompleteEvent.IID, ad7Thread); }
// ExecuteOnThread is called when the SDM wants execution to continue and have // stepping state cleared. public int ExecuteOnThread(IDebugThread2 pThread) { Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); AD7Thread thread = (AD7Thread)pThread; m_pollThread.RunOperation(new Operation(delegate { m_debuggedProcess.Execute(thread.GetDebuggedThread()); })); return(Constants.S_OK); }
// This method is deprecated. Use the IDebugProcess3::Step method instead. public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step) { Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); AD7Thread thread = (AD7Thread)pThread; // RunOperationAsync m_pollThread.RunOperation(new Operation(delegate { m_debuggedProcess.Step(thread.GetDebuggedThread(), (int)sk, (int)Step); })); return(Constants.S_OK); }
public void OnThreadStart(DebuggedThread debuggedThread) { // This will get called when the entrypoint breakpoint is fired because the engine sends a thread start event // for the main thread of the application. if (m_engine.DebuggedProcess != null) { Debug.Assert(Worker.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId); } AD7Thread ad7Thread = new AD7Thread(m_engine, debuggedThread); debuggedThread.Client = ad7Thread; AD7ThreadCreateEvent eventObject = new AD7ThreadCreateEvent(); Send(eventObject, AD7ThreadCreateEvent.IID, ad7Thread); }
// EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); DebuggedThread[] threads = m_debuggedProcess.GetThreads(); AD7Thread[] threadObjects = new AD7Thread[threads.Length]; for (int i = 0; i < threads.Length; i++) { Debug.Assert(threads[i].Client != null); threadObjects[i] = (AD7Thread)threads[i].Client; } ppEnum = new Microsoft.VisualStudio.Debugger.SampleEngine.AD7ThreadEnum(threadObjects); return(Constants.S_OK); }
public void OnBreakpoint(DebuggedThread thread, ReadOnlyCollection <object> clients, uint address) { IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[clients.Count]; int i = 0; foreach (object objCurrentBreakpoint in clients) { boundBreakpoints[i] = (IDebugBoundBreakpoint2)objCurrentBreakpoint; i++; } // An engine that supports more advanced breakpoint features such as hit counts, conditions and filters // should notify each bound breakpoint that it has been hit and evaluate conditions here. // The sample engine does not support these features. AD7BoundBreakpointsEnum boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints); AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpointsEnum); AD7Thread ad7Thread = (AD7Thread)thread.Client; Send(eventObject, AD7BreakpointEvent.IID, ad7Thread); }
// EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); DebuggedThread[] threads = m_debuggedProcess.GetThreads(); AD7Thread[] threadObjects = new AD7Thread[threads.Length]; for (int i = 0; i < threads.Length; i++) { Debug.Assert(threads[i].Client != null); threadObjects[i] = (AD7Thread)threads[i].Client; } ppEnum = new Microsoft.VisualStudio.Debugger.SampleEngine.AD7ThreadEnum(threadObjects); return Constants.S_OK; }