private void DebugService_DebuggerStopped(object sender, DebuggerStoppedEventArgs e) { // Provide the reason for why the debugger has stopped script execution. // See https://github.com/Microsoft/vscode/issues/3648 // The reason is displayed in the breakpoints viewlet. Some recommended reasons are: // "step", "breakpoint", "function breakpoint", "exception" and "pause". // We don't support exception breakpoints and for "pause", we can't distinguish // between stepping and the user pressing the pause/break button in the debug toolbar. string debuggerStoppedReason = "step"; if (e.OriginalEvent.Breakpoints.Count > 0) { debuggerStoppedReason = e.OriginalEvent.Breakpoints[0] is CommandBreakpoint ? "function breakpoint" : "breakpoint"; } _debugAdapterServer.SendNotification(EventNames.Stopped, new StoppedEvent { ThreadId = 1, Reason = debuggerStoppedReason }); }
private async Task OnExecutionCompletedAsync(Task executeTask) { try { await executeTask.ConfigureAwait(false); } catch (Exception e) { _logger.LogError( "Exception occurred while awaiting debug launch task.\n\n" + e.ToString()); } _logger.LogTrace("Execution completed, terminating..."); _debugStateService.ExecutionCompleted = true; _debugEventHandlerService.UnregisterEventHandlers(); if (_debugStateService.IsAttachSession) { // Pop the sessions if (_powerShellContextService.CurrentRunspace.Context == RunspaceContext.EnteredProcess) { try { await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSHostProcess"); if (_debugStateService.IsRemoteAttach && _powerShellContextService.CurrentRunspace.Location == RunspaceLocation.Remote) { await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSSession"); } } catch (Exception e) { _logger.LogException("Caught exception while popping attached process after debugging", e); } } } _debugService.IsClientAttached = false; _debugAdapterServer.SendNotification(EventNames.Terminated); }