Merge from vscode 9bc92b48d945144abb405b9e8df05e18accb9148

This commit is contained in:
ADS Merger
2020-02-19 03:11:35 +00:00
parent 98584d32a7
commit 1e308639e5
253 changed files with 6414 additions and 2296 deletions

View File

@@ -117,7 +117,6 @@ export class DebugService implements IDebugService {
this.model = new DebugModel(this.loadBreakpoints(), this.loadFunctionBreakpoints(),
this.loadExceptionBreakpoints(), this.loadDataBreakpoints(), this.loadWatchExpressions(), this.textFileService);
this.toDispose.push(this.model);
const setBreakpointsExistContext = () => this.breakpointsExist.set(!!(this.model.getBreakpoints().length || this.model.getDataBreakpoints().length || this.model.getFunctionBreakpoints().length));
this.breakpointsExist = CONTEXT_BREAKPOINTS_EXIST.bindTo(contextKeyService);
setBreakpointsExistContext();
@@ -125,8 +124,8 @@ export class DebugService implements IDebugService {
this.viewModel = new ViewModel(contextKeyService);
this.taskRunner = this.instantiationService.createInstance(DebugTaskRunner);
this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this.lifecycleService.onShutdown(this.dispose, this);
this.toDispose.push(this.fileService.onDidFilesChange(e => this.onFileChanges(e)));
this.toDispose.push(this.lifecycleService.onShutdown(this.dispose, this));
this.toDispose.push(this.extensionHostDebugService.onAttachSession(event => {
const session = this.model.getSession(event.sessionId, true);
@@ -522,7 +521,6 @@ export class DebugService implements IDebugService {
await this.focusStackFrame(undefined, undefined, session);
}
} catch (err) {
session.shutdown();
if (this.viewModel.focusedSession === session) {
await this.focusStackFrame(undefined);
}
@@ -567,7 +565,6 @@ export class DebugService implements IDebugService {
this.notificationService.error(err);
}
}
session.shutdown();
this.endInitializingState();
this._onDidEndSession.fire(session);

View File

@@ -33,6 +33,7 @@ import { variableSetEmitter } from 'vs/workbench/contrib/debug/browser/variables
import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation';
import { distinct } from 'vs/base/common/arrays';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
export class DebugSession implements IDebugSession {
@@ -74,7 +75,8 @@ export class DebugSession implements IDebugSession {
@IProductService private readonly productService: IProductService,
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
@IOpenerService private readonly openerService: IOpenerService,
@INotificationService private readonly notificationService: INotificationService
@INotificationService private readonly notificationService: INotificationService,
@ILifecycleService lifecycleService: ILifecycleService
) {
this.id = generateUuid();
this._options = options || {};
@@ -83,7 +85,15 @@ export class DebugSession implements IDebugSession {
} else {
this.repl = (this.parentSession as DebugSession).repl;
}
this.repl.onDidChangeElements(() => this._onDidChangeREPLElements.fire());
const toDispose: IDisposable[] = [];
toDispose.push(this.repl.onDidChangeElements(() => this._onDidChangeREPLElements.fire()));
if (lifecycleService) {
toDispose.push(lifecycleService.onShutdown(() => {
this.shutdown();
dispose(toDispose);
}));
}
}
getId(): string {
@@ -213,6 +223,7 @@ export class DebugSession implements IDebugSession {
} catch (err) {
this.initialized = true;
this._onDidChangeState.fire();
this.shutdown();
throw err;
}
}
@@ -227,8 +238,12 @@ export class DebugSession implements IDebugSession {
// __sessionID only used for EH debugging (but we add it always for now...)
config.__sessionId = this.getId();
await this.raw.launchOrAttach(config);
try {
await this.raw.launchOrAttach(config);
} catch (err) {
this.shutdown();
throw err;
}
}
/**
@@ -892,19 +907,22 @@ export class DebugSession implements IDebugSession {
this.rawListeners.push(this.raw.onDidExitAdapter(event => {
this.initialized = true;
this.model.setBreakpointSessionData(this.getId(), this.capabilities, undefined);
this.shutdown();
this._onDidEndAdapter.fire(event);
}));
}
shutdown(): void {
// Disconnects and clears state. Session can be initialized again for a new connection.
private shutdown(): void {
dispose(this.rawListeners);
if (this.raw) {
this.raw.disconnect();
this.raw.dispose();
}
this.raw = undefined;
this.fetchThreadsScheduler = undefined;
this.model.clearThreads(this.getId(), true);
if (this.raw) {
const raw = this.raw;
this.raw = undefined;
raw.disconnect();
raw.dispose();
}
this._onDidChangeState.fire();
}

View File

@@ -270,7 +270,7 @@ export class RawDebugSession implements IDisposable {
if (this.capabilities.supportsTerminateRequest) {
if (!this.terminated) {
this.terminated = true;
return this.send('terminate', { restart });
return this.send('terminate', { restart }, undefined, 500);
}
return this.disconnect(restart);
}

View File

@@ -200,9 +200,6 @@ export interface IDebugSession extends ITreeElement {
readonly onDidLoadedSource: Event<LoadedSourceEvent>;
readonly onDidCustomEvent: Event<DebugProtocol.Event>;
// Disconnects and clears state. Session can be initialized again for a new connection.
shutdown(): void;
// DAP request
initialize(dbgr: IDebugger): Promise<void>;

View File

@@ -6,7 +6,6 @@
import * as nls from 'vs/nls';
import { URI as uri } from 'vs/base/common/uri';
import * as resources from 'vs/base/common/resources';
import * as lifecycle from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import { generateUuid } from 'vs/base/common/uuid';
import { RunOnceScheduler } from 'vs/base/common/async';
@@ -819,7 +818,6 @@ export class ThreadAndSessionIds implements ITreeElement {
export class DebugModel implements IDebugModel {
private sessions: IDebugSession[];
private toDispose: lifecycle.IDisposable[];
private schedulers = new Map<string, RunOnceScheduler>();
private breakpointsActivated = true;
private readonly _onDidChangeBreakpoints = new Emitter<IBreakpointsChangeEvent | undefined>();
@@ -835,7 +833,6 @@ export class DebugModel implements IDebugModel {
private textFileService: ITextFileService
) {
this.sessions = [];
this.toDispose = [];
}
getId(): string {
@@ -1227,10 +1224,4 @@ export class DebugModel implements IDebugModel {
});
this._onDidChangeCallStack.fire(undefined);
}
dispose(): void {
// Make sure to shutdown each session, such that no debugged process is left laying around
this.sessions.forEach(s => s.shutdown());
this.toDispose = lifecycle.dispose(this.toDispose);
}
}

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/** Declaration module describing the VS Code debug protocol.
Auto-generated from json schema. Do not edit manually.
*/
@@ -98,7 +99,7 @@ declare module DebugProtocol {
The sequence of events/requests is as follows:
- adapters sends 'initialized' event (after the 'initialize' request has returned)
- frontend sends zero or more 'setBreakpoints' requests
- frontend sends one 'setFunctionBreakpoints' request
- frontend sends one 'setFunctionBreakpoints' request (if capability 'supportsFunctionBreakpoints' is true)
- frontend sends a 'setExceptionBreakpoints' request if one or more 'exceptionBreakpointFilters' have been defined (or if 'supportsConfigurationDoneRequest' is not defined or false)
- frontend sends other future configuration requests
- frontend sends one 'configurationDone' request to indicate the end of the configuration.
@@ -201,6 +202,15 @@ declare module DebugProtocol {
category?: string;
/** The output to report. */
output: string;
/** Support for keeping an output log organized by grouping related messages.
'start': Start a new group in expanded mode. Subsequent output events are members of the group and should be shown indented.
The 'output' attribute becomes the name of the group and is not indented.
'startCollapsed': Start a new group in collapsed mode. Subsequent output events are members of the group and should be shown indented (as soon as the group is expanded).
The 'output' attribute becomes the name of the group and is not indented.
'end': End the current group and decreases the indentation of subsequent output events.
A non empty 'output' attribute is shown as the unindented end of the group.
*/
group?: 'start' | 'startCollapsed' | 'end';
/** If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request. The value should be less than or equal to 2147483647 (2^31 - 1). */
variablesReference?: number;
/** An optional source location where the output was produced. */

View File

@@ -19,7 +19,7 @@ import { OverviewRulerLane } from 'vs/editor/common/model';
import { MarkdownString } from 'vs/base/common/htmlContent';
function createMockSession(model: DebugModel, name = 'mockSession', options?: IDebugSessionOptions): DebugSession {
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, options, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!);
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, options, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!, undefined!);
}
function addBreakpointsAndCheckEvents(model: DebugModel, uri: uri, data: IBreakpointData[]): void {

View File

@@ -18,7 +18,7 @@ import { getContext, getContextForContributedActions } from 'vs/workbench/contri
import { getStackFrameThreadAndSessionToFocus } from 'vs/workbench/contrib/debug/browser/debugService';
export function createMockSession(model: DebugModel, name = 'mockSession', options?: IDebugSessionOptions): DebugSession {
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, options, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!);
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, options, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!, undefined!);
}
function createTwoStackFrames(session: DebugSession): { firstStackFrame: StackFrame, secondStackFrame: StackFrame } {
@@ -363,7 +363,7 @@ suite('Debug - CallStack', () => {
get state(): State {
return State.Stopped;
}
}({ resolved: { name: 'stoppedSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!);
}({ resolved: { name: 'stoppedSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!, undefined!);
const runningSession = createMockSession(model);
model.addSession(runningSession);

View File

@@ -327,8 +327,6 @@ export class MockSession implements IDebugSession {
goto(threadId: number, targetId: number): Promise<DebugProtocol.GotoResponse> {
throw new Error('Method not implemented.');
}
shutdown(): void { }
}
export class MockRawSession {

View File

@@ -30,7 +30,7 @@ suite.skip('Debug - ANSI Handling', () => {
*/
setup(() => {
model = new DebugModel([], [], [], [], [], <any>{ isDirty: (e: any) => false });
session = new DebugSession({ resolved: { name: 'test', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!);
session = new DebugSession({ resolved: { name: 'test', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService, undefined!, undefined!);
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService();
linkDetector = instantiationService.createInstance(LinkDetector);