Skip to content

Commit

Permalink
Fix microsoft#12595: Opt out of process tree compacting
Browse files Browse the repository at this point in the history
Change IDebugService.startDebugging() to use DebugSessionOptions.

Use {noCompact: true} option for child sessions.
  • Loading branch information
int19h committed Jul 1, 2020
1 parent a6db5c0 commit 752f3c6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/client/common/application/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
DebugConsole,
DebugSession,
DebugSessionCustomEvent,
DebugSessionOptions,
Disposable,
Event,
WorkspaceFolder
Expand Down Expand Up @@ -57,9 +58,9 @@ export class DebugService implements IDebugService {
public startDebugging(
folder: WorkspaceFolder | undefined,
nameOrConfiguration: string | DebugConfiguration,
parentSession?: DebugSession
options?: DebugSessionOptions
): Thenable<boolean> {
return debug.startDebugging(folder, nameOrConfiguration, parentSession);
return debug.startDebugging(folder, nameOrConfiguration, options);
}
public addBreakpoints(breakpoints: Breakpoint[]): void {
debug.addBreakpoints(breakpoints);
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
DebugConsole,
DebugSession,
DebugSessionCustomEvent,
DebugSessionOptions,
DecorationRenderOptions,
Disposable,
DocumentSelector,
Expand Down Expand Up @@ -70,7 +71,6 @@ import type {
NotebookOutputSelector
} from 'vscode-proposed';
import * as vsls from 'vsls/vscode';

import { IAsyncDisposable, Resource } from '../types';
import { ICommandNameArgumentTypeMapping } from './commands';

Expand Down Expand Up @@ -927,7 +927,7 @@ export interface IDebugService {
startDebugging(
folder: WorkspaceFolder | undefined,
nameOrConfiguration: string | DebugConfiguration,
parentSession?: DebugSession
options?: DebugSessionOptions
): Thenable<boolean>;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/client/datascience/jupyterDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
DebugConsole,
DebugSession,
DebugSessionCustomEvent,
DebugSessionOptions,
Disposable,
Event,
EventEmitter,
Expand Down Expand Up @@ -167,7 +168,7 @@ export class JupyterDebugService implements IJupyterDebugService, IDisposable {
public startDebugging(
_folder: WorkspaceFolder | undefined,
nameOrConfiguration: string | DebugConfiguration,
_parentSession?: DebugSession | undefined
_options?: DebugSessionOptions
): Thenable<boolean> {
// Should have a port number. We'll assume it's local
const config = nameOrConfiguration as DebugConfiguration; // NOSONAR
Expand Down
5 changes: 3 additions & 2 deletions src/client/datascience/multiplexingDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DebugConsole,
DebugSession,
DebugSessionCustomEvent,
DebugSessionOptions,
Disposable,
Event,
EventEmitter,
Expand Down Expand Up @@ -106,10 +107,10 @@ export class MultiplexingDebugService implements IJupyterDebugService {
public startDebugging(
folder: WorkspaceFolder | undefined,
nameOrConfiguration: string | DebugConfiguration,
parentSession?: DebugSession | undefined
options?: DebugSessionOptions
): Thenable<boolean> {
this.lastStartedService = this.vscodeDebugService;
return this.vscodeDebugService.startDebugging(folder, nameOrConfiguration, parentSession);
return this.vscodeDebugService.startDebugging(folder, nameOrConfiguration, options);
}
public addBreakpoints(breakpoints: Breakpoint[]): void {
return this.activeService.addBreakpoints(breakpoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { inject, injectable } from 'inversify';
import { DebugConfiguration, DebugSession, WorkspaceFolder } from 'vscode';
import { DebugConfiguration, DebugSession, DebugSessionOptions, WorkspaceFolder } from 'vscode';
import { IApplicationShell, IDebugService, IWorkspaceService } from '../../../common/application/types';
import { noop } from '../../../common/utils/misc';
import { captureTelemetry } from '../../../telemetry';
Expand Down Expand Up @@ -32,7 +32,10 @@ export class ChildProcessAttachService implements IChildProcessAttachService {
const debugConfig: AttachRequestArguments & DebugConfiguration = data;
const processId = debugConfig.subProcessId!;
const folder = this.getRelatedWorkspaceFolder(debugConfig);
const launched = await this.debugService.startDebugging(folder, debugConfig, parentSession);
const launched = await this.debugService.startDebugging(folder, debugConfig, {
parentSession,
noCompact: true
} as DebugSessionOptions);
if (!launched) {
this.appShell.showErrorMessage(`Failed to launch debugger for child process ${processId}`).then(noop, noop);
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/datascience/mockDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DebugConsole,
DebugSession,
DebugSessionCustomEvent,
DebugSessionOptions,
Disposable,
Event,
WorkspaceFolder
Expand Down Expand Up @@ -72,9 +73,9 @@ export class MockDebuggerService implements IJupyterDebugService {
public startDebugging(
folder: WorkspaceFolder | undefined,
nameOrConfiguration: string | DebugConfiguration,
parentSession?: DebugSession | undefined
options?: DebugSessionOptions
): Thenable<boolean> {
return this.activeService.startDebugging(folder, nameOrConfiguration, parentSession);
return this.activeService.startDebugging(folder, nameOrConfiguration, options);
}
public addBreakpoints(breakpoints: Breakpoint[]): void {
return this.activeService.addBreakpoints(breakpoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ suite('Debug - Attach to Child Process', () => {
verify(debugService.startDebugging(undefined, anything(), anything())).once();
const [, secondArg, thirdArg] = capture(debugService.startDebugging).last();
expect(secondArg).to.deep.equal(debugConfig);
expect(thirdArg).to.deep.equal(session);
expect(thirdArg)
.to.have.property('parentSession', session)
.and.have.property('noCompact', true, 'Sessions must not be compacted');
verify(shell.showErrorMessage(anything())).never();
});
test('Pass data as is if data is attach debug configuration', async () => {
Expand All @@ -165,7 +167,9 @@ suite('Debug - Attach to Child Process', () => {
verify(debugService.startDebugging(undefined, anything(), anything())).once();
const [, secondArg, thirdArg] = capture(debugService.startDebugging).last();
expect(secondArg).to.deep.equal(debugConfig);
expect(thirdArg).to.deep.equal(session);
expect(thirdArg)
.to.have.property('parentSession', session)
.and.have.property('noCompact', true, 'Sessions must not be compacted');
verify(shell.showErrorMessage(anything())).never();
});
test('Validate debug config when parent/root parent was attached', async () => {
Expand Down Expand Up @@ -193,7 +197,9 @@ suite('Debug - Attach to Child Process', () => {
verify(debugService.startDebugging(undefined, anything(), anything())).once();
const [, secondArg, thirdArg] = capture(debugService.startDebugging).last();
expect(secondArg).to.deep.equal(debugConfig);
expect(thirdArg).to.deep.equal(session);
expect(thirdArg)
.to.have.property('parentSession', session)
.and.have.property('noCompact', true, 'Sessions must not be compacted');
verify(shell.showErrorMessage(anything())).never();
});
});

0 comments on commit 752f3c6

Please sign in to comment.