diff --git a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Engine.cs b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Engine.cs index 39563ef54..632aaec78 100644 --- a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Engine.cs +++ b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Engine.cs @@ -13,7 +13,7 @@ using System.Collections.Specialized; using System.Windows.Forms; namespace Cosmos.Debug.VSDebugEngine { - // AD7Engine is the primary entrypoint object for the sample engine. + // AD7Engine is the primary entrypoint object for the the debugger. // // It implements: // @@ -56,8 +56,6 @@ namespace Cosmos.Debug.VSDebugEngine { // Attach the debug engine to a program. int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); if (celtPrograms != 1) { System.Diagnostics.Debug.Fail("SampleEngine only expects to see one program in a process"); throw new ArgumentException(); @@ -135,8 +133,6 @@ namespace Cosmos.Debug.VSDebugEngine { // This is normally called in response to the user clicking on the pause button in the debugger. // When the break is complete, an AsyncBreakComplete event will be sent back to the debugger. int IDebugEngine2.CauseBreak() { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); return ((IDebugProgram2)this).CauseBreak(); } @@ -144,9 +140,6 @@ namespace Cosmos.Debug.VSDebugEngine { // was received and processed. The only event the sample engine sends in this fashion is Program Destroy. // It responds to that event by shutting down the engine. int IDebugEngine2.ContinueFromSynchronousEvent(IDebugEvent2 eventObject) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); - try { if (eventObject is AD7ProgramDestroyEvent) { //DebuggedProcess debuggedProcess = m_debuggedProcess; @@ -170,8 +163,6 @@ namespace Cosmos.Debug.VSDebugEngine { // Creates a pending breakpoint in the engine. A pending breakpoint is contains all the information needed to bind a breakpoint to // a location in the debuggee. int IDebugEngine2.CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - System.Diagnostics.Debug.Assert(BPMgr != null); ppPendingBP = null; try { @@ -186,61 +177,20 @@ namespace Cosmos.Debug.VSDebugEngine { // Informs a DE that the program specified has been atypically terminated and that the DE should // clean up all references to the program and send a program destroy event. int IDebugEngine2.DestroyProgram(IDebugProgram2 pProgram) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); // Tell the SDM that the engine knows that the program is exiting, and that the // engine will send a program destroy. We do this because the Win32 debug api will always // tell us that the process exited, and otherwise we have a race condition. - - return (AD7_HRESULT.E_PROGRAM_DESTROY_PENDING); + return AD7_HRESULT.E_PROGRAM_DESTROY_PENDING; } // Gets the GUID of the DE. int IDebugEngine2.GetEngineId(out Guid guidEngine) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); guidEngine = new Guid(ID); return VSConstants.S_OK; } - // Removes the list of exceptions the IDE has set for a particular run-time architecture or language. - // The sample engine does not support exceptions in the debuggee so this method is not actually implemented. - int IDebugEngine2.RemoveAllSetExceptions(ref Guid guidType) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - - return VSConstants.S_OK; - } - - // Removes the specified exception so it is no longer handled by the debug engine. - // The sample engine does not support exceptions in the debuggee so this method is not actually implemented. - int IDebugEngine2.RemoveSetException(EXCEPTION_INFO[] pException) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - // The sample engine will always stop on all exceptions. - - return VSConstants.S_OK; - } - - // Specifies how the DE should handle a given exception. - // The sample engine does not support exceptions in the debuggee so this method is not actually implemented. - int IDebugEngine2.SetException(EXCEPTION_INFO[] pException) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - return VSConstants.S_OK; - } - - // Sets the locale of the DE. - // This method is called by the session debug manager (SDM) to propagate the locale settings of the IDE so that - // strings returned by the DE are properly localized. The sample engine is not localized so this is not implemented. - int IDebugEngine2.SetLocale(ushort wLangID) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - return VSConstants.S_OK; - } - // Determines if a process can be terminated. int IDebugEngineLaunch2.CanTerminateProcess(IDebugProcess2 process) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); - //System.Diagnostics.Debug.Assert(m_pollThread != null); - //System.Diagnostics.Debug.Assert(mEngineCallback != null); - //System.Diagnostics.Debug.Assert(m_debuggedProcess != null); - try { int processId = EngineUtils.GetProcessId(process); @@ -269,13 +219,6 @@ namespace Cosmos.Debug.VSDebugEngine { // in which case Visual Studio uses the IDebugEngineLaunch2::LaunchSuspended method // The IDebugEngineLaunch2::ResumeProcess method is called to start the process after the process has been successfully launched in a suspended state. int IDebugEngineLaunch2.LaunchSuspended(string aPszServer, IDebugPort2 aPort, string aDebugInfo, string aArgs, string aDir, string aEnv, string aOptions, enum_LAUNCH_FLAGS aLaunchFlags, uint aStdInputHandle, uint aStdOutputHandle, uint hStdError, IDebugEventCallback2 aAD7Callback, out IDebugProcess2 aProcess) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); - //System.Diagnostics.Debug.Assert(m_pollThread == null); - //System.Diagnostics.Debug.Assert(mEngineCallback == null); - //System.Diagnostics.Debug.Assert(m_debuggedProcess == null); - //System.Diagnostics.Debug.Assert(m_ad7ProgramId == Guid.Empty); - aProcess = null; try { mEngineCallback = new EngineCallback(this, aAD7Callback); @@ -349,13 +292,6 @@ namespace Cosmos.Debug.VSDebugEngine { // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 aProcess) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); - //System.Diagnostics.Debug.Assert(m_pollThread != null); - //System.Diagnostics.Debug.Assert(mEngineCallback != null); - //System.Diagnostics.Debug.Assert(m_debuggedProcess != null); - //System.Diagnostics.Debug.Assert(m_ad7ProgramId == Guid.Empty); - try { int processId = EngineUtils.GetProcessId(aProcess); @@ -401,7 +337,6 @@ namespace Cosmos.Debug.VSDebugEngine { // This function is used to terminate a process that the SampleEngine launched // The debugger will call IDebugEngineLaunch2::CanTerminateProcess before calling this method. int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 aProcess) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); //System.Diagnostics.Debug.Assert(m_pollThread != null); //System.Diagnostics.Debug.Assert(mEngineCallback != null); @@ -432,7 +367,6 @@ namespace Cosmos.Debug.VSDebugEngine { // but have stepping state remain. An example is when a tracepoint is executed, // and the debugger does not want to actually enter break mode. public int Continue(IDebugThread2 pThread) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); AD7Thread thread = (AD7Thread)pThread; @@ -454,7 +388,6 @@ namespace Cosmos.Debug.VSDebugEngine { // Detach is called when debugging is stopped and the process was attached to (as opposed to launched) // or when one of the Detach commands are executed in the UI. public int Detach() { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); BPMgr.ClearBoundBreakpoints(); @@ -469,7 +402,6 @@ namespace Cosmos.Debug.VSDebugEngine { // EnumModules is called by the debugger when it needs to enumerate the modules in the program. public int EnumModules(out IEnumDebugModules2 ppEnum) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); ppEnum = new AD7ModuleEnum(new[] { mModule }); @@ -479,7 +411,6 @@ namespace Cosmos.Debug.VSDebugEngine { // EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); //DebuggedThread[] threads = m_debuggedProcess.GetThreads(); @@ -496,18 +427,8 @@ namespace Cosmos.Debug.VSDebugEngine { return VSConstants.S_OK; } - // This method gets the Edit and Continue (ENC) update for this program. A custom debug engine always returns E_NOTIMPL - public int GetENCUpdate(out object update) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - // The sample engine does not participate in managed edit & continue. - update = null; - - return VSConstants.S_OK; - } - // Gets the name and identifier of the debug engine (DE) running this program. public int GetEngineInfo(out string engineName, out Guid engineGuid) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); engineName = ResourceStrings.EngineName; engineGuid = new Guid(AD7Engine.ID); @@ -517,7 +438,6 @@ namespace Cosmos.Debug.VSDebugEngine { // Gets the name of the program. // The name returned by this method is always a friendly, user-displayable name that describes the program. public int GetName(out string programName) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); // The Sample engine uses default transport and doesn't need to customize the name of the program, // so return NULL. programName = null; @@ -528,26 +448,20 @@ namespace Cosmos.Debug.VSDebugEngine { // Gets a GUID for this program. A debug engine (DE) must return the program identifier originally passed to the IDebugProgramNodeAttach2::OnAttach // or IDebugEngine2::Attach methods. This allows identification of the program across debugger components. public int GetProgramId(out Guid guidProgramId) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); //System.Diagnostics.Debug.Assert(m_ad7ProgramId != Guid.Empty); - guidProgramId = m_ad7ProgramId; - return VSConstants.S_OK; } // This method is deprecated. Use the IDebugProcess3::Step method instead. public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); mProcess.Step((enum_STEPKIND)sk); - return VSConstants.S_OK; } // ExecuteOnThread is called when the SDM wants execution to continue and have // stepping state cleared. public int ExecuteOnThread(IDebugThread2 pThread) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); mProcess.Continue(); //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); @@ -561,6 +475,39 @@ namespace Cosmos.Debug.VSDebugEngine { #region Unimplemented methods + // This method gets the Edit and Continue (ENC) update for this program. A custom debug engine always returns E_NOTIMPL + public int GetENCUpdate(out object update) { + // The sample engine does not participate in managed edit & continue. + update = null; + + return VSConstants.S_OK; + } + + // Removes the list of exceptions the IDE has set for a particular run-time architecture or language. + // We dont support exceptions in the debuggee so this method is not actually implemented. + int IDebugEngine2.RemoveAllSetExceptions(ref Guid guidType) { + return VSConstants.S_OK; + } + + // Removes the specified exception so it is no longer handled by the debug engine. + // The sample engine does not support exceptions in the debuggee so this method is not actually implemented. + int IDebugEngine2.RemoveSetException(EXCEPTION_INFO[] pException) { + // We stop on all exceptions. + return VSConstants.S_OK; + } + + // Specifies how the DE should handle a given exception. + // We dont support exceptions in the debuggee so this method is not actually implemented. + int IDebugEngine2.SetException(EXCEPTION_INFO[] pException) { + return VSConstants.S_OK; + } + + // Sets the locale of the DE. + // This method is called by the session debug manager (SDM) to propagate the locale settings of the IDE so that + // strings returned by the DE are properly localized. The sample engine is not localized so this is not implemented. + int IDebugEngine2.SetLocale(ushort wLangID) { + return VSConstants.S_OK; + } // A metric is a registry value used to change a debug engine's behavior or to advertise supported functionality. // This method can forward the call to the appropriate form of the Debugging SDK Helpers function, SetMetric. int IDebugEngine2.SetMetric(string pszMetric, object varValue) { @@ -576,25 +523,19 @@ namespace Cosmos.Debug.VSDebugEngine { } public string GetAddressDescription(uint ip) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); // DebuggedModule module = m_debuggedProcess.ResolveAddress(ip); - return "";// EngineUtils.GetAddressDescription(module, ip); } // Determines if a debug engine (DE) can detach from the program. public int CanDetach() { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - // The sample engine always supports detach + // We always support detach return VSConstants.S_OK; } // The debugger calls CauseBreak when the user clicks on the pause button in VS. The debugger should respond by entering // breakmode. public int CauseBreak() { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - //System.Diagnostics.Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); - //m_pollThread.RunOperation(new Operation(delegate { // //m_debuggedProcess.Break(); //})); @@ -602,17 +543,9 @@ namespace Cosmos.Debug.VSDebugEngine { return VSConstants.S_OK; } - // Enumerates the code contexts for a given position in a source file. - public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - - throw new Exception("The method or operation is not implemented."); - } - // EnumCodePaths is used for the step-into specific feature -- right click on the current statment and decide which // function to step into. This is not something that the SampleEngine supports. public int EnumCodePaths(string hint, IDebugCodeContext2 start, IDebugStackFrame2 frame, int fSource, out IEnumCodePaths2 pathEnum, out IDebugCodeContext2 safetyContext) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); pathEnum = null; safetyContext = null; return VSConstants.E_NOTIMPL; @@ -625,31 +558,24 @@ namespace Cosmos.Debug.VSDebugEngine { // An IDE might display the additional program properties through a generic property browser user interface. // The sample engine does not support this public int GetDebugProperty(out IDebugProperty2 ppProperty) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); throw new Exception("The method or operation is not implemented."); } // The debugger calls this when it needs to obtain the IDebugDisassemblyStream2 for a particular code-context. // The sample engine does not support dissassembly so it returns E_NOTIMPL public int GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 codeContext, out IDebugDisassemblyStream2 disassemblyStream) { - MessageBox.Show("Disassembly"); - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); disassemblyStream = null; - return VSConstants.E_NOTIMPL; } // The memory bytes as represented by the IDebugMemoryBytes2 object is for the program's image in memory and not any memory // that was allocated when the program was executed. public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); throw new Exception("The method or operation is not implemented."); } // Writes a dump to a file. public int WriteDump(enum_DUMPTYPE DUMPTYPE, string pszDumpUrl) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - // The sample debugger does not support creating or reading mini-dumps. return VSConstants.E_NOTIMPL; } @@ -662,8 +588,6 @@ namespace Cosmos.Debug.VSDebugEngine { // // The sample engine only supports debugging native applications and therefore only has one program per-process public int Stop() { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - throw new Exception("The method or operation is not implemented."); } @@ -671,23 +595,18 @@ namespace Cosmos.Debug.VSDebugEngine { // the same process. The sample engine doesn't cooperate with other engines, so it has nothing // to do here. public int WatchForExpressionEvaluationOnThread(IDebugProgram2 pOriginatingProgram, uint dwTid, uint dwEvalFlags, IDebugEventCallback2 pExprCallback, int fWatch) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - return VSConstants.S_OK; } // WatchForThreadStep is used to cooperate between two different engines debugging the same process. // The sample engine doesn't cooperate with other engines, so it has nothing to do here. public int WatchForThreadStep(IDebugProgram2 pOriginatingProgram, uint dwTid, int fWatch, uint dwFrame) { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); - return VSConstants.S_OK; } // Terminates the program. public int Terminate() { - Trace.WriteLine(new StackTrace(false).GetFrame(0).GetMethod().GetFullName()); mProgram = null; // Because the sample engine is a native debugger, it implements IDebugEngineLaunch2, and will terminate @@ -695,7 +614,12 @@ namespace Cosmos.Debug.VSDebugEngine { return VSConstants.S_OK; } - + + // Enumerates the code contexts for a given position in a source file. + public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) { + throw new Exception("The method or operation is not implemented."); + } + #endregion #region Deprecated interface methods