Setup pty host debug target

This commit is contained in:
Daniel Imms 2021-09-20 15:26:21 -07:00
parent 960d1a6ac7
commit b5d1c0b987
6 changed files with 46 additions and 16 deletions

9
.vscode/launch.json vendored
View file

@ -47,6 +47,15 @@
"${workspaceFolder}/out/**/*.js"
]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Pty Host Process",
"port": 5877,
"outFiles": [
"${workspaceFolder}/out/**/*.js"
]
},
{
"type": "node",
"request": "attach",

View file

@ -284,6 +284,7 @@ class SharedProcessMain extends Disposable {
scrollback: configurationService.getValue<number>(TerminalSettingId.PersistentSessionScrollback) ?? 100
},
configurationService,
environmentService,
logService,
telemetryService
)

View file

@ -49,6 +49,8 @@ export interface NativeParsedArgs {
debugRenderer?: boolean; // whether we expect a debugger (js-debug) to attach to the renderer, incl webviews+webworker
'inspect-search'?: string;
'inspect-brk-search'?: string;
'inspect-ptyhost'?: string;
'inspect-brk-ptyhost'?: string;
'disable-extensions'?: boolean;
'disable-extension'?: string[]; // undefined or array of 1 or more
'list-extensions'?: boolean;

View file

@ -251,6 +251,10 @@ export function parseSearchPort(args: NativeParsedArgs, isBuild: boolean): IDebu
return parseDebugPort(args['inspect-search'], args['inspect-brk-search'], 5876, isBuild);
}
export function parsePtyHostPort(args: NativeParsedArgs, isBuild: boolean): IDebugParams {
return parseDebugPort(args['inspect-ptyhost'], args['inspect-brk-ptyhost'], 5877, isBuild);
}
function parseDebugPort(debugArg: string | undefined, debugBrkArg: string | undefined, defaultBuildPort: number, isBuild: boolean, debugId?: string): IExtensionHostDebugParams {
const portStr = debugBrkArg || debugArg;
const port = Number(portStr) || (!isBuild ? defaultBuildPort : null);

View file

@ -88,6 +88,8 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
'extensionTestsPath': { type: 'string' },
'debugId': { type: 'string' },
'debugRenderer': { type: 'boolean' },
'inspect-ptyhost': { type: 'string' },
'inspect-brk-ptyhost': { type: 'string' },
'inspect-search': { type: 'string', deprecates: 'debugSearch' },
'inspect-brk-search': { type: 'string', deprecates: 'debugBrkSearch' },
'export-default-configuration': { type: 'string' },

View file

@ -8,8 +8,10 @@ import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { FileAccess } from 'vs/base/common/network';
import { IProcessEnvironment, isWindows, OperatingSystem } from 'vs/base/common/platform';
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
import { Client, IIPCOptions } from 'vs/base/parts/ipc/node/ipc.cp';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
import { parsePtyHostPort } from 'vs/platform/environment/common/environmentService';
import { resolveShellEnv } from 'vs/platform/environment/node/shellEnv';
import { ILogService } from 'vs/platform/log/common/log';
import { LogLevelChannelClient } from 'vs/platform/log/common/logIpc';
@ -89,6 +91,7 @@ export class PtyHostService extends Disposable implements IPtyService {
constructor(
private readonly _reconnectConstants: IReconnectConstants,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IEnvironmentService private readonly _environmentService: INativeEnvironmentService,
@ILogService private readonly _logService: ILogService,
@ITelemetryService private readonly _telemetryService: ITelemetryService
) {
@ -109,22 +112,31 @@ export class PtyHostService extends Disposable implements IPtyService {
}
private _startPtyHost(): [Client, IPtyService] {
const client = new Client(
FileAccess.asFileUri('bootstrap-fork', require).fsPath,
{
serverName: 'Pty Host',
args: ['--type=ptyHost'],
env: {
VSCODE_LAST_PTY_ID: lastPtyId,
VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain',
VSCODE_PIPE_LOGGING: 'true',
VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client,
VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.graceTime,
VSCODE_RECONNECT_SHORT_GRACE_TIME: this._reconnectConstants.shortGraceTime,
VSCODE_RECONNECT_SCROLLBACK: this._reconnectConstants.scrollback
}
const opts: IIPCOptions = {
serverName: 'Pty Host',
args: ['--type=ptyHost'],
env: {
VSCODE_LAST_PTY_ID: lastPtyId,
VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain',
VSCODE_PIPE_LOGGING: 'true',
VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client,
VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.graceTime,
VSCODE_RECONNECT_SHORT_GRACE_TIME: this._reconnectConstants.shortGraceTime,
VSCODE_RECONNECT_SCROLLBACK: this._reconnectConstants.scrollback
}
);
};
const ptyHostDebug = parsePtyHostPort(this._environmentService.args, this._environmentService.isBuilt);
console.log('ptyHostDebug', ptyHostDebug.port, ptyHostDebug.break);
if (ptyHostDebug) {
if (ptyHostDebug.break && ptyHostDebug.port) {
opts.debugBrk = ptyHostDebug.port;
} else if (!ptyHostDebug.break && ptyHostDebug.port) {
opts.debug = ptyHostDebug.port;
}
}
const client = new Client(FileAccess.asFileUri('bootstrap-fork', require).fsPath, opts);
this._onPtyHostStart.fire();
// Setup heartbeat service and trigger a heartbeat immediately to reset the timeouts