Skip to content

Commit 19d8a08

Browse files
authored
Switch over to the new debugger (microsoft#2073)
Fixes microsoft#2063
1 parent 66e3c18 commit 19d8a08

27 files changed

Lines changed: 825 additions & 1472 deletions

.vscode/launch.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,7 @@
1919
"preLaunchTask": "Compile"
2020
},
2121
{
22-
"name": "Launch Extension as debugServer", // https://code.visualstudio.com/docs/extensions/example-debuggers
23-
"type": "node",
24-
"request": "launch",
25-
"program": "${workspaceFolder}/out/client/debugger/Main.js",
26-
"stopOnEntry": false,
27-
"smartStep": true,
28-
"args": [
29-
"--server=4711"
30-
],
31-
"sourceMaps": true,
32-
"outFiles": [
33-
"${workspaceFolder}/out/client/**/*.js"
34-
],
35-
"cwd": "${workspaceFolder}",
36-
"preLaunchTask": "Compile"
37-
},
38-
{
39-
"name": "Launch Experimental Debugger as debugServer", // https://code.visualstudio.com/docs/extensions/example-debuggers
22+
"name": "Launch Debugger as debugServer", // https://code.visualstudio.com/docs/extensions/example-debuggers
4023
"type": "node",
4124
"request": "launch",
4225
"program": "${workspaceFolder}/out/client/debugger/mainV2.js",

package.json

Lines changed: 33 additions & 499 deletions
Large diffs are not rendered by default.

src/client/common/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ export interface IUnitTestSettings {
152152
readonly unittestEnabled: boolean;
153153
unittestArgs: string[];
154154
cwd?: string;
155-
readonly useExperimentalDebugger?: boolean;
156155
readonly autoTestDiscoverOnSaveEnabled: boolean;
157156
}
158157
export interface IPylintCategorySeverity {

src/client/debugger/Common/Contracts.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import * as net from 'net';
66
import { OutputEvent } from 'vscode-debugadapter';
77
import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol';
88
import { DebuggerPerformanceTelemetry, DebuggerTelemetry } from '../../telemetry/types';
9-
import { ExperimentalDebuggerType } from './constants';
9+
import { DebuggerTypeName } from './constants';
1010

11+
export type DebuggerType = typeof DebuggerTypeName;
1112
export class TelemetryEvent extends OutputEvent {
1213
body!: {
1314
/** The category of output (such as: 'console', 'stdout', 'stderr', 'telemetry'). If not specified, 'console' is assumed. */
@@ -51,8 +52,6 @@ export interface ExceptionHandling {
5152
unhandled: string[];
5253
}
5354

54-
export type DebuggerType = 'python' | typeof ExperimentalDebuggerType;
55-
5655
export interface AdditionalLaunchDebugOptions {
5756
redirectOutput?: boolean;
5857
django?: boolean;
@@ -72,7 +71,7 @@ export interface AdditionalAttachDebugOptions {
7271
}
7372

7473
export interface BaseLaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
75-
type?: DebuggerType;
74+
type?: typeof DebuggerTypeName;
7675
/** An absolute path to the program to debug. */
7776
module?: string;
7877
program?: string;
@@ -98,7 +97,7 @@ export interface LaunchRequestArguments extends BaseLaunchRequestArguments, Addi
9897
}
9998

10099
export interface BaseAttachRequestArguments extends DebugProtocol.AttachRequestArguments {
101-
type?: DebuggerType;
100+
type?: typeof DebuggerTypeName;
102101
/** An absolute path to local directory with source. */
103102
port?: number;
104103
host?: string;

src/client/debugger/Common/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import * as path from 'path';
77
import { EXTENSION_ROOT_DIR } from '../../common/constants';
88

99
export const PTVSD_PATH = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'experimental', 'ptvsd');
10-
export const ExperimentalDebuggerType = 'pythonExperimental';
10+
export const DebuggerTypeName = 'python';

src/client/debugger/DebugClients/DebugFactory.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { DebugClient } from './DebugClient';
55
import { DebuggerLauncherScriptProvider, NoDebugLauncherScriptProvider } from './launcherProvider';
66
import { LocalDebugClient } from './LocalDebugClient';
77
import { LocalDebugClientV2 } from './localDebugClientV2';
8-
import { NonDebugClient } from './NonDebugClient';
98
import { NonDebugClientV2 } from './nonDebugClientV2';
109
import { RemoteDebugClient } from './RemoteDebugClient';
1110

@@ -14,10 +13,10 @@ export function CreateLaunchDebugClient(launchRequestOptions: LaunchRequestArgum
1413
let debugClientClass: typeof LocalDebugClient;
1514
if (launchRequestOptions.noDebug === true) {
1615
launchScriptProvider = new NoDebugLauncherScriptProvider();
17-
debugClientClass = launchRequestOptions.type === 'pythonExperimental' ? NonDebugClientV2 : NonDebugClient;
16+
debugClientClass = NonDebugClientV2;
1817
} else {
1918
launchScriptProvider = new DebuggerLauncherScriptProvider();
20-
debugClientClass = launchRequestOptions.type === 'pythonExperimental' ? LocalDebugClientV2 : LocalDebugClient;
19+
debugClientClass = LocalDebugClientV2;
2120
}
2221
return new debugClientClass(launchRequestOptions, debugSession, canLaunchTerminal, launchScriptProvider);
2322
}

src/client/debugger/DebugClients/LocalDebugClient.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import { PTVSD_PATH } from '../Common/constants';
1111
import { DebugOptions, IDebugServer, IPythonProcess, LaunchRequestArguments } from '../Common/Contracts';
1212
import { IS_WINDOWS } from '../Common/Utils';
1313
import { BaseDebugServer } from '../DebugServers/BaseDebugServer';
14-
import { LocalDebugServer } from '../DebugServers/LocalDebugServer';
1514
import { LocalDebugServerV2 } from '../DebugServers/LocalDebugServerV2';
1615
import { IDebugLauncherScriptProvider } from '../types';
1716
import { DebugClient, DebugType } from './DebugClient';
1817
import { DebugClientHelper } from './helper';
18+
import { noop } from '../../common/core.utils';
1919

2020
const VALID_DEBUG_OPTIONS = [
2121
'RedirectOutput',
@@ -48,14 +48,8 @@ export class LocalDebugClient extends DebugClient<LaunchRequestArguments> {
4848
super(args, debugSession);
4949
}
5050

51-
public CreateDebugServer(pythonProcess?: IPythonProcess, serviceContainer?: IServiceContainer): BaseDebugServer {
52-
if (this.args.type === 'pythonExperimental') {
53-
this.debugServer = new LocalDebugServerV2(this.debugSession, this.args, serviceContainer!);
54-
} else {
55-
this.pythonProcess = pythonProcess!;
56-
this.debugServer = new LocalDebugServer(this.debugSession, this.pythonProcess!, this.args);
57-
}
58-
return this.debugServer;
51+
public CreateDebugServer(_pythonProcess?: IPythonProcess, serviceContainer?: IServiceContainer): BaseDebugServer {
52+
return new LocalDebugServerV2(this.debugSession, this.args, serviceContainer!);
5953
}
6054

6155
public get DebugType(): DebugType {
@@ -86,10 +80,8 @@ export class LocalDebugClient extends DebugClient<LaunchRequestArguments> {
8680
const environmentVariablesService = new EnvironmentVariablesService(pathUtils);
8781
const helper = new DebugClientHelper(environmentVariablesService, pathUtils, currentProcess);
8882
const environmentVariables = await helper.getEnvironmentVariables(this.args);
89-
if (this.args.type === 'pythonExperimental') {
90-
// Import the PTVSD debugger, allowing users to use their own latest copies.
91-
environmentVariablesService.appendPythonPath(environmentVariables, PTVSD_PATH);
92-
}
83+
// Import the PTVSD debugger, allowing users to use their own latest copies.
84+
environmentVariablesService.appendPythonPath(environmentVariables, PTVSD_PATH);
9385
// tslint:disable-next-line:max-func-body-length cyclomatic-complexity no-any
9486
return new Promise<any>((resolve, reject) => {
9587
const fileDir = this.args && this.args.program ? path.dirname(this.args.program) : '';
@@ -138,19 +130,7 @@ export class LocalDebugClient extends DebugClient<LaunchRequestArguments> {
138130
this.displayError(error);
139131
});
140132
proc.stderr.setEncoding('utf8');
141-
proc.stderr.on('data', error => {
142-
if (this.args.type === 'pythonExperimental') {
143-
return;
144-
}
145-
// We generally don't need to display the errors as stderr output is being captured by debugger
146-
// and it gets sent out to the debug client.
147-
148-
// Either way, we need some code in here so we read the stdout of the python process,
149-
// Else it just keep building up (related to issue #203 and #52).
150-
if (this.debugServerStatus === DebugServerStatus.NotRunning) {
151-
return failedToLaunch(error);
152-
}
153-
});
133+
proc.stderr.on('data', noop);
154134
proc.stdout.on('data', d => {
155135
// This is necessary so we read the stdout of the python process,
156136
// Else it just keep building up (related to issue #203 and #52).

src/client/debugger/DebugClients/RemoteDebugClient.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { DebugSession } from 'vscode-debugadapter';
2-
import { AttachRequestArgumentsV1, BaseAttachRequestArguments, IPythonProcess } from '../Common/Contracts';
2+
import { BaseAttachRequestArguments, IPythonProcess } from '../Common/Contracts';
33
import { BaseDebugServer } from '../DebugServers/BaseDebugServer';
4-
import { RemoteDebugServer } from '../DebugServers/RemoteDebugServer';
54
import { RemoteDebugServerV2 } from '../DebugServers/RemoteDebugServerv2';
65
import { DebugClient, DebugType } from './DebugClient';
76

@@ -13,15 +12,9 @@ export class RemoteDebugClient<T extends BaseAttachRequestArguments> extends Deb
1312
super(args, debugSession);
1413
}
1514

16-
public CreateDebugServer(pythonProcess?: IPythonProcess): BaseDebugServer {
17-
if (this.args.type === 'pythonExperimental') {
18-
// tslint:disable-next-line:no-any
19-
this.debugServer = new RemoteDebugServerV2(this.debugSession, undefined as any, this.args);
20-
} else {
21-
this.pythonProcess = pythonProcess!;
22-
this.debugServer = new RemoteDebugServer(this.debugSession, this.pythonProcess!, this.args as {} as AttachRequestArgumentsV1);
23-
}
24-
return this.debugServer!;
15+
public CreateDebugServer(_pythonProcess?: IPythonProcess): BaseDebugServer {
16+
// tslint:disable-next-line:no-any
17+
return new RemoteDebugServerV2(this.debugSession, undefined as any, this.args);
2518
}
2619
public get DebugType(): DebugType {
2720
return DebugType.Remote;

src/client/debugger/banner.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import '../common/extensions';
1111
import { IBrowserService, IDisposableRegistry, IExperimentalDebuggerBanner,
1212
ILogger, IPersistentStateFactory } from '../common/types';
1313
import { IServiceContainer } from '../ioc/types';
14-
import { ExperimentalDebuggerType } from './Common/constants';
14+
import { DebuggerTypeName } from './Common/constants';
15+
import { IExperimentalDebuggerBanner } from './types';
1516

1617
export enum PersistentStateKeys {
1718
ShowBanner = 'ShowBanner',
@@ -40,7 +41,7 @@ export class ExperimentalDebuggerBanner implements IExperimentalDebuggerBanner {
4041
}
4142
const debuggerService = this.serviceContainer.get<IDebugService>(IDebugService);
4243
const disposable = debuggerService.onDidTerminateDebugSession(async e => {
43-
if (e.type === ExperimentalDebuggerType) {
44+
if (e.type === DebuggerTypeName) {
4445
const logger = this.serviceContainer.get<ILogger>(ILogger);
4546
await this.onDidTerminateDebugSession()
4647
.catch(ex => logger.logError('Error in debugger Banner', ex));
@@ -53,7 +54,7 @@ export class ExperimentalDebuggerBanner implements IExperimentalDebuggerBanner {
5354
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
5455
const yes = 'Yes, take survey now';
5556
const no = 'No thanks';
56-
const response = await appShell.showInformationMessage('Can you please take 2 minutes to tell us how the Experimental Debugger is working for you?', yes, no);
57+
const response = await appShell.showInformationMessage('Can you please take 2 minutes to tell us how the Debugger is working for you?', yes, no);
5758
switch (response) {
5859
case yes:
5960
{

src/client/debugger/configProviders/pythonProvider.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)