public int StopDebuggingPE() { try { log.Write("Exit Debug Mode: project '{0}'", _vsProject.DisplayName); Debug.Assert(s_breakStateEnteredProjects.Count == 0); // EnC service is global (per solution), but the debugger calls this for each project. // Avoid ending the debug session if it has already been ended. if (_encService.DebuggingSession != null) { _encService.EndDebuggingSession(); LogEncSession(); s_encDebuggingSessionInfo = null; s_readOnlyDocumentTracker.Dispose(); s_readOnlyDocumentTracker = null; } if (_metadata != null) { _metadata.Dispose(); _metadata = null; s_debugStateProjectCount--; } else { // an error might have been reported: _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.DebuggerErrorId, _vsProject.Id, documentId: null); } _activeMethods = null; _exceptionRegions = null; _committedBaseline = null; _activeStatementIds = null; if (_pdbReaderObj != null) { Marshal.ReleaseComObject(_pdbReaderObj); _pdbReaderObj = null; } if (_pdbProvider != null) { _pdbProvider.Dispose(); _pdbProvider = null; } _pdbReader = null; // The HResult is ignored by the debugger. return VSConstants.S_OK; } catch (Exception e) when(FatalError.Report(e)) { throw ExceptionUtilities.Unreachable; } }
private EditAndContinueMethodDebugInformation GetBaselineEncDebugInfo(MethodDefinitionHandle methodHandle) { Debug.Assert(Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA); if (_pdbReader == null) { if (_pdbReaderObj != null) { _pdbReader = (ISymUnmanagedReader)_pdbReaderObj; } else { Debug.Assert(_pdbImage != null); _pdbProvider = SymbolReaderProvider.Create(_pdbImage); _pdbReader = _pdbProvider.SymbolReader; _pdbImage = null; } } byte[] debugInfo = _pdbReader.GetCustomDebugInfo(MetadataTokens.GetToken(methodHandle), methodVersion: 0); if (debugInfo != null) { try { var localSlots = CustomDebugInfoReader.TryGetCustomDebugInfoRecord(debugInfo, CustomDebugInfoKind.EditAndContinueLocalSlotMap); var lambdaMap = CustomDebugInfoReader.TryGetCustomDebugInfoRecord(debugInfo, CustomDebugInfoKind.EditAndContinueLambdaMap); return EditAndContinueMethodDebugInformation.Create(localSlots, lambdaMap); } catch (InvalidOperationException e) { log.Write("Error reading Local Slot Map CDI: {0}", e.Message); } } return default(EditAndContinueMethodDebugInformation); }