} // end ProcessRecord() internal static void _DoDisconnect(DbgEngDebugger debugger, bool leaveSuspended, bool kill) { DbgEngContext ctxBefore; debugger.GetCurrentDbgEngContext().TryAsProcessContext(out ctxBefore); if (leaveSuspended) { debugger.AbandonProcess(); } else { if (kill) { if (debugger.IsLive) { debugger.KillProcess(); } } debugger.DetachProcess(); } DbgEngContext ctxAfter = null; try { debugger.GetCurrentDbgEngContext().TryAsProcessContext(out ctxAfter); } catch (DbgProviderException) { // Couldn't get the context: great--that means it's gone, like we // wanted. } // Just because we were able to get /a/ context, doesn't mean the // disconnect didn't work--it could be the context of a different // process (if we had been attached to multiple systems or processes). if (ctxAfter == ctxBefore) { LogManager.Trace("Looks like we need to .abandon as well."); // This can happen if the process has already exited--in that state, // a simple ".kill" (KillProcess and DetachProcess) doesn't work. It // doesn't work in windbg, either, but I'd like the UX to be better in // DbgShell: .kill should /always/ "get rid of" the current process; // not just if it's running. debugger.AbandonProcess(); } } // end _DoDisconnect()
public DbgSymbolGroup(DbgEngDebugger debugger, DEBUG_SCOPE_GROUP scope, DbgStackFrameInfo frame, DbgEngContext context) : base(debugger) { if (null == context) { context = debugger.GetCurrentDbgEngContext(); } if (null == frame) { frame = debugger.GetCurrentScopeFrame(); } Context = context; Frame = frame; using (new DbgEngContextSaver(debugger, context)) { debugger.ExecuteOnDbgEngThread(() => { WDebugSymbols ds5 = (WDebugSymbols)debugger.DebuggerInterface; WDebugSymbolGroup symGroup; CheckHr(ds5.GetScopeSymbolGroup2(scope, null, out symGroup)); m_symGroup = symGroup; Target = debugger.GetCurrentTarget(); }); } } // end constructor
internal DbgTarget(DbgEngDebugger debugger, DbgEngContext context, string targetFriendlyName) : base(debugger) { Context = context.AsTargetContext(); // We are currently assuming that the current context is the target context // (if it were not, the IsLive call below might be wrong). Util.Assert(Context == debugger.GetCurrentDbgEngContext().AsTargetContext()); IsLive = Debugger.IsLive; m_targetFriendlyName = targetFriendlyName; } // end constructor
public DbgEngContextSaver(DbgEngDebugger debugger, DbgEngContext temporaryContext) { if (null == debugger) { throw new ArgumentNullException("debugger"); } if (null == temporaryContext) { throw new ArgumentNullException("temporaryContext"); } m_debugger = debugger; m_oldContext = debugger.GetCurrentDbgEngContext(); Context = temporaryContext; debugger.SetCurrentDbgEngContext(temporaryContext, true); } // end constructor