diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index 1ddb52cbb10..6a3d4c18a57 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -36,9 +36,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb ) { this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDebugService); this._toDispose = []; - this._toDispose.push(debugService.onDidNewProcess(proc => this._proxy.$acceptDebugSessionStarted(proc.getId(), proc.configuration.type, proc.getName(false)))); - this._toDispose.push(debugService.onDidEndProcess(proc => this._proxy.$acceptDebugSessionTerminated(proc.getId(), proc.configuration.type, proc.getName(false)))); - this._toDispose.push(debugService.getViewModel().onDidFocusProcess(proc => { + this._toDispose.push(debugService.onDidNewSession(proc => this._proxy.$acceptDebugSessionStarted(proc.getId(), proc.configuration.type, proc.getName(false)))); + this._toDispose.push(debugService.onDidEndSession(proc => this._proxy.$acceptDebugSessionTerminated(proc.getId(), proc.configuration.type, proc.getName(false)))); + this._toDispose.push(debugService.getViewModel().onDidFocusSession(proc => { if (proc) { this._proxy.$acceptDebugSessionActiveChanged(proc.getId(), proc.configuration.type, proc.getName(false)); } else { @@ -48,7 +48,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb this._toDispose.push(debugService.onDidCustomEvent(event => { if (event && event.sessionId) { - const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === event.sessionId).pop(); + const process = this.debugService.getModel().getSessions().filter(p => p.getId() === event.sessionId).pop(); if (process) { this._proxy.$acceptDebugSessionCustomEvent(event.sessionId, process.configuration.type, process.configuration.name, event); } @@ -218,9 +218,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb } public $customDebugAdapterRequest(sessionId: DebugSessionUUID, request: string, args: any): TPromise { - const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === sessionId).pop(); + const process = this.debugService.getModel().getSessions().filter(p => p.getId() === sessionId).pop(); if (process) { - return process.session.custom(request, args).then(response => { + return process.raw.custom(request, args).then(response => { if (response && response.success) { return response.body; } else { diff --git a/src/vs/workbench/parts/debug/browser/breakpointsView.ts b/src/vs/workbench/parts/debug/browser/breakpointsView.ts index 1e1eb738dad..4fc47f3a778 100644 --- a/src/vs/workbench/parts/debug/browser/breakpointsView.ts +++ b/src/vs/workbench/parts/debug/browser/breakpointsView.ts @@ -436,9 +436,9 @@ class FunctionBreakpointsRenderer implements IRenderer { - const process = this.debugService.getViewModel().focusedProcess; - if (process) { - const index = this.debugService.getModel().getProcesses().indexOf(process); + const session = this.debugService.getViewModel().focusedSession; + if (session) { + const index = this.debugService.getModel().getSessions().indexOf(session); this.select(index); } }); @@ -211,10 +211,10 @@ export class FocusProcessActionItem extends SelectActionItem { } private update() { - const process = this.debugService.getViewModel().focusedProcess; - const processes = this.debugService.getModel().getProcesses(); + const session = this.debugService.getViewModel().focusedSession; + const sessions = this.debugService.getModel().getSessions(); const showRootName = this.debugService.getConfigurationManager().getLaunches().length > 1; - const names = processes.map(p => p.getName(showRootName)); - this.setOptions(names, process ? processes.indexOf(process) : undefined); + const names = sessions.map(s => s.getName(showRootName)); + this.setOptions(names, session ? sessions.indexOf(session) : undefined); } } diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index d42736e6268..03bbd8191f0 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -11,9 +11,9 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IFileService } from 'vs/platform/files/common/files'; -import { IDebugService, State, IProcess, IThread, IEnablement, IBreakpoint, IStackFrame, REPL_ID, ProcessState } +import { IDebugService, State, ISession, IThread, IEnablement, IBreakpoint, IStackFrame, REPL_ID, SessionState } from 'vs/workbench/parts/debug/common/debug'; -import { Variable, Expression, Thread, Breakpoint, Process } from 'vs/workbench/parts/debug/common/debugModel'; +import { Variable, Expression, Thread, Breakpoint, Session } from 'vs/workbench/parts/debug/common/debugModel'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -154,20 +154,20 @@ export class StartAction extends AbstractDebugAction { } public static isEnabled(debugService: IDebugService, contextService: IWorkspaceContextService, configName: string) { - const processes = debugService.getModel().getProcesses(); + const sessions = debugService.getModel().getSessions(); const launch = debugService.getConfigurationManager().selectedConfiguration.launch; if (debugService.state === State.Initializing) { return false; } - if (contextService && contextService.getWorkbenchState() === WorkbenchState.EMPTY && processes.length > 0) { + if (contextService && contextService.getWorkbenchState() === WorkbenchState.EMPTY && sessions.length > 0) { return false; } - if (processes.some(p => p.getName(false) === configName && (!launch || !launch.workspace || !p.session.root || p.session.root.uri.toString() === launch.workspace.uri.toString()))) { + if (sessions.some(p => p.getName(false) === configName && (!launch || !launch.workspace || !p.raw.root || p.raw.root.uri.toString() === launch.workspace.uri.toString()))) { return false; } const compound = launch && launch.getCompound(configName); - if (compound && compound.configurations && processes.some(p => compound.configurations.indexOf(p.getName(false)) !== -1)) { + if (compound && compound.configurations && sessions.some(p => compound.configurations.indexOf(p.getName(false)) !== -1)) { return false; } @@ -224,31 +224,31 @@ export class RestartAction extends AbstractDebugAction { @IHistoryService historyService?: IHistoryService ) { super(id, label, 'debug-action restart', debugService, keybindingService, 70); - this.setLabel(this.debugService.getViewModel().focusedProcess); - this.toDispose.push(this.debugService.getViewModel().onDidFocusStackFrame(() => this.setLabel(this.debugService.getViewModel().focusedProcess))); + this.setLabel(this.debugService.getViewModel().focusedSession); + this.toDispose.push(this.debugService.getViewModel().onDidFocusStackFrame(() => this.setLabel(this.debugService.getViewModel().focusedSession))); if (contextService !== undefined && historyService !== undefined) { this.startAction = new StartAction(id, label, debugService, keybindingService, contextService, historyService); } } - private setLabel(process: IProcess): void { - this.updateLabel(process && process.state === ProcessState.ATTACH ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL); + private setLabel(session: ISession): void { + this.updateLabel(session && session.state === SessionState.ATTACH ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL); } - public run(process: IProcess): TPromise { - if (!(process instanceof Process)) { - process = this.debugService.getViewModel().focusedProcess; + public run(session: ISession): TPromise { + if (!(session instanceof Session)) { + session = this.debugService.getViewModel().focusedSession; } - if (!process) { + if (!session) { return this.startAction.run(); } - if (this.debugService.getModel().getProcesses().length <= 1) { + if (this.debugService.getModel().getSessions().length <= 1) { this.debugService.removeReplExpressions(); } - return this.debugService.restartProcess(process); + return this.debugService.restartSession(session); } protected isEnabled(state: State): boolean { @@ -331,12 +331,12 @@ export class StopAction extends AbstractDebugAction { super(id, label, 'debug-action stop', debugService, keybindingService, 80); } - public run(process: IProcess): TPromise { - if (!(process instanceof Process)) { - process = this.debugService.getViewModel().focusedProcess; + public run(session: ISession): TPromise { + if (!(session instanceof Session)) { + session = this.debugService.getViewModel().focusedSession; } - return this.debugService.stopProcess(process); + return this.debugService.stopSession(session); } protected isEnabled(state: State): boolean { @@ -353,8 +353,8 @@ export class DisconnectAction extends AbstractDebugAction { } public run(): TPromise { - const process = this.debugService.getViewModel().focusedProcess; - return this.debugService.stopProcess(process); + const session = this.debugService.getViewModel().focusedSession; + return this.debugService.stopSession(session); } protected isEnabled(state: State): boolean { @@ -594,8 +594,8 @@ export class SetValueAction extends AbstractDebugAction { } protected isEnabled(state: State): boolean { - const process = this.debugService.getViewModel().focusedProcess; - return super.isEnabled(state) && state === State.Stopped && process && process.session.capabilities.supportsSetVariable; + const session = this.debugService.getViewModel().focusedSession; + return super.isEnabled(state) && state === State.Stopped && session && session.raw.capabilities.supportsSetVariable; } } @@ -763,9 +763,9 @@ export class FocusReplAction extends Action { } } -export class FocusProcessAction extends AbstractDebugAction { +export class FocusSessionAction extends AbstractDebugAction { static readonly ID = 'workbench.action.debug.focusProcess'; - static LABEL = nls.localize('focusProcess', "Focus Process"); + static LABEL = nls.localize('focusSession', "Focus Session"); constructor(id: string, label: string, @IDebugService debugService: IDebugService, @@ -775,10 +775,10 @@ export class FocusProcessAction extends AbstractDebugAction { super(id, label, null, debugService, keybindingService, 100); } - public run(processName: string): TPromise { + public run(sessionName: string): TPromise { const isMultiRoot = this.debugService.getConfigurationManager().getLaunches().length > 1; - const process = this.debugService.getModel().getProcesses().filter(p => p.getName(isMultiRoot) === processName).pop(); - this.debugService.focusStackFrame(undefined, undefined, process, true); + const session = this.debugService.getModel().getSessions().filter(p => p.getName(isMultiRoot) === sessionName).pop(); + this.debugService.focusStackFrame(undefined, undefined, session, true); const stackFrame = this.debugService.getViewModel().focusedStackFrame; if (stackFrame) { return stackFrame.openInEditor(this.editorService, true); @@ -806,9 +806,9 @@ export class StepBackAction extends AbstractDebugAction { } protected isEnabled(state: State): boolean { - const process = this.debugService.getViewModel().focusedProcess; + const session = this.debugService.getViewModel().focusedSession; return super.isEnabled(state) && state === State.Stopped && - process && process.session.capabilities.supportsStepBack; + session && session.raw.capabilities.supportsStepBack; } } @@ -829,9 +829,9 @@ export class ReverseContinueAction extends AbstractDebugAction { } protected isEnabled(state: State): boolean { - const process = this.debugService.getViewModel().focusedProcess; + const session = this.debugService.getViewModel().focusedSession; return super.isEnabled(state) && state === State.Stopped && - process && process.session.capabilities.supportsStepBack; + session && session.raw.capabilities.supportsStepBack; } } diff --git a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts index dcdbd5ae3d9..c0e457ea659 100644 --- a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts +++ b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts @@ -16,8 +16,8 @@ import { ActionBar, ActionsOrientation } from 'vs/base/browser/ui/actionbar/acti import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { IDebugConfiguration, IDebugService, State } from 'vs/workbench/parts/debug/common/debug'; -import { AbstractDebugAction, PauseAction, ContinueAction, StepBackAction, ReverseContinueAction, StopAction, DisconnectAction, StepOverAction, StepIntoAction, StepOutAction, RestartAction, FocusProcessAction } from 'vs/workbench/parts/debug/browser/debugActions'; -import { FocusProcessActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems'; +import { AbstractDebugAction, PauseAction, ContinueAction, StepBackAction, ReverseContinueAction, StopAction, DisconnectAction, StepOverAction, StepIntoAction, StepOutAction, RestartAction, FocusSessionAction } from 'vs/workbench/parts/debug/browser/debugActions'; +import { FocusSessionActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems'; import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; @@ -81,8 +81,8 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi this.actionBar = new ActionBar(actionBarContainter.getHTMLElement(), { orientation: ActionsOrientation.HORIZONTAL, actionItemProvider: (action: IAction) => { - if (action.id === FocusProcessAction.ID) { - return new FocusProcessActionItem(action, this.debugService, this.themeService, contextViewService); + if (action.id === FocusSessionAction.ID) { + return new FocusSessionActionItem(action, this.debugService, this.themeService, contextViewService); } return null; @@ -115,7 +115,7 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi private registerListeners(): void { this.toUnbind.push(this.debugService.onDidChangeState(() => this.updateScheduler.schedule())); - this.toUnbind.push(this.debugService.getViewModel().onDidFocusProcess(() => this.updateScheduler.schedule())); + this.toUnbind.push(this.debugService.getViewModel().onDidFocusSession(() => this.updateScheduler.schedule())); this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => this.onDidConfigurationChange(e))); this.toUnbind.push(this.actionBar.actionRunner.onDidRun((e: IRunEvent) => { // check for error @@ -253,15 +253,15 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi this.allActions.push(new RestartAction(RestartAction.ID, RestartAction.LABEL, this.debugService, this.keybindingService)); this.allActions.push(new StepBackAction(StepBackAction.ID, StepBackAction.LABEL, this.debugService, this.keybindingService)); this.allActions.push(new ReverseContinueAction(ReverseContinueAction.ID, ReverseContinueAction.LABEL, this.debugService, this.keybindingService)); - this.allActions.push(new FocusProcessAction(FocusProcessAction.ID, FocusProcessAction.LABEL, this.debugService, this.keybindingService, this.editorService)); + this.allActions.push(new FocusSessionAction(FocusSessionAction.ID, FocusSessionAction.LABEL, this.debugService, this.keybindingService, this.editorService)); this.allActions.forEach(a => { this.toUnbind.push(a); }); } const state = this.debugService.state; - const process = this.debugService.getViewModel().focusedProcess; - const attached = process && process.configuration.request === 'attach' && process.configuration.type && !strings.equalsIgnoreCase(process.configuration.type, 'extensionHost'); + const session = this.debugService.getViewModel().focusedSession; + const attached = session && session.configuration.request === 'attach' && session.configuration.type && !strings.equalsIgnoreCase(session.configuration.type, 'extensionHost'); return this.allActions.filter(a => { if (a.id === ContinueAction.ID) { @@ -271,10 +271,10 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi return state === State.Running; } if (a.id === StepBackAction.ID) { - return process && process.session.capabilities.supportsStepBack; + return session && session.raw.capabilities.supportsStepBack; } if (a.id === ReverseContinueAction.ID) { - return process && process.session.capabilities.supportsStepBack; + return session && session.raw.capabilities.supportsStepBack; } if (a.id === DisconnectAction.ID) { return attached; @@ -282,8 +282,8 @@ export class DebugActionsWidget extends Themable implements IWorkbenchContributi if (a.id === StopAction.ID) { return !attached; } - if (a.id === FocusProcessAction.ID) { - return this.debugService.getViewModel().isMultiProcessView(); + if (a.id === FocusSessionAction.ID) { + return this.debugService.getViewModel().isMultiSessionView(); } return true; diff --git a/src/vs/workbench/parts/debug/browser/debugContentProvider.ts b/src/vs/workbench/parts/debug/browser/debugContentProvider.ts index 7ca6eb20b7e..f7370887789 100644 --- a/src/vs/workbench/parts/debug/browser/debugContentProvider.ts +++ b/src/vs/workbench/parts/debug/browser/debugContentProvider.ts @@ -12,7 +12,7 @@ import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextModelService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; -import { DEBUG_SCHEME, IDebugService, IProcess } from 'vs/workbench/parts/debug/common/debug'; +import { DEBUG_SCHEME, IDebugService, ISession } from 'vs/workbench/parts/debug/common/debug'; import { Source } from 'vs/workbench/parts/debug/common/debugSource'; /** @@ -41,24 +41,24 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC public provideTextContent(resource: uri): TPromise { - let process: IProcess; + let session: ISession; let sourceRef: number; if (resource.query) { const data = Source.getEncodedDebugData(resource); - process = this.debugService.getModel().getProcesses().filter(p => p.getId() === data.processId).pop(); + session = this.debugService.getModel().getSessions().filter(p => p.getId() === data.sessionId).pop(); sourceRef = data.sourceReference; } - if (!process) { - // fallback: use focused process - process = this.debugService.getViewModel().focusedProcess; + if (!session) { + // fallback: use focused session + session = this.debugService.getViewModel().focusedSession; } - if (!process) { + if (!session) { return TPromise.wrapError(new Error(localize('unable', "Unable to resolve the resource without a debug session"))); } - const source = process.getSourceForUri(resource); + const source = session.getSourceForUri(resource); let rawSource: DebugProtocol.Source; if (source) { rawSource = source.raw; @@ -81,7 +81,7 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC return model; }; - return process.session.source({ sourceReference: sourceRef, source: rawSource }).then(response => { + return session.raw.source({ sourceReference: sourceRef, source: rawSource }).then(response => { if (!response) { return createErrModel(localize('canNotResolveSource', "Could not resolve resource {0}, no response from debug extension.", resource.toString())); } diff --git a/src/vs/workbench/parts/debug/browser/debugEditorActions.ts b/src/vs/workbench/parts/debug/browser/debugEditorActions.ts index 2e4110d5477..fd19cccca0f 100644 --- a/src/vs/workbench/parts/debug/browser/debugEditorActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugEditorActions.ts @@ -112,7 +112,7 @@ class RunToCursorAction extends EditorAction { } let breakpointToRemove: IBreakpoint; - const oneTimeListener = debugService.getViewModel().focusedProcess.session.onDidEvent(event => { + const oneTimeListener = debugService.getViewModel().focusedSession.raw.onDidEvent(event => { if (event.event === 'stopped' || event.event === 'exit') { if (breakpointToRemove) { debugService.removeBreakpoints(breakpointToRemove.getId()); diff --git a/src/vs/workbench/parts/debug/browser/media/debugViewlet.css b/src/vs/workbench/parts/debug/browser/media/debugViewlet.css index 12be0730d7c..412108b1955 100644 --- a/src/vs/workbench/parts/debug/browser/media/debugViewlet.css +++ b/src/vs/workbench/parts/debug/browser/media/debugViewlet.css @@ -114,7 +114,7 @@ .debug-viewlet .monaco-tree .monaco-tree-row.selected .line-number, .debug-viewlet .monaco-list .monaco-list-row.selected .line-number, .debug-viewlet .monaco-tree .monaco-tree-row.selected .thread > .state > .label, -.debug-viewlet .monaco-tree .monaco-tree-row.selected .process > .state > .label { +.debug-viewlet .monaco-tree .monaco-tree-row.selected .session > .state > .label { background-color: #ffffff; color: #666; } @@ -177,12 +177,12 @@ } .debug-viewlet .debug-call-stack .thread, -.debug-viewlet .debug-call-stack .process { +.debug-viewlet .debug-call-stack .session { display: flex; } .debug-viewlet .debug-call-stack .thread > .state, -.debug-viewlet .debug-call-stack .process > .state { +.debug-viewlet .debug-call-stack .session > .state { flex: 1; text-align: right; overflow: hidden; @@ -192,7 +192,7 @@ } .debug-viewlet .debug-call-stack .thread > .state > .label, -.debug-viewlet .debug-call-stack .process > .state > .label { +.debug-viewlet .debug-call-stack .session > .state > .label { background: rgba(136, 136, 136, 0.3); border-radius: 2px; font-size: 0.8em; diff --git a/src/vs/workbench/parts/debug/browser/statusbarColorProvider.ts b/src/vs/workbench/parts/debug/browser/statusbarColorProvider.ts index d3393c3ae02..7db5543accf 100644 --- a/src/vs/workbench/parts/debug/browser/statusbarColorProvider.ts +++ b/src/vs/workbench/parts/debug/browser/statusbarColorProvider.ts @@ -102,8 +102,8 @@ export function isStatusbarInDebugMode(debugService: IDebugService): boolean { return false; } - const process = debugService.getViewModel().focusedProcess; - const isRunningWithoutDebug = process && process.configuration && process.configuration.noDebug; + const session = debugService.getViewModel().focusedSession; + const isRunningWithoutDebug = session && session.configuration && session.configuration.noDebug; if (isRunningWithoutDebug) { return false; } diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 3479ce64f1a..c25c4d142ac 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -102,7 +102,7 @@ export interface IExpression extends IReplElement, IExpressionContainer { readonly type?: string; } -export interface ISession { +export interface IRawSession { readonly root: IWorkspaceFolder; stackTrace(args: DebugProtocol.StackTraceArguments): TPromise; exceptionInfo(args: DebugProtocol.ExceptionInfoArguments): TPromise; @@ -132,17 +132,17 @@ export interface ISession { source(args: DebugProtocol.SourceArguments): TPromise; } -export enum ProcessState { +export enum SessionState { INACTIVE, ATTACH, LAUNCH } -export interface IProcess extends ITreeElement { +export interface ISession extends ITreeElement { getName(includeRoot: boolean): string; readonly configuration: IConfig; - readonly session: ISession; - readonly state: ProcessState; + readonly raw: IRawSession; + readonly state: SessionState; getSourceForUri(modelUri: uri): Source; getThread(threadId: number): IThread; getAllThreads(): ReadonlyArray; @@ -155,7 +155,7 @@ export interface IThread extends ITreeElement { /** * Process the thread belongs to */ - readonly process: IProcess; + readonly session: ISession; /** * Id of the thread generated by the debug adapter backend. @@ -282,9 +282,9 @@ export interface IExceptionInfo { export interface IViewModel extends ITreeElement { /** - * Returns the focused debug process or null if no process is stopped. + * Returns the focused debug session or null if no session is stopped. */ - readonly focusedProcess: IProcess; + readonly focusedSession: ISession; /** * Returns the focused thread or null if no thread is stopped. @@ -301,15 +301,15 @@ export interface IViewModel extends ITreeElement { setSelectedExpression(expression: IExpression): void; setSelectedFunctionBreakpoint(functionBreakpoint: IFunctionBreakpoint): void; - isMultiProcessView(): boolean; + isMultiSessionView(): boolean; - onDidFocusProcess: Event; + onDidFocusSession: Event; onDidFocusStackFrame: Event<{ stackFrame: IStackFrame, explicit: boolean }>; onDidSelectExpression: Event; } export interface IModel extends ITreeElement { - getProcesses(): ReadonlyArray; + getSessions(): ReadonlyArray; getBreakpoints(): ReadonlyArray; areBreakpointsActivated(): boolean; getFunctionBreakpoints(): ReadonlyArray; @@ -580,14 +580,14 @@ export interface IDebugService { onDidChangeState: Event; /** - * Allows to register on new process events. + * Allows to register on new session events. */ - onDidNewProcess: Event; + onDidNewSession: Event; /** - * Allows to register on end process events. + * Allows to register on end session events. */ - onDidEndProcess: Event; + onDidEndSession: Event; /** * Allows to register on custom DAP events. @@ -602,7 +602,7 @@ export interface IDebugService { /** * Sets the focused stack frame and evaluates all expressions against the newly focused stack frame, */ - focusStackFrame(focusedStackFrame: IStackFrame, thread?: IThread, process?: IProcess, explicit?: boolean): void; + focusStackFrame(focusedStackFrame: IStackFrame, thread?: IThread, session?: ISession, explicit?: boolean): void; /** * Adds new breakpoints to the model for the file specified with the uri. Notifies debug adapter of breakpoint changes. @@ -692,14 +692,14 @@ export interface IDebugService { startDebugging(launch: ILaunch, configOrName?: IConfig | string, noDebug?: boolean): TPromise; /** - * Restarts a process or creates a new one if there is no active session. + * Restarts a session or creates a new one if there is no active session. */ - restartProcess(process: IProcess): TPromise; + restartSession(session: ISession): TPromise; /** - * Stops the process. If the process does not exist then stops all processes. + * Stops the session. If the session does not exist then stops all sessions. */ - stopProcess(process: IProcess): TPromise; + stopSession(session: ISession): TPromise; /** * Makes unavailable all sources with the passed uri. Source will appear as grayed out in callstack view. diff --git a/src/vs/workbench/parts/debug/common/debugModel.ts b/src/vs/workbench/parts/debug/common/debugModel.ts index 726e8ac61b9..4f537cd33af 100644 --- a/src/vs/workbench/parts/debug/common/debugModel.ts +++ b/src/vs/workbench/parts/debug/common/debugModel.ts @@ -19,8 +19,8 @@ import { Range, IRange } from 'vs/editor/common/core/range'; import { ISuggestion } from 'vs/editor/common/modes'; import { Position } from 'vs/editor/common/core/position'; import { - ITreeElement, IExpression, IExpressionContainer, IProcess, IStackFrame, IExceptionBreakpoint, IBreakpoint, IFunctionBreakpoint, IModel, IReplElementSource, - IConfig, ISession, IThread, IRawModelUpdate, IScope, IRawStoppedDetails, IEnablement, IBreakpointData, IExceptionInfo, IReplElement, ProcessState, IBreakpointsChangeEvent, IBreakpointUpdateData, IBaseBreakpoint + ITreeElement, IExpression, IExpressionContainer, ISession, IStackFrame, IExceptionBreakpoint, IBreakpoint, IFunctionBreakpoint, IModel, IReplElementSource, + IConfig, IRawSession, IThread, IRawModelUpdate, IScope, IRawStoppedDetails, IEnablement, IBreakpointData, IExceptionInfo, IReplElement, SessionState, IBreakpointsChangeEvent, IBreakpointUpdateData, IBaseBreakpoint } from 'vs/workbench/parts/debug/common/debug'; import { Source } from 'vs/workbench/parts/debug/common/debugSource'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -113,7 +113,7 @@ export class ExpressionContainer implements IExpressionContainer { protected children: TPromise; constructor( - protected process: IProcess, + protected session: ISession, private _reference: number, private id: string, public namedVariables = 0, @@ -161,7 +161,7 @@ export class ExpressionContainer implements IExpressionContainer { for (let i = 0; i < numberOfChunks; i++) { const start = this.startOfVariables + i * chunkSize; const count = Math.min(chunkSize, this.indexedVariables - i * chunkSize); - childrenArray.push(new Variable(this.process, this, this.reference, `[${start}..${start + count - 1}]`, '', '', null, count, { kind: 'virtual' }, null, true, start)); + childrenArray.push(new Variable(this.session, this, this.reference, `[${start}..${start + count - 1}]`, '', '', null, count, { kind: 'virtual' }, null, true, start)); } return childrenArray; @@ -186,16 +186,16 @@ export class ExpressionContainer implements IExpressionContainer { } private fetchVariables(start: number, count: number, filter: 'indexed' | 'named'): TPromise { - return this.process.state !== ProcessState.INACTIVE ? this.process.session.variables({ + return this.session.state !== SessionState.INACTIVE ? this.session.raw.variables({ variablesReference: this.reference, start, count, filter }).then(response => { return response && response.body && response.body.variables ? distinct(response.body.variables.filter(v => !!v && v.name), v => v.name).map( - v => new Variable(this.process, this, v.variablesReference, v.name, v.evaluateName, v.value, v.namedVariables, v.indexedVariables, v.presentationHint, v.type) + v => new Variable(this.session, this, v.variablesReference, v.name, v.evaluateName, v.value, v.namedVariables, v.indexedVariables, v.presentationHint, v.type) ) : []; - }, (e: Error) => [new Variable(this.process, this, 0, null, e.message, '', 0, 0, { kind: 'virtual' }, null, false)]) : TPromise.as([]); + }, (e: Error) => [new Variable(this.session, this, 0, null, e.message, '', 0, 0, { kind: 'virtual' }, null, false)]) : TPromise.as([]); } // The adapter explicitly sents the children count of an expression only if there are lots of children which should be chunked. @@ -231,8 +231,8 @@ export class Expression extends ExpressionContainer implements IExpression { } } - public evaluate(process: IProcess, stackFrame: IStackFrame, context: string): TPromise { - if (!process || (!stackFrame && context !== 'repl')) { + public evaluate(session: ISession, stackFrame: IStackFrame, context: string): TPromise { + if (!session || (!stackFrame && context !== 'repl')) { this.value = context === 'repl' ? nls.localize('startDebugFirst', "Please start a debug session to evaluate") : Expression.DEFAULT_VALUE; this.available = false; this.reference = 0; @@ -240,8 +240,8 @@ export class Expression extends ExpressionContainer implements IExpression { return TPromise.as(null); } - this.process = process; - return process.session.evaluate({ + this.session = session; + return session.raw.evaluate({ expression: this.name, frameId: stackFrame ? stackFrame.frameId : undefined, context @@ -272,7 +272,7 @@ export class Variable extends ExpressionContainer implements IExpression { public errorMessage: string; constructor( - process: IProcess, + session: ISession, public parent: IExpressionContainer, reference: number, public name: string, @@ -285,12 +285,12 @@ export class Variable extends ExpressionContainer implements IExpression { public available = true, startOfVariables = 0 ) { - super(process, reference, `variable:${parent.getId()}:${name}`, namedVariables, indexedVariables, startOfVariables); + super(session, reference, `variable:${parent.getId()}:${name}`, namedVariables, indexedVariables, startOfVariables); this.value = value; } public setVariable(value: string): TPromise { - return this.process.session.setVariable({ + return this.session.raw.setVariable({ name: this.name, value, variablesReference: (this.parent).reference @@ -324,7 +324,7 @@ export class Scope extends ExpressionContainer implements IScope { indexedVariables: number, public range?: IRange ) { - super(stackFrame.thread.process, reference, `scope:${stackFrame.getId()}:${name}:${index}`, namedVariables, indexedVariables); + super(stackFrame.thread.session, reference, `scope:${stackFrame.getId()}:${name}:${index}`, namedVariables, indexedVariables); } } @@ -350,7 +350,7 @@ export class StackFrame implements IStackFrame { public getScopes(): TPromise { if (!this.scopes) { - this.scopes = this.thread.process.session.scopes({ frameId: this.frameId }).then(response => { + this.scopes = this.thread.session.raw.scopes({ frameId: this.frameId }).then(response => { return response && response.body && response.body.scopes ? response.body.scopes.map((rs, index) => new Scope(this, index, rs.name, rs.variablesReference, rs.expensive, rs.namedVariables, rs.indexedVariables, rs.line && rs.column && rs.endLine && rs.endColumn ? new Range(rs.line, rs.column, rs.endLine, rs.endColumn) : null)) : []; @@ -375,7 +375,7 @@ export class StackFrame implements IStackFrame { } public restart(): TPromise { - return this.thread.process.session.restartFrame({ frameId: this.frameId }, this.thread.threadId); + return this.thread.session.raw.restartFrame({ frameId: this.frameId }, this.thread.threadId); } public toString(): string { @@ -394,7 +394,7 @@ export class Thread implements IThread { public stoppedDetails: IRawStoppedDetails; public stopped: boolean; - constructor(public process: IProcess, public name: string, public threadId: number) { + constructor(public session: ISession, public name: string, public threadId: number) { this.stoppedDetails = null; this.callStack = []; this.staleCallStack = []; @@ -402,7 +402,7 @@ export class Thread implements IThread { } public getId(): string { - return `thread:${this.process.getId()}:${this.threadId}`; + return `thread:${this.session.getId()}:${this.threadId}`; } public clearCallStack(): void { @@ -443,7 +443,7 @@ export class Thread implements IThread { } private getCallStackImpl(startFrame: number, levels: number): TPromise { - return this.process.session.stackTrace({ threadId: this.threadId, startFrame, levels }).then(response => { + return this.session.raw.stackTrace({ threadId: this.threadId, startFrame, levels }).then(response => { if (!response || !response.body) { return []; } @@ -453,7 +453,7 @@ export class Thread implements IThread { } return response.body.stackFrames.map((rsf, index) => { - const source = this.process.getSource(rsf.source); + const source = this.session.getSource(rsf.source); return new StackFrame(this, rsf.id, source, rsf.name, rsf.presentationHint, new Range( rsf.line, @@ -475,7 +475,7 @@ export class Thread implements IThread { * Returns exception info promise if the exception was thrown, otherwise null */ public get exceptionInfo(): TPromise { - const session = this.process.session; + const session = this.session.raw; if (this.stoppedDetails && this.stoppedDetails.reason === 'exception') { if (!session.capabilities.supportsExceptionInfoRequest) { return TPromise.as({ @@ -502,65 +502,65 @@ export class Thread implements IThread { } public next(): TPromise { - return this.process.session.next({ threadId: this.threadId }); + return this.session.raw.next({ threadId: this.threadId }); } public stepIn(): TPromise { - return this.process.session.stepIn({ threadId: this.threadId }); + return this.session.raw.stepIn({ threadId: this.threadId }); } public stepOut(): TPromise { - return this.process.session.stepOut({ threadId: this.threadId }); + return this.session.raw.stepOut({ threadId: this.threadId }); } public stepBack(): TPromise { - return this.process.session.stepBack({ threadId: this.threadId }); + return this.session.raw.stepBack({ threadId: this.threadId }); } public continue(): TPromise { - return this.process.session.continue({ threadId: this.threadId }); + return this.session.raw.continue({ threadId: this.threadId }); } public pause(): TPromise { - return this.process.session.pause({ threadId: this.threadId }); + return this.session.raw.pause({ threadId: this.threadId }); } public terminate(): TPromise { - return this.process.session.terminateThreads({ threadIds: [this.threadId] }); + return this.session.raw.terminateThreads({ threadIds: [this.threadId] }); } public reverseContinue(): TPromise { - return this.process.session.reverseContinue({ threadId: this.threadId }); + return this.session.raw.reverseContinue({ threadId: this.threadId }); } } -export class Process implements IProcess { +export class Session implements ISession { private sources: Map; private threads: Map; public inactive = true; - constructor(public configuration: IConfig, private _session: ISession & ITreeElement) { + constructor(public configuration: IConfig, private _session: IRawSession & ITreeElement) { this.threads = new Map(); this.sources = new Map(); this._session.onDidInitialize(() => this.inactive = false); } - public get session(): ISession { + public get raw(): IRawSession { return this._session; } public getName(includeRoot: boolean): string { - return includeRoot && this.session.root ? `${this.configuration.name} (${resources.basenameOrAuthority(this.session.root.uri)})` : this.configuration.name; + return includeRoot && this.raw.root ? `${this.configuration.name} (${resources.basenameOrAuthority(this.raw.root.uri)})` : this.configuration.name; } - public get state(): ProcessState { + public get state(): SessionState { if (this.inactive) { - return ProcessState.INACTIVE; + return SessionState.INACTIVE; } - return this.configuration.type === 'attach' ? ProcessState.ATTACH : ProcessState.LAUNCH; + return this.configuration.type === 'attach' ? SessionState.ATTACH : SessionState.LAUNCH; } public getSourceForUri(modelUri: uri): Source { @@ -653,11 +653,11 @@ export class Process implements IProcess { } public completions(frameId: number, text: string, position: Position, overwriteBefore: number): TPromise { - if (!this.session.capabilities.supportsCompletionsRequest) { + if (!this.raw.capabilities.supportsCompletionsRequest) { return TPromise.as([]); } - return this.session.completions({ + return this.raw.completions({ frameId, text, column: position.column, @@ -762,17 +762,17 @@ export class ExceptionBreakpoint extends Enablement implements IExceptionBreakpo } } -export class ThreadAndProcessIds implements ITreeElement { - constructor(public processId: string, public threadId: number) { } +export class ThreadAndSessionIds implements ITreeElement { + constructor(public sessionId: string, public threadId: number) { } public getId(): string { - return `${this.processId}:${this.threadId}`; + return `${this.sessionId}:${this.threadId}`; } } export class Model implements IModel { - private processes: Process[]; + private sessions: Session[]; private toDispose: lifecycle.IDisposable[]; private replElements: IReplElement[]; private schedulers = new Map(); @@ -788,7 +788,7 @@ export class Model implements IModel { private exceptionBreakpoints: ExceptionBreakpoint[], private watchExpressions: Expression[] ) { - this.processes = []; + this.sessions = []; this.replElements = []; this.toDispose = []; this._onDidChangeBreakpoints = new Emitter(); @@ -801,19 +801,19 @@ export class Model implements IModel { return 'root'; } - public getProcesses(): Process[] { - return this.processes; + public getSessions(): Session[] { + return this.sessions; } - public addProcess(configuration: IConfig, session: ISession & ITreeElement): Process { - const process = new Process(configuration, session); - this.processes.push(process); + public addSession(configuration: IConfig, raw: IRawSession & ITreeElement): Session { + const session = new Session(configuration, raw); + this.sessions.push(session); - return process; + return session; } - public removeProcess(id: string): void { - this.processes = this.processes.filter(p => p.getId() !== id); + public removeSession(id: string): void { + this.sessions = this.sessions.filter(p => p.getId() !== id); this._onDidChangeCallStack.fire(); } @@ -834,26 +834,26 @@ export class Model implements IModel { } public rawUpdate(data: IRawModelUpdate): void { - let process = this.processes.filter(p => p.getId() === data.sessionId).pop(); - if (process) { - process.rawUpdate(data); + let session = this.sessions.filter(p => p.getId() === data.sessionId).pop(); + if (session) { + session.rawUpdate(data); this._onDidChangeCallStack.fire(); } } public clearThreads(id: string, removeThreads: boolean, reference: number = undefined): void { - const process = this.processes.filter(p => p.getId() === id).pop(); + const session = this.sessions.filter(p => p.getId() === id).pop(); this.schedulers.forEach(scheduler => scheduler.dispose()); this.schedulers.clear(); - if (process) { - process.clearThreads(removeThreads, reference); + if (session) { + session.clearThreads(removeThreads, reference); this._onDidChangeCallStack.fire(); } } public fetchCallStack(thread: Thread): TPromise { - if (thread.process.session.capabilities.supportsDelayedStackTraceLoading) { + if (thread.session.raw.capabilities.supportsDelayedStackTraceLoading) { // For improved performance load the first stack frame and then load the rest async. return thread.fetchCallStack(1).then(() => { if (!this.schedulers.has(thread.getId())) { @@ -1068,10 +1068,10 @@ export class Model implements IModel { return this.replElements; } - public addReplExpression(process: IProcess, stackFrame: IStackFrame, name: string): TPromise { + public addReplExpression(session: ISession, stackFrame: IStackFrame, name: string): TPromise { const expression = new Expression(name); this.addReplElements([expression]); - return expression.evaluate(process, stackFrame, 'repl') + return expression.evaluate(session, stackFrame, 'repl') .then(() => this._onDidChangeREPLElements.fire()); } @@ -1115,7 +1115,7 @@ export class Model implements IModel { return this.watchExpressions; } - public addWatchExpression(process: IProcess, stackFrame: IStackFrame, name: string): IExpression { + public addWatchExpression(name: string): IExpression { const we = new Expression(name); this.watchExpressions.push(we); this._onDidChangeWatchExpressions.fire(we); @@ -1123,7 +1123,7 @@ export class Model implements IModel { return we; } - public renameWatchExpression(process: IProcess, stackFrame: IStackFrame, id: string, newName: string): void { + public renameWatchExpression(id: string, newName: string): void { const filtered = this.watchExpressions.filter(we => we.getId() === id); if (filtered.length === 1) { filtered[0].name = newName; @@ -1145,7 +1145,7 @@ export class Model implements IModel { } public sourceIsNotAvailable(uri: uri): void { - this.processes.forEach(p => p.setNotAvailable(uri)); + this.sessions.forEach(p => p.setNotAvailable(uri)); this._onDidChangeCallStack.fire(); } diff --git a/src/vs/workbench/parts/debug/common/debugSource.ts b/src/vs/workbench/parts/debug/common/debugSource.ts index c2ff61f69fe..c2f88d63c28 100644 --- a/src/vs/workbench/parts/debug/common/debugSource.ts +++ b/src/vs/workbench/parts/debug/common/debugSource.ts @@ -86,10 +86,10 @@ export class Source { }, sideBySide); } - public static getEncodedDebugData(modelUri: uri): { name: string, path: string, processId: string, sourceReference: number } { + public static getEncodedDebugData(modelUri: uri): { name: string, path: string, sessionId: string, sourceReference: number } { let path: string; let sourceReference: number; - let processId: string; + let sessionId: string; switch (modelUri.scheme) { case Schemas.file: @@ -104,7 +104,7 @@ export class Source { if (pair.length === 2) { switch (pair[0]) { case 'session': - processId = decodeURIComponent(pair[1]); + sessionId = decodeURIComponent(pair[1]); break; case 'ref': sourceReference = parseInt(pair[1]); @@ -123,7 +123,7 @@ export class Source { name: resources.basenameOrAuthority(modelUri), path, sourceReference, - processId + sessionId }; } } diff --git a/src/vs/workbench/parts/debug/common/debugViewModel.ts b/src/vs/workbench/parts/debug/common/debugViewModel.ts index a4ac6700260..7c945318b01 100644 --- a/src/vs/workbench/parts/debug/common/debugViewModel.ts +++ b/src/vs/workbench/parts/debug/common/debugViewModel.ts @@ -4,28 +4,28 @@ *--------------------------------------------------------------------------------------------*/ import { Event, Emitter } from 'vs/base/common/event'; -import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, IProcess, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED } from 'vs/workbench/parts/debug/common/debug'; +import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, ISession, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED } from 'vs/workbench/parts/debug/common/debug'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; export class ViewModel implements IViewModel { private _focusedStackFrame: IStackFrame; - private _focusedProcess: IProcess; + private _focusedSession: ISession; private _focusedThread: IThread; private selectedExpression: IExpression; private selectedFunctionBreakpoint: IFunctionBreakpoint; - private readonly _onDidFocusProcess: Emitter; + private readonly _onDidFocusSession: Emitter; private readonly _onDidFocusStackFrame: Emitter<{ stackFrame: IStackFrame, explicit: boolean }>; private readonly _onDidSelectExpression: Emitter; - private multiProcessView: boolean; + private multiSessionView: boolean; private expressionSelectedContextKey: IContextKey; private breakpointSelectedContextKey: IContextKey; constructor(contextKeyService: IContextKeyService) { - this._onDidFocusProcess = new Emitter(); + this._onDidFocusSession = new Emitter(); this._onDidFocusStackFrame = new Emitter<{ stackFrame: IStackFrame, explicit: boolean }>(); this._onDidSelectExpression = new Emitter(); - this.multiProcessView = false; + this.multiSessionView = false; this.expressionSelectedContextKey = CONTEXT_EXPRESSION_SELECTED.bindTo(contextKeyService); this.breakpointSelectedContextKey = CONTEXT_BREAKPOINT_SELECTED.bindTo(contextKeyService); } @@ -34,16 +34,16 @@ export class ViewModel implements IViewModel { return 'root'; } - public get focusedProcess(): IProcess { - return this._focusedProcess; + public get focusedSession(): ISession { + return this._focusedSession; } public get focusedThread(): IThread { if (this._focusedStackFrame) { return this._focusedStackFrame.thread; } - if (this._focusedProcess) { - const threads = this._focusedProcess.getAllThreads(); + if (this._focusedSession) { + const threads = this._focusedSession.getAllThreads(); if (threads && threads.length) { return threads[threads.length - 1]; } @@ -56,12 +56,12 @@ export class ViewModel implements IViewModel { return this._focusedStackFrame; } - public setFocus(stackFrame: IStackFrame, thread: IThread, process: IProcess, explicit: boolean): void { - let shouldEmit = this._focusedProcess !== process || this._focusedThread !== thread || this._focusedStackFrame !== stackFrame; + public setFocus(stackFrame: IStackFrame, thread: IThread, session: ISession, explicit: boolean): void { + let shouldEmit = this._focusedSession !== session || this._focusedThread !== thread || this._focusedStackFrame !== stackFrame; - if (this._focusedProcess !== process) { - this._focusedProcess = process; - this._onDidFocusProcess.fire(process); + if (this._focusedSession !== session) { + this._focusedSession = session; + this._onDidFocusSession.fire(session); } this._focusedThread = thread; this._focusedStackFrame = stackFrame; @@ -71,8 +71,8 @@ export class ViewModel implements IViewModel { } } - public get onDidFocusProcess(): Event { - return this._onDidFocusProcess.event; + public get onDidFocusSession(): Event { + return this._onDidFocusSession.event; } public get onDidFocusStackFrame(): Event<{ stackFrame: IStackFrame, explicit: boolean }> { @@ -102,11 +102,11 @@ export class ViewModel implements IViewModel { this.breakpointSelectedContextKey.set(!!functionBreakpoint); } - public isMultiProcessView(): boolean { - return this.multiProcessView; + public isMultiSessionView(): boolean { + return this.multiSessionView; } - public setMultiProcessView(isMultiProcessView: boolean): void { - this.multiProcessView = isMultiProcessView; + public setMultiSessionView(isMultiSessionView: boolean): void { + this.multiSessionView = isMultiSessionView; } } diff --git a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts index 6703b2b0c70..bdb38e45996 100644 --- a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts @@ -9,8 +9,8 @@ import * as dom from 'vs/base/browser/dom'; import { TPromise } from 'vs/base/common/winjs.base'; import * as errors from 'vs/base/common/errors'; import { TreeViewsViewletPanel, IViewletViewOptions, IViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet'; -import { IDebugService, State, IStackFrame, IProcess, IThread } from 'vs/workbench/parts/debug/common/debug'; -import { Thread, StackFrame, ThreadAndProcessIds, Process, Model } from 'vs/workbench/parts/debug/common/debugModel'; +import { IDebugService, State, IStackFrame, ISession, IThread } from 'vs/workbench/parts/debug/common/debug'; +import { Thread, StackFrame, ThreadAndSessionIds, Session, Model } from 'vs/workbench/parts/debug/common/debugModel'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { MenuId } from 'vs/platform/actions/common/actions'; @@ -57,11 +57,11 @@ export class CallStackView extends TreeViewsViewletPanel { // Create scheduler to prevent unnecessary flashing of tree when reacting to changes this.onCallStackChangeScheduler = new RunOnceScheduler(() => { let newTreeInput: any = this.debugService.getModel(); - const processes = this.debugService.getModel().getProcesses(); - if (!this.debugService.getViewModel().isMultiProcessView() && processes.length) { - const threads = processes[0].getAllThreads(); + const sessions = this.debugService.getModel().getSessions(); + if (!this.debugService.getViewModel().isMultiSessionView() && sessions.length) { + const threads = sessions[0].getAllThreads(); // Only show the threads in the call stack if there is more than 1 thread. - newTreeInput = threads.length === 1 ? threads[0] : processes[0]; + newTreeInput = threads.length === 1 ? threads[0] : sessions[0]; } // Only show the global pause message if we do not display threads. @@ -117,18 +117,18 @@ export class CallStackView extends TreeViewsViewletPanel { const element = e.element; if (element instanceof StackFrame) { - this.debugService.focusStackFrame(element, element.thread, element.thread.process, true); + this.debugService.focusStackFrame(element, element.thread, element.thread.session, true); element.openInEditor(this.editorService, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned).done(undefined, errors.onUnexpectedError); } if (element instanceof Thread) { - this.debugService.focusStackFrame(undefined, element, element.process, true); + this.debugService.focusStackFrame(undefined, element, element.session, true); } - if (element instanceof Process) { + if (element instanceof Session) { this.debugService.focusStackFrame(undefined, undefined, element, true); } - if (element instanceof ThreadAndProcessIds) { - const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === element.processId).pop(); - const thread = process && process.getThread(element.threadId); + if (element instanceof ThreadAndSessionIds) { + const session = this.debugService.getModel().getSessions().filter(p => p.getId() === element.sessionId).pop(); + const thread = session && session.getThread(element.threadId); if (thread) { (thread).fetchCallStack() .done(() => this.tree.refresh(), errors.onUnexpectedError); @@ -176,8 +176,8 @@ export class CallStackView extends TreeViewsViewletPanel { const stackFrame = this.debugService.getViewModel().focusedStackFrame; const thread = this.debugService.getViewModel().focusedThread; - const process = this.debugService.getViewModel().focusedProcess; - const updateSelection = (element: IStackFrame | IProcess) => { + const session = this.debugService.getViewModel().focusedSession; + const updateSelection = (element: IStackFrame | ISession) => { this.ignoreSelectionChangedEvent = true; try { this.tree.setSelection([element]); @@ -187,16 +187,16 @@ export class CallStackView extends TreeViewsViewletPanel { }; if (!thread) { - if (!process) { + if (!session) { this.tree.clearSelection(); return TPromise.as(null); } - updateSelection(process); - return this.tree.reveal(process); + updateSelection(session); + return this.tree.reveal(session); } - return this.tree.expandAll([thread.process, thread]).then(() => { + return this.tree.expandAll([thread.session, thread]).then(() => { if (!stackFrame) { return TPromise.as(null); } @@ -256,7 +256,7 @@ class CallStackActionProvider implements IActionProvider { public getSecondaryActions(tree: ITree, element: any): TPromise { const actions: IAction[] = []; - if (element instanceof Process) { + if (element instanceof Session) { actions.push(new RestartAction(RestartAction.ID, RestartAction.LABEL, this.debugService, this.keybindingService)); actions.push(new StopAction(StopAction.ID, StopAction.LABEL, this.debugService, this.keybindingService)); } else if (element instanceof Thread) { @@ -273,7 +273,7 @@ class CallStackActionProvider implements IActionProvider { actions.push(new Separator()); actions.push(new TerminateThreadAction(TerminateThreadAction.ID, TerminateThreadAction.LABEL, this.debugService, this.keybindingService)); } else if (element instanceof StackFrame) { - if (element.thread.process.session.capabilities.supportsRestartFrame) { + if (element.thread.session.raw.capabilities.supportsRestartFrame) { actions.push(new RestartFrameAction(RestartFrameAction.ID, RestartFrameAction.LABEL, this.debugService, this.keybindingService)); } actions.push(new CopyStackTraceAction(CopyStackTraceAction.ID, CopyStackTraceAction.LABEL)); @@ -298,7 +298,7 @@ class CallStackDataSource implements IDataSource { } public hasChildren(tree: ITree, element: any): boolean { - return element instanceof Model || element instanceof Process || (element instanceof Thread && (element).stopped); + return element instanceof Model || element instanceof Session || (element instanceof Thread && (element).stopped); } public getChildren(tree: ITree, element: any): TPromise { @@ -306,11 +306,11 @@ class CallStackDataSource implements IDataSource { return this.getThreadChildren(element); } if (element instanceof Model) { - return TPromise.as(element.getProcesses()); + return TPromise.as(element.getSessions()); } - const process = element; - return TPromise.as(process.getAllThreads()); + const session = element; + return TPromise.as(session.getAllThreads()); } private getThreadChildren(thread: Thread): TPromise { @@ -321,7 +321,7 @@ class CallStackDataSource implements IDataSource { } return callStackPromise.then(() => { - if (callStack.length === 1 && thread.process.session.capabilities.supportsDelayedStackTraceLoading) { + if (callStack.length === 1 && thread.session.raw.capabilities.supportsDelayedStackTraceLoading) { // To reduce flashing of the call stack view simply append the stale call stack // once we have the correct data the tree will refresh and we will no longer display it. callStack = callStack.concat(thread.getStaleCallStack().slice(1)); @@ -331,7 +331,7 @@ class CallStackDataSource implements IDataSource { callStack = callStack.concat([thread.stoppedDetails.framesErrorMessage]); } if (thread.stoppedDetails && thread.stoppedDetails.totalFrames > callStack.length && callStack.length > 1) { - callStack = callStack.concat([new ThreadAndProcessIds(thread.process.getId(), thread.threadId)]); + callStack = callStack.concat([new ThreadAndSessionIds(thread.session.getId(), thread.threadId)]); } return callStack; @@ -350,8 +350,8 @@ interface IThreadTemplateData { stateLabel: HTMLSpanElement; } -interface IProcessTemplateData { - process: HTMLElement; +interface ISessionTemplateData { + session: HTMLElement; name: HTMLElement; state: HTMLElement; stateLabel: HTMLSpanElement; @@ -379,7 +379,7 @@ class CallStackRenderer implements IRenderer { private static readonly STACK_FRAME_TEMPLATE_ID = 'stackFrame'; private static readonly ERROR_TEMPLATE_ID = 'error'; private static readonly LOAD_MORE_TEMPLATE_ID = 'loadMore'; - private static readonly PROCESS_TEMPLATE_ID = 'process'; + private static readonly SESSION_TEMPLATE_ID = 'session'; constructor( @IWorkspaceContextService private contextService: IWorkspaceContextService, @@ -393,8 +393,8 @@ class CallStackRenderer implements IRenderer { } public getTemplateId(tree: ITree, element: any): string { - if (element instanceof Process) { - return CallStackRenderer.PROCESS_TEMPLATE_ID; + if (element instanceof Session) { + return CallStackRenderer.SESSION_TEMPLATE_ID; } if (element instanceof Thread) { return CallStackRenderer.THREAD_TEMPLATE_ID; @@ -410,11 +410,11 @@ class CallStackRenderer implements IRenderer { } public renderTemplate(tree: ITree, templateId: string, container: HTMLElement): any { - if (templateId === CallStackRenderer.PROCESS_TEMPLATE_ID) { - let data: IProcessTemplateData = Object.create(null); - data.process = dom.append(container, $('.process')); - data.name = dom.append(data.process, $('.name')); - data.state = dom.append(data.process, $('.state')); + if (templateId === CallStackRenderer.SESSION_TEMPLATE_ID) { + let data: ISessionTemplateData = Object.create(null); + data.session = dom.append(container, $('.session')); + data.name = dom.append(data.session, $('.name')); + data.state = dom.append(data.session, $('.state')); data.stateLabel = dom.append(data.state, $('span.label')); return data; @@ -454,8 +454,8 @@ class CallStackRenderer implements IRenderer { } public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void { - if (templateId === CallStackRenderer.PROCESS_TEMPLATE_ID) { - this.renderProcess(element, templateData); + if (templateId === CallStackRenderer.SESSION_TEMPLATE_ID) { + this.renderSession(element, templateData); } else if (templateId === CallStackRenderer.THREAD_TEMPLATE_ID) { this.renderThread(element, templateData); } else if (templateId === CallStackRenderer.STACK_FRAME_TEMPLATE_ID) { @@ -467,10 +467,10 @@ class CallStackRenderer implements IRenderer { } } - private renderProcess(process: IProcess, data: IProcessTemplateData): void { - data.process.title = nls.localize({ key: 'process', comment: ['Process is a noun'] }, "Process"); - data.name.textContent = process.getName(this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE); - const stoppedThread = process.getAllThreads().filter(t => t.stopped).pop(); + private renderSession(session: ISession, data: ISessionTemplateData): void { + data.session.title = nls.localize({ key: 'session', comment: ['Session is a noun'] }, "Session"); + data.name.textContent = session.getName(this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE); + const stoppedThread = session.getAllThreads().filter(t => t.stopped).pop(); data.stateLabel.textContent = stoppedThread ? nls.localize('paused', "Paused") : nls.localize({ key: 'running', comment: ['indicates state'] }, "Running"); diff --git a/src/vs/workbench/parts/debug/electron-browser/debugHover.ts b/src/vs/workbench/parts/debug/electron-browser/debugHover.ts index 9a154574295..6e43c34d40b 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugHover.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugHover.ts @@ -142,7 +142,7 @@ export class DebugHoverWidget implements IContentWidget { public showAt(range: Range, focus: boolean): TPromise { const pos = range.getStartPosition(); - const process = this.debugService.getViewModel().focusedProcess; + const session = this.debugService.getViewModel().focusedSession; const lineContent = this.editor.getModel().getLineContent(pos.lineNumber); const { start, end } = getExactExpressionStartAndEnd(lineContent, range.startColumn, range.endColumn); // use regex to extract the sub-expression #9821 @@ -152,9 +152,9 @@ export class DebugHoverWidget implements IContentWidget { } let promise: TPromise; - if (process.session.capabilities.supportsEvaluateForHovers) { + if (session.raw.capabilities.supportsEvaluateForHovers) { const result = new Expression(matchingExpression); - promise = result.evaluate(process, this.debugService.getViewModel().focusedStackFrame, 'hover').then(() => result); + promise = result.evaluate(session, this.debugService.getViewModel().focusedStackFrame, 'hover').then(() => result); } else { promise = this.findExpressionInStackFrame(matchingExpression.split('.').map(word => word.trim()).filter(word => !!word)); } diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index e12738ea6f4..b53455f4f2d 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -31,7 +31,7 @@ import { TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryI import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import * as debug from 'vs/workbench/parts/debug/common/debug'; import { RawDebugSession } from 'vs/workbench/parts/debug/electron-browser/rawDebugSession'; -import { Model, ExceptionBreakpoint, FunctionBreakpoint, Breakpoint, Expression, RawObjectReplElement, ExpressionContainer, Process } from 'vs/workbench/parts/debug/common/debugModel'; +import { Model, ExceptionBreakpoint, FunctionBreakpoint, Breakpoint, Expression, RawObjectReplElement, ExpressionContainer, Session } from 'vs/workbench/parts/debug/common/debugModel'; import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel'; import * as debugactions from 'vs/workbench/parts/debug/browser/debugActions'; import { ConfigurationManager } from 'vs/workbench/parts/debug/electron-browser/debugConfigurationManager'; @@ -69,12 +69,12 @@ export class DebugService implements debug.IDebugService { private sessionStates: Map; private readonly _onDidChangeState: Emitter; - private readonly _onDidNewProcess: Emitter; - private readonly _onDidEndProcess: Emitter; + private readonly _onDidNewSession: Emitter; + private readonly _onDidEndSession: Emitter; private readonly _onDidCustomEvent: Emitter; private model: Model; private viewModel: ViewModel; - private allProcesses: Map; + private allSessions: Map; private configurationManager: ConfigurationManager; private toDispose: lifecycle.IDisposable[]; private toDisposeOnSessionEnd: Map; @@ -114,11 +114,11 @@ export class DebugService implements debug.IDebugService { this.toDisposeOnSessionEnd = new Map(); this.breakpointsToSendOnResourceSaved = new Set(); this._onDidChangeState = new Emitter(); - this._onDidNewProcess = new Emitter(); - this._onDidEndProcess = new Emitter(); + this._onDidNewSession = new Emitter(); + this._onDidEndSession = new Emitter(); this._onDidCustomEvent = new Emitter(); this.sessionStates = new Map(); - this.allProcesses = new Map(); + this.allSessions = new Map(); this.fetchThreadsSchedulers = new Map(); this.configurationManager = this.instantiationService.createInstance(ConfigurationManager); @@ -146,24 +146,24 @@ export class DebugService implements debug.IDebugService { private onBroadcast(broadcast: IBroadcast): void { // attach: PH is ready to be attached to - const process = this.allProcesses.get(broadcast.payload.debugId); - if (!process) { + const session = this.allSessions.get(broadcast.payload.debugId); + if (!session) { // Ignore attach events for sessions that never existed (wrong vscode windows) return; } - const session = process.session; + const raw = session.raw; if (broadcast.channel === EXTENSION_ATTACH_BROADCAST_CHANNEL) { - this.onSessionEnd(session); + this.onRawSessionEnd(raw); - process.configuration.request = 'attach'; - process.configuration.port = broadcast.payload.port; - this.doCreateProcess(process.session.root, process.configuration, process.getId()); + session.configuration.request = 'attach'; + session.configuration.port = broadcast.payload.port; + this.doCreateSession(session.raw.root, session.configuration, session.getId()); return; } if (broadcast.channel === EXTENSION_TERMINATE_BROADCAST_CHANNEL) { - this.onSessionEnd(session); + this.onRawSessionEnd(raw); return; } @@ -180,7 +180,7 @@ export class DebugService implements debug.IDebugService { source = { column: frame.column, lineNumber: frame.line, - source: process.getSource({ + source: session.getSource({ name: resources.basenameOrAuthority(frame.uri), path: frame.uri.fsPath }) @@ -269,32 +269,31 @@ export class DebugService implements debug.IDebugService { return stackFrameToFocus.openInEditor(this.editorService, true); } - private registerSessionListeners(process: Process, session: RawDebugSession): void { + private registerSessionListeners(session: Session, raw: RawDebugSession): void { + this.toDisposeOnSessionEnd.get(raw.getId()).push(raw); - this.toDisposeOnSessionEnd.get(session.getId()).push(session); - - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidInitialize(event => { + this.toDisposeOnSessionEnd.get(raw.getId()).push(raw.onDidInitialize(event => { aria.status(nls.localize('debuggingStarted', "Debugging started.")); const sendConfigurationDone = () => { - if (session && session.capabilities.supportsConfigurationDoneRequest) { - return session.configurationDone().done(null, e => { + if (raw && raw.capabilities.supportsConfigurationDoneRequest) { + return raw.configurationDone().done(null, e => { // Disconnect the debug session on configuration done error #10596 - if (session) { - session.disconnect().done(null, errors.onUnexpectedError); + if (raw) { + raw.disconnect().done(null, errors.onUnexpectedError); } this.notificationService.error(e.message); }); } }; - this.sendAllBreakpoints(process).then(sendConfigurationDone, sendConfigurationDone) - .done(() => this.fetchThreads(session), errors.onUnexpectedError); + this.sendAllBreakpoints(session).then(sendConfigurationDone, sendConfigurationDone) + .done(() => this.fetchThreads(raw), errors.onUnexpectedError); })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidStop(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidStop(event => { this.updateStateAndEmit(session.getId(), debug.State.Stopped); - this.fetchThreads(session, event.body).done(() => { - const thread = process && process.getThread(event.body.threadId); + this.fetchThreads(raw, event.body).done(() => { + const thread = session && session.getThread(event.body.threadId); if (thread) { // Call fetch call stack twice, the first only return the top stack frame. // Second retrieves the rest of the call stack. For performance reasons #25605 @@ -305,13 +304,13 @@ export class DebugService implements debug.IDebugService { }, errors.onUnexpectedError); })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidThread(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidThread(event => { if (event.body.reason === 'started') { // debounce to reduce threadsRequest frequency and improve performance let scheduler = this.fetchThreadsSchedulers.get(session.getId()); if (!scheduler) { scheduler = new RunOnceScheduler(() => { - this.fetchThreads(session).done(undefined, errors.onUnexpectedError); + this.fetchThreads(raw).done(undefined, errors.onUnexpectedError); }, 100); this.fetchThreadsSchedulers.set(session.getId(), scheduler); this.toDisposeOnSessionEnd.get(session.getId()).push(scheduler); @@ -324,28 +323,28 @@ export class DebugService implements debug.IDebugService { } })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidTerminateDebugee(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidTerminateDebugee(event => { aria.status(nls.localize('debuggingStopped', "Debugging stopped.")); if (session && session.getId() === event.sessionId) { - if (event.body && event.body.restart && process) { - this.restartProcess(process, event.body.restart).done(null, err => this.notificationService.error(err.message)); + if (event.body && event.body.restart && session) { + this.restartSession(session, event.body.restart).done(null, err => this.notificationService.error(err.message)); } else { - session.disconnect().done(null, errors.onUnexpectedError); + raw.disconnect().done(null, errors.onUnexpectedError); } } })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidContinued(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidContinued(event => { const threadId = event.body.allThreadsContinued !== false ? undefined : event.body.threadId; this.model.clearThreads(session.getId(), false, threadId); - if (this.viewModel.focusedProcess.getId() === session.getId()) { - this.focusStackFrame(undefined, this.viewModel.focusedThread, this.viewModel.focusedProcess); + if (this.viewModel.focusedSession.getId() === session.getId()) { + this.focusStackFrame(undefined, this.viewModel.focusedThread, this.viewModel.focusedSession); } this.updateStateAndEmit(session.getId(), debug.State.Running); })); let outputPromises: TPromise[] = []; - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidOutput(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidOutput(event => { if (!event.body) { return; } @@ -354,9 +353,9 @@ export class DebugService implements debug.IDebugService { if (event.body.category === 'telemetry') { // only log telemetry events from debug adapter if the debug extension provided the telemetry key // and the user opted in telemetry - if (session.customTelemetryService && this.telemetryService.isOptedIn) { + if (raw.customTelemetryService && this.telemetryService.isOptedIn) { // __GDPR__TODO__ We're sending events in the name of the debug extension and we can not ensure that those are declared correctly. - session.customTelemetryService.publicLog(event.body.output, event.body.data); + raw.customTelemetryService.publicLog(event.body.output, event.body.data); } return; @@ -367,10 +366,10 @@ export class DebugService implements debug.IDebugService { const source = event.body.source ? { lineNumber: event.body.line, column: event.body.column ? event.body.column : 1, - source: process.getSource(event.body.source) + source: session.getSource(event.body.source) } : undefined; if (event.body.variablesReference) { - const container = new ExpressionContainer(process, event.body.variablesReference, generateUuid()); + const container = new ExpressionContainer(session, event.body.variablesReference, generateUuid()); outputPromises.push(container.getChildren().then(children => { return TPromise.join(waitFor).then(() => children.forEach(child => { // Since we can not display multiple trees in a row, we are displaying these variables one after the other (ignoring their names) @@ -384,13 +383,13 @@ export class DebugService implements debug.IDebugService { TPromise.join(outputPromises).then(() => outputPromises = []); })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidBreakpoint(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidBreakpoint(event => { const id = event.body && event.body.breakpoint ? event.body.breakpoint.id : undefined; const breakpoint = this.model.getBreakpoints().filter(bp => bp.idFromAdapter === id).pop(); const functionBreakpoint = this.model.getFunctionBreakpoints().filter(bp => bp.idFromAdapter === id).pop(); if (event.body.reason === 'new' && event.body.breakpoint.source) { - const source = process.getSource(event.body.breakpoint.source); + const source = session.getSource(event.body.breakpoint.source); const bps = this.model.addBreakpoints(source.uri, [{ column: event.body.breakpoint.column, enabled: true, @@ -423,21 +422,21 @@ export class DebugService implements debug.IDebugService { } })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidExitAdapter(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidExitAdapter(event => { // 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905 - if (strings.equalsIgnoreCase(process.configuration.type, 'extensionhost') && this.sessionStates.get(session.getId()) === debug.State.Running && - process && process.session.root && process.configuration.noDebug) { + if (strings.equalsIgnoreCase(session.configuration.type, 'extensionhost') && this.sessionStates.get(session.getId()) === debug.State.Running && + session && session.raw.root && session.configuration.noDebug) { this.broadcastService.broadcast({ channel: EXTENSION_CLOSE_EXTHOST_BROADCAST_CHANNEL, - payload: [process.session.root.uri.fsPath] + payload: [session.raw.root.uri.fsPath] }); } if (session && session.getId() === event.sessionId) { - this.onSessionEnd(session); + this.onRawSessionEnd(raw); } })); - this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidCustomEvent(event => { + this.toDisposeOnSessionEnd.get(session.getId()).push(raw.onDidCustomEvent(event => { this._onDidCustomEvent.fire(event); })); } @@ -506,9 +505,9 @@ export class DebugService implements debug.IDebugService { if (focusedThread && focusedThread.stopped) { return debug.State.Stopped; } - const focusedProcess = this.viewModel.focusedProcess; - if (focusedProcess && this.sessionStates.has(focusedProcess.getId())) { - return this.sessionStates.get(focusedProcess.getId()); + const focusedSession = this.viewModel.focusedSession; + if (focusedSession && this.sessionStates.has(focusedSession.getId())) { + return this.sessionStates.get(focusedSession.getId()); } if (this.sessionStates.size > 0) { return debug.State.Initializing; @@ -521,12 +520,12 @@ export class DebugService implements debug.IDebugService { return this._onDidChangeState.event; } - public get onDidNewProcess(): Event { - return this._onDidNewProcess.event; + public get onDidNewSession(): Event { + return this._onDidNewSession.event; } - public get onDidEndProcess(): Event { - return this._onDidEndProcess.event; + public get onDidEndSession(): Event { + return this._onDidEndSession.event; } public get onDidCustomEvent(): Event { @@ -553,13 +552,13 @@ export class DebugService implements debug.IDebugService { } } - public focusStackFrame(stackFrame: debug.IStackFrame, thread?: debug.IThread, process?: debug.IProcess, explicit?: boolean): void { - if (!process) { + public focusStackFrame(stackFrame: debug.IStackFrame, thread?: debug.IThread, session?: debug.ISession, explicit?: boolean): void { + if (!session) { if (stackFrame || thread) { - process = stackFrame ? stackFrame.thread.process : thread.process; + session = stackFrame ? stackFrame.thread.session : thread.session; } else { - const processes = this.model.getProcesses(); - process = processes.length ? processes[0] : undefined; + const sessions = this.model.getSessions(); + session = sessions.length ? sessions[0] : undefined; } } @@ -567,7 +566,7 @@ export class DebugService implements debug.IDebugService { if (stackFrame) { thread = stackFrame.thread; } else { - const threads = process ? process.getAllThreads() : undefined; + const threads = session ? session.getAllThreads() : undefined; thread = threads && threads.length ? threads[0] : undefined; } } @@ -579,7 +578,7 @@ export class DebugService implements debug.IDebugService { } } - this.viewModel.setFocus(stackFrame, thread, process, explicit); + this.viewModel.setFocus(stackFrame, thread, session, explicit); this.updateStateAndEmit(); } @@ -646,9 +645,9 @@ export class DebugService implements debug.IDebugService { } public addReplExpression(name: string): TPromise { - return this.model.addReplExpression(this.viewModel.focusedProcess, this.viewModel.focusedStackFrame, name) + return this.model.addReplExpression(this.viewModel.focusedSession, this.viewModel.focusedStackFrame, name) // Evaluate all watch expressions and fetch variables again since repl evaluation might have changed some. - .then(() => this.focusStackFrame(this.viewModel.focusedStackFrame, this.viewModel.focusedThread, this.viewModel.focusedProcess)); + .then(() => this.focusStackFrame(this.viewModel.focusedStackFrame, this.viewModel.focusedThread, this.viewModel.focusedSession)); } public removeReplExpressions(): void { @@ -665,12 +664,12 @@ export class DebugService implements debug.IDebugService { } public addWatchExpression(name: string): void { - const we = this.model.addWatchExpression(this.viewModel.focusedProcess, this.viewModel.focusedStackFrame, name); + const we = this.model.addWatchExpression(name); this.viewModel.setSelectedExpression(we); } public renameWatchExpression(id: string, newName: string): void { - return this.model.renameWatchExpression(this.viewModel.focusedProcess, this.viewModel.focusedStackFrame, id, newName); + return this.model.renameWatchExpression(id, newName); } public moveWatchExpression(id: string, position: number): void { @@ -693,9 +692,9 @@ export class DebugService implements debug.IDebugService { // make sure to save all files and that the configuration is up to date return this.extensionService.activateByEvent('onDebug').then(() => this.textFileService.saveAll().then(() => this.configurationService.reloadConfiguration(launch ? launch.workspace : undefined).then(() => this.extensionService.whenInstalledExtensionsRegistered().then(() => { - if (this.model.getProcesses().length === 0) { + if (this.model.getSessions().length === 0) { this.removeReplExpressions(); - this.allProcesses.clear(); + this.allSessions.clear(); this.model.unverifyBreakpoints(); } this.launchJsonChanged = false; @@ -775,7 +774,7 @@ export class DebugService implements debug.IDebugService { this.configurationManager.resolveConfigurationByProviders(launch && launch.workspace ? launch.workspace.uri : undefined, type, config).then(config => { // a falsy config indicates an aborted launch if (config && config.type) { - return this.createProcess(launch, config, sessionId); + return this.createSession(launch, config, sessionId); } if (launch && type) { @@ -812,7 +811,7 @@ export class DebugService implements debug.IDebugService { return TPromise.as(config); } - private createProcess(launch: debug.ILaunch, config: debug.IConfig, sessionId: string): TPromise { + private createSession(launch: debug.ILaunch, config: debug.IConfig, sessionId: string): TPromise { return this.textFileService.saveAll().then(() => this.substituteVariables(launch, config).then(resolvedConfig => { @@ -839,7 +838,7 @@ export class DebugService implements debug.IDebugService { const workspace = launch ? launch.workspace : undefined; const debugAnywayAction = new Action('debug.debugAnyway', nls.localize('debugAnyway', "Debug Anyway"), undefined, true, () => { - return this.doCreateProcess(workspace, resolvedConfig, sessionId); + return this.doCreateSession(workspace, resolvedConfig, sessionId); }); return this.runTask(sessionId, workspace, resolvedConfig.preLaunchTask).then((taskSummary: ITaskSummary) => { @@ -847,7 +846,7 @@ export class DebugService implements debug.IDebugService { const successExitCode = taskSummary && taskSummary.exitCode === 0; const failureExitCode = taskSummary && taskSummary.exitCode !== undefined && taskSummary.exitCode !== 0; if (successExitCode || (errorCount === 0 && !failureExitCode)) { - return this.doCreateProcess(workspace, resolvedConfig, sessionId); + return this.doCreateSession(workspace, resolvedConfig, sessionId); } const message = errorCount > 1 ? nls.localize('preLaunchTaskErrors', "Build errors have been detected during preLaunchTask '{0}'.", resolvedConfig.preLaunchTask) : @@ -875,7 +874,7 @@ export class DebugService implements debug.IDebugService { ); } - private doCreateProcess(root: IWorkspaceFolder, configuration: debug.IConfig, sessionId: string): TPromise { + private doCreateSession(root: IWorkspaceFolder, configuration: debug.IConfig, sessionId: string): TPromise { configuration.__sessionId = sessionId; this.inDebugMode.set(true); @@ -912,16 +911,16 @@ export class DebugService implements debug.IDebugService { customTelemetryService = new TelemetryService({ appender }, this.configurationService); } - const session = this.instantiationService.createInstance(RawDebugSession, sessionId, configuration.debugServer, dbg, customTelemetryService, root); - const process = this.model.addProcess(configuration, session); - this.allProcesses.set(process.getId(), process); + const raw = this.instantiationService.createInstance(RawDebugSession, sessionId, configuration.debugServer, dbg, customTelemetryService, root); + const session = this.model.addSession(configuration, raw); + this.allSessions.set(session.getId(), session); if (client) { - this.toDisposeOnSessionEnd.get(session.getId()).push(client); + this.toDisposeOnSessionEnd.get(raw.getId()).push(client); } - this.registerSessionListeners(process, session); + this.registerSessionListeners(session, raw); - return session.initialize({ + return raw.initialize({ clientID: 'vscode', clientName: product.nameLong, adapterID: configuration.type, @@ -933,14 +932,14 @@ export class DebugService implements debug.IDebugService { supportsRunInTerminalRequest: true, // #10574 locale: platform.locale }).then((result: DebugProtocol.InitializeResponse) => { - this.model.setExceptionBreakpoints(session.capabilities.exceptionBreakpointFilters); - return configuration.request === 'attach' ? session.attach(configuration) : session.launch(configuration); + this.model.setExceptionBreakpoints(raw.capabilities.exceptionBreakpointFilters); + return configuration.request === 'attach' ? raw.attach(configuration) : raw.launch(configuration); }).then((result: DebugProtocol.Response) => { - if (session.disconnected) { + if (raw.disconnected) { return TPromise.as(null); } - this.focusStackFrame(undefined, undefined, process); - this._onDidNewProcess.fire(process); + this.focusStackFrame(undefined, undefined, session); + this._onDidNewSession.fire(session); const internalConsoleOptions = configuration.internalConsoleOptions || this.configurationService.getValue('debug').internalConsoleOptions; if (internalConsoleOptions === 'openOnSessionStart' || (this.firstSessionStart && internalConsoleOptions === 'openOnFirstSessionStart')) { @@ -955,10 +954,10 @@ export class DebugService implements debug.IDebugService { this.firstSessionStart = false; this.debugType.set(configuration.type); - if (this.model.getProcesses().length > 1) { - this.viewModel.setMultiProcessView(true); + if (this.model.getSessions().length > 1) { + this.viewModel.setMultiSessionView(true); } - this.updateStateAndEmit(session.getId(), debug.State.Running); + this.updateStateAndEmit(raw.getId(), debug.State.Running); /* __GDPR__ "debugSessionStart" : { @@ -980,7 +979,7 @@ export class DebugService implements debug.IDebugService { isBuiltin: dbg.extensionDescription.isBuiltin, launchJsonExists: root && !!this.configurationService.getValue('launch', { resource: root.uri }) }); - }).then(() => process, (error: Error | string) => { + }).then(() => session, (error: Error | string) => { if (errors.isPromiseCanceledError(error)) { // Do not show 'canceled' error messages to the user #7906 return TPromise.as(null); @@ -994,11 +993,11 @@ export class DebugService implements debug.IDebugService { } */ this.telemetryService.publicLog('debugMisconfiguration', { type: configuration ? configuration.type : undefined, error: errorMessage }); - this.updateStateAndEmit(session.getId(), debug.State.Inactive); - if (!session.disconnected) { - session.disconnect().done(null, errors.onUnexpectedError); - } else if (process) { - this.model.removeProcess(process.getId()); + this.updateStateAndEmit(raw.getId(), debug.State.Inactive); + if (!raw.disconnected) { + raw.disconnect().done(null, errors.onUnexpectedError); + } else if (session) { + this.model.removeSession(session.getId()); } // Show the repl if some error got logged there #5870 @@ -1091,36 +1090,36 @@ export class DebugService implements debug.IDebugService { this.model.sourceIsNotAvailable(uri); } - public restartProcess(process: debug.IProcess, restartData?: any): TPromise { + public restartSession(session: debug.ISession, restartData?: any): TPromise { return this.textFileService.saveAll().then(() => { - if (process.session.capabilities.supportsRestartRequest) { - return process.session.custom('restart', null); + if (session.raw.capabilities.supportsRestartRequest) { + return session.raw.custom('restart', null); } - const focusedProcess = this.viewModel.focusedProcess; - const preserveFocus = focusedProcess && process.getId() === focusedProcess.getId(); + const focusedSession = this.viewModel.focusedSession; + const preserveFocus = focusedSession && session.getId() === focusedSession.getId(); // Do not run preLaunch and postDebug tasks for automatic restarts this.skipRunningTask = !!restartData; - return process.session.disconnect(true).then(() => { - if (strings.equalsIgnoreCase(process.configuration.type, 'extensionHost') && process.session.root) { + return session.raw.disconnect(true).then(() => { + if (strings.equalsIgnoreCase(session.configuration.type, 'extensionHost') && session.raw.root) { return this.broadcastService.broadcast({ channel: EXTENSION_RELOAD_BROADCAST_CHANNEL, - payload: [process.session.root.uri.fsPath] + payload: [session.raw.root.uri.fsPath] }); } return new TPromise((c, e) => { setTimeout(() => { // Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration - let config = process.configuration; + let config = session.configuration; - const launch = process.session.root ? this.configurationManager.getLaunch(process.session.root.uri) : undefined; + const launch = session.raw.root ? this.configurationManager.getLaunch(session.raw.root.uri) : undefined; if (this.launchJsonChanged && launch) { this.launchJsonChanged = false; - config = launch.getConfiguration(process.configuration.name) || config; - // Take the type from the process since the debug extension might overwrite it #21316 - config.type = process.configuration.type; - config.noDebug = process.configuration.noDebug; + config = launch.getConfiguration(session.configuration.name) || config; + // Take the type from the session since the debug extension might overwrite it #21316 + config.type = session.configuration.type; + config.noDebug = session.configuration.noDebug; } config.__restart = restartData; this.skipRunningTask = !!restartData; @@ -1129,24 +1128,24 @@ export class DebugService implements debug.IDebugService { }); }).then(() => { if (preserveFocus) { - // Restart should preserve the focused process - const restartedProcess = this.model.getProcesses().filter(p => p.configuration.name === process.configuration.name).pop(); - if (restartedProcess && restartedProcess !== this.viewModel.focusedProcess) { - this.focusStackFrame(undefined, undefined, restartedProcess); + // Restart should preserve the focused session + const restartedSession = this.model.getSessions().filter(p => p.configuration.name === session.configuration.name).pop(); + if (restartedSession && restartedSession !== this.viewModel.focusedSession) { + this.focusStackFrame(undefined, undefined, restartedSession); } } }); }); } - public stopProcess(process: debug.IProcess): TPromise { - if (process) { - return process.session.disconnect(false, true); + public stopSession(session: debug.ISession): TPromise { + if (session) { + return session.raw.disconnect(false, true); } - const processes = this.model.getProcesses(); - if (processes.length) { - return TPromise.join(processes.map(p => p.session.disconnect(false, true))); + const sessions = this.model.getSessions(); + if (sessions.length) { + return TPromise.join(sessions.map(s => s.raw.disconnect(false, true))); } this.sessionStates.clear(); @@ -1154,9 +1153,9 @@ export class DebugService implements debug.IDebugService { return undefined; } - private onSessionEnd(session: RawDebugSession): void { + private onRawSessionEnd(raw: RawDebugSession): void { const bpsExist = this.model.getBreakpoints().length > 0; - const process = this.model.getProcesses().filter(p => p.getId() === session.getId()).pop(); + const session = this.model.getSessions().filter(p => p.getId() === raw.getId()).pop(); /* __GDPR__ "debugSessionStop" : { "type" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }, @@ -1167,32 +1166,32 @@ export class DebugService implements debug.IDebugService { } */ this.telemetryService.publicLog('debugSessionStop', { - type: process && process.configuration.type, - success: session.emittedStopped || !bpsExist, - sessionLengthInSeconds: session.getLengthInSeconds(), + type: session && session.configuration.type, + success: raw.emittedStopped || !bpsExist, + sessionLengthInSeconds: raw.getLengthInSeconds(), breakpointCount: this.model.getBreakpoints().length, watchExpressionsCount: this.model.getWatchExpressions().length }); - this.model.removeProcess(session.getId()); - if (process) { - process.inactive = true; - this._onDidEndProcess.fire(process); - if (process.configuration.postDebugTask) { - this.runTask(process.getId(), process.session.root, process.configuration.postDebugTask).done(undefined, err => + this.model.removeSession(raw.getId()); + if (session) { + session.inactive = true; + this._onDidEndSession.fire(session); + if (session.configuration.postDebugTask) { + this.runTask(session.getId(), session.raw.root, session.configuration.postDebugTask).done(undefined, err => this.notificationService.error(err) ); } } - this.toDisposeOnSessionEnd.set(session.getId(), lifecycle.dispose(this.toDisposeOnSessionEnd.get(session.getId()))); - const focusedProcess = this.viewModel.focusedProcess; - if (focusedProcess && focusedProcess.getId() === session.getId()) { + this.toDisposeOnSessionEnd.set(raw.getId(), lifecycle.dispose(this.toDisposeOnSessionEnd.get(raw.getId()))); + const focusedSession = this.viewModel.focusedSession; + if (focusedSession && focusedSession.getId() === raw.getId()) { this.focusStackFrame(null); } - this.updateStateAndEmit(session.getId(), debug.State.Inactive); + this.updateStateAndEmit(raw.getId(), debug.State.Inactive); - if (this.model.getProcesses().length === 0) { + if (this.model.getSessions().length === 0) { // set breakpoints back to unverified since the session ended. const data: { [id: string]: { line: number, verified: boolean, column: number, endLine: number, endColumn: number } } = {}; this.model.getBreakpoints().forEach(bp => { @@ -1202,7 +1201,7 @@ export class DebugService implements debug.IDebugService { this.inDebugMode.reset(); this.debugType.reset(); - this.viewModel.setMultiProcessView(false); + this.viewModel.setMultiSessionView(false); if (this.partService.isVisible(Parts.SIDEBAR_PART) && this.configurationService.getValue('debug').openExplorerOnEnd) { this.viewletService.openViewlet(EXPLORER_VIEWLET_ID).done(null, errors.onUnexpectedError); @@ -1222,24 +1221,24 @@ export class DebugService implements debug.IDebugService { return this.configurationManager; } - private sendAllBreakpoints(process?: debug.IProcess): TPromise { - return TPromise.join(distinct(this.model.getBreakpoints(), bp => bp.uri.toString()).map(bp => this.sendBreakpoints(bp.uri, false, process))) - .then(() => this.sendFunctionBreakpoints(process)) + private sendAllBreakpoints(session?: debug.ISession): TPromise { + return TPromise.join(distinct(this.model.getBreakpoints(), bp => bp.uri.toString()).map(bp => this.sendBreakpoints(bp.uri, false, session))) + .then(() => this.sendFunctionBreakpoints(session)) // send exception breakpoints at the end since some debug adapters rely on the order - .then(() => this.sendExceptionBreakpoints(process)); + .then(() => this.sendExceptionBreakpoints(session)); } - private sendBreakpoints(modelUri: uri, sourceModified = false, targetProcess?: debug.IProcess): TPromise { + private sendBreakpoints(modelUri: uri, sourceModified = false, session?: debug.ISession): TPromise { - const sendBreakpointsToProcess = (process: debug.IProcess): TPromise => { - const session = process.session; - if (!session.readyForBreakpoints) { + const sendBreakpointsToSession = (session: debug.ISession): TPromise => { + const raw = session.raw; + if (!raw.readyForBreakpoints) { return TPromise.as(null); } const breakpointsToSend = this.model.getEnabledBreakpointsForResource(modelUri); - const source = process.getSourceForUri(modelUri); + const source = session.getSourceForUri(modelUri); let rawSource: DebugProtocol.Source; if (source) { rawSource = source.raw; @@ -1254,7 +1253,7 @@ export class DebugService implements debug.IDebugService { // Normalize all drive letters going out from vscode to debug adapters so we are consistent with our resolving #43959 rawSource.path = normalizeDriveLetter(rawSource.path); - return session.setBreakpoints({ + return raw.setBreakpoints({ source: rawSource, lines: breakpointsToSend.map(bp => bp.lineNumber), breakpoints: breakpointsToSend.map(bp => ({ line: bp.lineNumber, column: bp.column, condition: bp.condition, hitCondition: bp.hitCondition, logMessage: bp.logMessage })), @@ -1277,18 +1276,18 @@ export class DebugService implements debug.IDebugService { }); }; - return this.sendToOneOrAllProcesses(targetProcess, sendBreakpointsToProcess); + return this.sendToOneOrAllSessions(session, sendBreakpointsToSession); } - private sendFunctionBreakpoints(targetProcess?: debug.IProcess): TPromise { - const sendFunctionBreakpointsToProcess = (process: debug.IProcess): TPromise => { - const session = process.session; - if (!session.readyForBreakpoints || !session.capabilities.supportsFunctionBreakpoints) { + private sendFunctionBreakpoints(session?: debug.ISession): TPromise { + const sendFunctionBreakpointsToSession = (session: debug.ISession): TPromise => { + const raw = session.raw; + if (!raw.readyForBreakpoints || !raw.capabilities.supportsFunctionBreakpoints) { return TPromise.as(null); } const breakpointsToSend = this.model.getFunctionBreakpoints().filter(fbp => fbp.enabled && this.model.areBreakpointsActivated()); - return session.setFunctionBreakpoints({ breakpoints: breakpointsToSend }).then(response => { + return raw.setFunctionBreakpoints({ breakpoints: breakpointsToSend }).then(response => { if (!response || !response.body) { return; } @@ -1302,29 +1301,29 @@ export class DebugService implements debug.IDebugService { }); }; - return this.sendToOneOrAllProcesses(targetProcess, sendFunctionBreakpointsToProcess); + return this.sendToOneOrAllSessions(session, sendFunctionBreakpointsToSession); } - private sendExceptionBreakpoints(targetProcess?: debug.IProcess): TPromise { - const sendExceptionBreakpointsToProcess = (process: debug.IProcess): TPromise => { - const session = process.session; - if (!session.readyForBreakpoints || this.model.getExceptionBreakpoints().length === 0) { + private sendExceptionBreakpoints(session?: debug.ISession): TPromise { + const sendExceptionBreakpointsToSession = (session: debug.ISession): TPromise => { + const raw = session.raw; + if (!raw.readyForBreakpoints || this.model.getExceptionBreakpoints().length === 0) { return TPromise.as(null); } const enabledExceptionBps = this.model.getExceptionBreakpoints().filter(exb => exb.enabled); - return session.setExceptionBreakpoints({ filters: enabledExceptionBps.map(exb => exb.filter) }); + return raw.setExceptionBreakpoints({ filters: enabledExceptionBps.map(exb => exb.filter) }); }; - return this.sendToOneOrAllProcesses(targetProcess, sendExceptionBreakpointsToProcess); + return this.sendToOneOrAllSessions(session, sendExceptionBreakpointsToSession); } - private sendToOneOrAllProcesses(process: debug.IProcess, send: (process: debug.IProcess) => TPromise): TPromise { - if (process) { - return send(process); + private sendToOneOrAllSessions(session: debug.ISession, send: (session: debug.ISession) => TPromise): TPromise { + if (session) { + return send(session); } - return TPromise.join(this.model.getProcesses().map(p => send(p))).then(() => void 0); + return TPromise.join(this.model.getSessions().map(s => send(s))).then(() => void 0); } private onFileChanges(fileChangesEvent: FileChangesEvent): void { diff --git a/src/vs/workbench/parts/debug/electron-browser/electronDebugActions.ts b/src/vs/workbench/parts/debug/electron-browser/electronDebugActions.ts index bdc325867d5..c7745f86c64 100644 --- a/src/vs/workbench/parts/debug/electron-browser/electronDebugActions.ts +++ b/src/vs/workbench/parts/debug/electron-browser/electronDebugActions.ts @@ -25,8 +25,8 @@ export class CopyValueAction extends Action { public run(): TPromise { if (this.value instanceof Variable) { const frameId = this.debugService.getViewModel().focusedStackFrame.frameId; - const process = this.debugService.getViewModel().focusedProcess; - return process.session.evaluate({ expression: this.value.evaluateName, frameId }).then(result => { + const session = this.debugService.getViewModel().focusedSession; + return session.raw.evaluate({ expression: this.value.evaluateName, frameId }).then(result => { clipboard.writeText(result.body.result); }, err => clipboard.writeText(this.value.value)); } diff --git a/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts b/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts index 66eabe1f91c..78ce3ff55de 100644 --- a/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts +++ b/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts @@ -64,7 +64,7 @@ export class SocketDebugAdapter extends StreamDebugAdapter { } } -export class RawDebugSession implements debug.ISession { +export class RawDebugSession implements debug.IRawSession { private debugAdapter: debug.IDebugAdapter; diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 0a30add4f14..63d77441008 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -185,8 +185,8 @@ export class Repl extends Panel implements IPrivateReplService { const text = this.replInput.getModel().getLineContent(position.lineNumber); const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame; const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined; - const focusedProcess = this.debugService.getViewModel().focusedProcess; - const completions = focusedProcess ? focusedProcess.completions(frameId, text, position, overwriteBefore) : TPromise.as([]); + const focusedSession = this.debugService.getViewModel().focusedSession; + const completions = focusedSession ? focusedSession.completions(frameId, text, position, overwriteBefore) : TPromise.as([]); return wireCancellationToken(token, completions.then(suggestions => ({ suggestions }))); diff --git a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts index 9ade1f87f61..57c643e45e3 100644 --- a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts @@ -316,8 +316,8 @@ class VariablesController extends BaseDebugController { protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean { // double click on primitive value: open input box to be able to set the value - const process = this.debugService.getViewModel().focusedProcess; - if (element instanceof Variable && event.detail === 2 && process && process.session.capabilities.supportsSetVariable) { + const session = this.debugService.getViewModel().focusedSession; + if (element instanceof Variable && event.detail === 2 && session && session.raw.capabilities.supportsSetVariable) { const expression = element; this.debugService.getViewModel().setSelectedExpression(expression); return true; diff --git a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts index 53bb57a640c..45b7a275ebd 100644 --- a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts @@ -214,7 +214,7 @@ class WatchExpressionsDataSource implements IDataSource { if (element instanceof Model) { const viewModel = this.debugService.getViewModel(); return TPromise.join(element.getWatchExpressions().map(we => - we.name ? we.evaluate(viewModel.focusedProcess, viewModel.focusedStackFrame, 'watch').then(() => we) : TPromise.as(we))); + we.name ? we.evaluate(viewModel.focusedSession, viewModel.focusedStackFrame, 'watch').then(() => we) : TPromise.as(we))); } let expression = element; diff --git a/src/vs/workbench/parts/debug/test/browser/baseDebugView.test.ts b/src/vs/workbench/parts/debug/test/browser/baseDebugView.test.ts index 30feb53f8f9..6ca3df65b60 100644 --- a/src/vs/workbench/parts/debug/test/browser/baseDebugView.test.ts +++ b/src/vs/workbench/parts/debug/test/browser/baseDebugView.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import { replaceWhitespace, renderExpressionValue, renderVariable } from 'vs/workbench/parts/debug/browser/baseDebugView'; import * as dom from 'vs/base/browser/dom'; -import { Expression, Variable, Process, Scope, StackFrame, Thread } from 'vs/workbench/parts/debug/common/debugModel'; +import { Expression, Variable, Session, Scope, StackFrame, Thread } from 'vs/workbench/parts/debug/common/debugModel'; import { MockSession } from 'vs/workbench/parts/debug/test/common/mockDebug'; const $ = dom.$; @@ -53,12 +53,12 @@ suite('Debug - Base Debug View', () => { test('render variable', () => { const rawSession = new MockSession(); - const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); - const thread = new Thread(process, 'mockthread', 1); + const session = new Session({ name: 'mockSession', type: 'node', request: 'launch' }, rawSession); + const thread = new Thread(session, 'mockthread', 1); const stackFrame = new StackFrame(thread, 1, null, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: undefined, endColumn: undefined }, 0); const scope = new Scope(stackFrame, 1, 'local', 1, false, 10, 10); - let variable = new Variable(process, scope, 2, 'foo', 'bar.foo', undefined, 0, 0, {}, 'string'); + let variable = new Variable(session, scope, 2, 'foo', 'bar.foo', undefined, 0, 0, {}, 'string'); let expression = $('.'); let name = $('.'); let value = $('.'); @@ -77,7 +77,7 @@ suite('Debug - Base Debug View', () => { assert.equal(name.textContent, 'foo:'); assert.equal(name.title, 'string'); - variable = new Variable(process, scope, 2, 'console', 'console', '5', 0, 0, { kind: 'virtual' }); + variable = new Variable(session, scope, 2, 'console', 'console', '5', 0, 0, { kind: 'virtual' }); expression = $('.'); name = $('.'); value = $('.'); diff --git a/src/vs/workbench/parts/debug/test/common/debugSource.test.ts b/src/vs/workbench/parts/debug/test/common/debugSource.test.ts index a2f305ffa68..fd2656f96a6 100644 --- a/src/vs/workbench/parts/debug/test/common/debugSource.test.ts +++ b/src/vs/workbench/parts/debug/test/common/debugSource.test.ts @@ -40,12 +40,12 @@ suite('Debug - Source', () => { }); test('get encoded debug data', () => { - const checkData = (uri: uri, expectedName, expectedPath, expectedSourceReference, expectedProcessId) => { - let { name, path, sourceReference, processId } = Source.getEncodedDebugData(uri); + const checkData = (uri: uri, expectedName, expectedPath, expectedSourceReference, expectedSessionId) => { + let { name, path, sourceReference, sessionId } = Source.getEncodedDebugData(uri); assert.equal(name, expectedName); assert.equal(path, expectedPath); assert.equal(sourceReference, expectedSourceReference); - assert.equal(processId, expectedProcessId); + assert.equal(sessionId, expectedSessionId); }; checkData(uri.file('a/b/c/d'), 'd', normalize('/a/b/c/d', true), undefined, undefined); diff --git a/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts b/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts index 76130ed7692..cf3492c4f34 100644 --- a/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts +++ b/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts @@ -5,7 +5,7 @@ import * as assert from 'assert'; import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel'; -import { StackFrame, Expression, Thread, Process } from 'vs/workbench/parts/debug/common/debugModel'; +import { StackFrame, Expression, Thread, Session } from 'vs/workbench/parts/debug/common/debugModel'; import { MockSession } from 'vs/workbench/parts/debug/test/common/mockDebug'; import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; @@ -24,14 +24,14 @@ suite('Debug - View Model', () => { assert.equal(model.focusedStackFrame, null); assert.equal(model.focusedThread, null); const mockSession = new MockSession(); - const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, mockSession); - const thread = new Thread(process, 'myThread', 1); + const session = new Session({ name: 'mockSession', type: 'node', request: 'launch' }, mockSession); + const thread = new Thread(session, 'myThread', 1); const frame = new StackFrame(thread, 1, null, 'app.js', 'normal', { startColumn: 1, startLineNumber: 1, endColumn: undefined, endLineNumber: undefined }, 0); - model.setFocus(frame, thread, process, false); + model.setFocus(frame, thread, session, false); assert.equal(model.focusedStackFrame.getId(), frame.getId()); assert.equal(model.focusedThread.threadId, 1); - assert.equal(model.focusedProcess.getId(), process.getId()); + assert.equal(model.focusedSession.getId(), session.getId()); }); test('selected expression', () => { @@ -42,9 +42,9 @@ suite('Debug - View Model', () => { assert.equal(model.getSelectedExpression(), expression); }); - test('multi process view and changed workbench state', () => { - assert.equal(model.isMultiProcessView(), false); - model.setMultiProcessView(true); - assert.equal(model.isMultiProcessView(), true); + test('multi session view and changed workbench state', () => { + assert.equal(model.isMultiSessionView(), false); + model.setMultiSessionView(true); + assert.equal(model.isMultiSessionView(), true); }); }); diff --git a/src/vs/workbench/parts/debug/test/common/mockDebug.ts b/src/vs/workbench/parts/debug/test/common/mockDebug.ts index a9fabb23c80..aaa7993b320 100644 --- a/src/vs/workbench/parts/debug/test/common/mockDebug.ts +++ b/src/vs/workbench/parts/debug/test/common/mockDebug.ts @@ -7,7 +7,7 @@ import uri from 'vs/base/common/uri'; import { Event, Emitter } from 'vs/base/common/event'; import { TPromise } from 'vs/base/common/winjs.base'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; -import { ILaunch, IDebugService, State, DebugEvent, IProcess, IConfigurationManager, IStackFrame, IBreakpointData, IBreakpointUpdateData, IConfig, IModel, IViewModel, ISession, IBreakpoint } from 'vs/workbench/parts/debug/common/debug'; +import { ILaunch, IDebugService, State, DebugEvent, ISession, IConfigurationManager, IStackFrame, IBreakpointData, IBreakpointUpdateData, IConfig, IModel, IViewModel, IRawSession, IBreakpoint } from 'vs/workbench/parts/debug/common/debug'; export class MockDebugService implements IDebugService { public _serviceBrand: any; @@ -20,11 +20,11 @@ export class MockDebugService implements IDebugService { return null; } - public get onDidNewProcess(): Event { + public get onDidNewSession(): Event { return null; } - public get onDidEndProcess(): Event { + public get onDidEndSession(): Event { return null; } @@ -89,11 +89,11 @@ export class MockDebugService implements IDebugService { return TPromise.as(null); } - public restartProcess(): TPromise { + public restartSession(): TPromise { return TPromise.as(null); } - public stopProcess(): TPromise { + public stopSession(): TPromise { return TPromise.as(null); } @@ -110,7 +110,7 @@ export class MockDebugService implements IDebugService { public sourceIsNotAvailable(uri: uri): void { } } -export class MockSession implements ISession { +export class MockSession implements IRawSession { public readyForBreakpoints = true; public emittedStopped = true; diff --git a/src/vs/workbench/parts/debug/test/node/debugModel.test.ts b/src/vs/workbench/parts/debug/test/node/debugModel.test.ts index 9ff21b98e39..7a42e119458 100644 --- a/src/vs/workbench/parts/debug/test/node/debugModel.test.ts +++ b/src/vs/workbench/parts/debug/test/node/debugModel.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import uri from 'vs/base/common/uri'; import severity from 'vs/base/common/severity'; -import { SimpleReplElement, Model, Process, Expression, RawObjectReplElement, StackFrame, Thread } from 'vs/workbench/parts/debug/common/debugModel'; +import { SimpleReplElement, Model, Session, Expression, RawObjectReplElement, StackFrame, Thread } from 'vs/workbench/parts/debug/common/debugModel'; import * as sinon from 'sinon'; import { MockSession } from 'vs/workbench/parts/debug/test/common/mockDebug'; @@ -116,8 +116,8 @@ suite('Debug - Model', () => { const threadId = 1; const threadName = 'firstThread'; - model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); - assert.equal(model.getProcesses().length, 1); + model.addSession({ name: 'mockSession', type: 'node', request: 'launch' }, rawSession); + assert.equal(model.getSessions().length, 1); model.rawUpdate({ sessionId: rawSession.getId(), threadId: threadId, @@ -126,15 +126,15 @@ suite('Debug - Model', () => { name: threadName } }); - const process = model.getProcesses().filter(p => p.getId() === rawSession.getId()).pop(); + const session = model.getSessions().filter(p => p.getId() === rawSession.getId()).pop(); - assert.equal(process.getThread(threadId).name, threadName); + assert.equal(session.getThread(threadId).name, threadName); - model.clearThreads(process.getId(), true); - assert.equal(process.getThread(threadId), null); - assert.equal(model.getProcesses().length, 1); - model.removeProcess(process.getId()); - assert.equal(model.getProcesses().length, 0); + model.clearThreads(session.getId(), true); + assert.equal(session.getThread(threadId), null); + assert.equal(model.getSessions().length, 1); + model.removeSession(session.getId()); + assert.equal(model.getSessions().length, 0); }); test('threads multiple wtih allThreadsStopped', () => { @@ -147,7 +147,7 @@ suite('Debug - Model', () => { const stoppedReason = 'breakpoint'; // Add the threads - model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); + model.addSession({ name: 'mockSession', type: 'node', request: 'launch' }, rawSession); model.rawUpdate({ sessionId: rawSession.getId(), threadId: threadId1, @@ -176,13 +176,13 @@ suite('Debug - Model', () => { allThreadsStopped: true }, }); - const process = model.getProcesses().filter(p => p.getId() === rawSession.getId()).pop(); + const session = model.getSessions().filter(p => p.getId() === rawSession.getId()).pop(); - const thread1 = process.getThread(threadId1); - const thread2 = process.getThread(threadId2); + const thread1 = session.getThread(threadId1); + const thread2 = session.getThread(threadId2); // at the beginning, callstacks are obtainable but not available - assert.equal(process.getAllThreads().length, 2); + assert.equal(session.getAllThreads().length, 2); assert.equal(thread1.name, threadName1); assert.equal(thread1.stopped, true); assert.equal(thread1.getCallStack().length, 0); @@ -223,10 +223,10 @@ suite('Debug - Model', () => { assert.equal(thread2.stopped, true); assert.equal(thread2.getCallStack().length, 0); - model.clearThreads(process.getId(), true); - assert.equal(process.getThread(threadId1), null); - assert.equal(process.getThread(threadId2), null); - assert.equal(process.getAllThreads().length, 0); + model.clearThreads(session.getId(), true); + assert.equal(session.getThread(threadId1), null); + assert.equal(session.getThread(threadId2), null); + assert.equal(session.getAllThreads().length, 0); }); test('threads mutltiple without allThreadsStopped', () => { @@ -237,7 +237,7 @@ suite('Debug - Model', () => { const runningThreadId = 2; const runningThreadName = 'runningThread'; const stoppedReason = 'breakpoint'; - model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); + model.addSession({ name: 'mockSession', type: 'node', request: 'launch' }, rawSession); // Add the threads model.rawUpdate({ sessionId: rawSession.getId(), @@ -267,16 +267,16 @@ suite('Debug - Model', () => { allThreadsStopped: false } }); - const process = model.getProcesses().filter(p => p.getId() === rawSession.getId()).pop(); + const session = model.getSessions().filter(p => p.getId() === rawSession.getId()).pop(); - const stoppedThread = process.getThread(stoppedThreadId); - const runningThread = process.getThread(runningThreadId); + const stoppedThread = session.getThread(stoppedThreadId); + const runningThread = session.getThread(runningThreadId); // the callstack for the stopped thread is obtainable but not available // the callstack for the running thread is not obtainable nor available assert.equal(stoppedThread.name, stoppedThreadName); assert.equal(stoppedThread.stopped, true); - assert.equal(process.getAllThreads().length, 2); + assert.equal(session.getAllThreads().length, 2); assert.equal(stoppedThread.getCallStack().length, 0); assert.equal(stoppedThread.stoppedDetails.reason, stoppedReason); assert.equal(runningThread.name, runningThreadName); @@ -305,10 +305,10 @@ suite('Debug - Model', () => { assert.equal(stoppedThread.stopped, true); assert.equal(stoppedThread.getCallStack().length, 0); - model.clearThreads(process.getId(), true); - assert.equal(process.getThread(stoppedThreadId), null); - assert.equal(process.getThread(runningThreadId), null); - assert.equal(process.getAllThreads().length, 0); + model.clearThreads(session.getId(), true); + assert.equal(session.getThread(stoppedThreadId), null); + assert.equal(session.getThread(runningThreadId), null); + assert.equal(session.getAllThreads().length, 0); }); // Expressions @@ -324,21 +324,18 @@ suite('Debug - Model', () => { test('watch expressions', () => { assert.equal(model.getWatchExpressions().length, 0); - const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); - const thread = new Thread(process, 'mockthread', 1); - const stackFrame = new StackFrame(thread, 1, null, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: undefined, endColumn: undefined }, 0); - model.addWatchExpression(process, stackFrame, 'console'); - model.addWatchExpression(process, stackFrame, 'console'); + model.addWatchExpression('console'); + model.addWatchExpression('console'); let watchExpressions = model.getWatchExpressions(); assertWatchExpressions(watchExpressions, 'console'); - model.renameWatchExpression(process, stackFrame, watchExpressions[0].getId(), 'new_name'); - model.renameWatchExpression(process, stackFrame, watchExpressions[1].getId(), 'new_name'); + model.renameWatchExpression(watchExpressions[0].getId(), 'new_name'); + model.renameWatchExpression(watchExpressions[1].getId(), 'new_name'); assertWatchExpressions(model.getWatchExpressions(), 'new_name'); assertWatchExpressions(model.getWatchExpressions(), 'new_name'); - model.addWatchExpression(process, stackFrame, 'mockExpression'); + model.addWatchExpression('mockExpression'); model.moveWatchExpression(model.getWatchExpressions()[2].getId(), 1); watchExpressions = model.getWatchExpressions(); assert.equal(watchExpressions[0].name, 'new_name'); @@ -351,12 +348,12 @@ suite('Debug - Model', () => { test('repl expressions', () => { assert.equal(model.getReplElements().length, 0); - const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); - const thread = new Thread(process, 'mockthread', 1); + const session = new Session({ name: 'mockSession', type: 'node', request: 'launch' }, rawSession); + const thread = new Thread(session, 'mockthread', 1); const stackFrame = new StackFrame(thread, 1, null, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 }, 1); - model.addReplExpression(process, stackFrame, 'myVariable').done(); - model.addReplExpression(process, stackFrame, 'myVariable').done(); - model.addReplExpression(process, stackFrame, 'myVariable').done(); + model.addReplExpression(session, stackFrame, 'myVariable').done(); + model.addReplExpression(session, stackFrame, 'myVariable').done(); + model.addReplExpression(session, stackFrame, 'myVariable').done(); assert.equal(model.getReplElements().length, 3); model.getReplElements().forEach(re => {