Exemplo n.º 1
0
        /// <summary>
        /// Prepares the debugger
        /// </summary>
        /// <param name="debuggeeVersion">Version of the program to debug - eg. "v1.1.4322"
        /// If null, the version of the executing process will be used</param>
        internal void InitDebugger(string debuggeeVersion)
        {
            if (IsKernelDebuggerEnabled)
            {
                throw new DebuggerException("Can not debug because kernel debugger is enabled");
            }
            if (string.IsNullOrEmpty(debuggeeVersion))
            {
                debuggeeVersion = GetDebuggerVersion();
                TraceMessage("Debuggee version: Unknown (assuming " + debuggeeVersion + ")");
            }
            else
            {
                TraceMessage("Debuggee version: " + debuggeeVersion);
            }
            this.debuggeeVersion = debuggeeVersion;

            int debuggerVersion;

            // The CLR does not provide 4.0 debugger interface for older versions
            if (debuggeeVersion.StartsWith("v1") || debuggeeVersion.StartsWith("v2"))
            {
                debuggerVersion = 3; // 2.0 CLR
                TraceMessage("Debugger interface version: v2.0");
            }
            else
            {
                debuggerVersion = 4; // 4.0 CLR
                TraceMessage("Debugger interface version: v4.0");
            }

            corDebug = NativeMethods.CreateDebuggingInterfaceFromVersion(debuggerVersion, debuggeeVersion);
            TrackedComObjects.Track(corDebug);

            managedCallbackSwitch = new ManagedCallbackSwitch(this);
            managedCallbackProxy  = new ManagedCallbackProxy(this, managedCallbackSwitch);

            corDebug.Initialize();
            corDebug.SetManagedHandler(managedCallbackProxy);

            TraceMessage("ICorDebug initialized");
        }
 public ManagedCallbackProxy(NDebugger debugger, ManagedCallbackSwitch callbackSwitch)
 {
     this.debugger       = debugger;
     this.callbackSwitch = callbackSwitch;
 }