提交 0f731a79 编写于 作者: I isidor

pass on --debugId from extension host to debug

fixes #30698
上级 ed98fcab
......@@ -518,6 +518,7 @@ export class CodeWindow implements ICodeWindow {
configuration.verbose = cli.verbose;
configuration.debugPluginHost = cli.debugPluginHost;
configuration.debugBrkPluginHost = cli.debugBrkPluginHost;
configuration.debugId = cli.debugId;
configuration['extensions-dir'] = cli['extensions-dir'];
}
......
......@@ -1007,6 +1007,7 @@ export class WindowsManager implements IWindowsMainService {
configuration.extensionDevelopmentPath = currentWindowConfig.extensionDevelopmentPath;
configuration.verbose = currentWindowConfig.verbose;
configuration.debugBrkPluginHost = currentWindowConfig.debugBrkPluginHost;
configuration.debugId = currentWindowConfig.debugId;
configuration.debugPluginHost = currentWindowConfig.debugPluginHost;
configuration['extensions-dir'] = currentWindowConfig['extensions-dir'];
}
......
......@@ -31,6 +31,7 @@ export interface ParsedArgs {
extensionDevelopmentPath?: string;
extensionTestsPath?: string;
debugBrkPluginHost?: string;
debugId?: string;
debugPluginHost?: string;
'list-extensions'?: boolean;
'show-versions'?: boolean;
......@@ -71,7 +72,8 @@ export interface IEnvironmentService {
extensionDevelopmentPath: string;
extensionTestsPath: string;
debugExtensionHost: { port: number; break: boolean; };
debugExtensionHost: { port: number; break: boolean; debugId: string };
logExtensionHostCommunication: boolean;
......
......@@ -20,6 +20,7 @@ const options: minimist.Opts = {
'install-extension',
'uninstall-extension',
'debugBrkPluginHost',
'debugId',
'debugPluginHost',
'open-url',
'enable-proposed-api'
......
......@@ -109,7 +109,7 @@ export class EnvironmentService implements IEnvironmentService {
get skipGettingStarted(): boolean { return this._args['skip-getting-started']; }
@memoize
get debugExtensionHost(): { port: number; break: boolean; } { return parseExtensionHostPort(this._args, this.isBuilt); }
get debugExtensionHost(): { port: number; break: boolean; debugId: string } { return parseExtensionHostPort(this._args, this.isBuilt); }
get isBuilt(): boolean { return !process.env['VSCODE_DEV']; }
get verbose(): boolean { return this._args.verbose; }
......@@ -142,11 +142,11 @@ export class EnvironmentService implements IEnvironmentService {
constructor(private _args: ParsedArgs, private _execPath: string) { }
}
export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): { port: number; break: boolean; } {
export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): { port: number; break: boolean; debugId: string } {
const portStr = args.debugBrkPluginHost || args.debugPluginHost;
const port = Number(portStr) || (!isBuild ? 5870 : null);
const brk = port ? Boolean(!!args.debugBrkPluginHost) : false;
return { port, break: brk };
return { port, break: brk, debugId: args.debugId };
}
function parsePathArg(arg: string, process: NodeJS.Process): string {
......
......@@ -14,23 +14,23 @@ suite('EnvironmentService', () => {
test('parseExtensionHostPort when built', () => {
const parse = a => parseExtensionHostPort(parseArgs(a), true);
assert.deepEqual(parse([]), { port: null, break: false });
assert.deepEqual(parse(['--debugPluginHost']), { port: null, break: false });
assert.deepEqual(parse(['--debugPluginHost=1234']), { port: 1234, break: false });
assert.deepEqual(parse(['--debugBrkPluginHost']), { port: null, break: false });
assert.deepEqual(parse(['--debugBrkPluginHost=5678']), { port: 5678, break: true });
assert.deepEqual(parse(['--debugPluginHost=1234', '--debugBrkPluginHost=5678']), { port: 5678, break: true });
assert.deepEqual(parse([]), { port: null, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugPluginHost']), { port: null, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugPluginHost=1234']), { port: 1234, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugBrkPluginHost']), { port: null, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugBrkPluginHost=5678']), { port: 5678, break: true, debugId: undefined });
assert.deepEqual(parse(['--debugPluginHost=1234', '--debugBrkPluginHost=5678', '--debugId=7']), { port: 5678, break: true, debugId: '7' });
});
test('parseExtensionHostPort when unbuilt', () => {
const parse = a => parseExtensionHostPort(parseArgs(a), false);
assert.deepEqual(parse([]), { port: 5870, break: false });
assert.deepEqual(parse(['--debugPluginHost']), { port: 5870, break: false });
assert.deepEqual(parse(['--debugPluginHost=1234']), { port: 1234, break: false });
assert.deepEqual(parse(['--debugBrkPluginHost']), { port: 5870, break: false });
assert.deepEqual(parse(['--debugBrkPluginHost=5678']), { port: 5678, break: true });
assert.deepEqual(parse(['--debugPluginHost=1234', '--debugBrkPluginHost=5678']), { port: 5678, break: true });
assert.deepEqual(parse([]), { port: 5870, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugPluginHost']), { port: 5870, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugPluginHost=1234']), { port: 1234, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugBrkPluginHost']), { port: 5870, break: false, debugId: undefined });
assert.deepEqual(parse(['--debugBrkPluginHost=5678']), { port: 5678, break: true, debugId: undefined });
assert.deepEqual(parse(['--debugPluginHost=1234', '--debugBrkPluginHost=5678', '--debugId=7']), { port: 5678, break: true, debugId: '7' });
});
test('userDataPath', () => {
......
......@@ -202,7 +202,10 @@ export class ExtensionHostProcessWorker {
if (this.isExtensionDevelopmentHost && port) {
this.broadcastService.broadcast({
channel: EXTENSION_ATTACH_BROADCAST_CHANNEL,
payload: { port }
payload: {
debugId: this.environmentService.debugExtensionHost.debugId,
port
}
});
}
......@@ -344,7 +347,10 @@ export class ExtensionHostProcessWorker {
else if (!this.environmentService.isBuilt || this.isExtensionDevelopmentHost) {
this.broadcastService.broadcast({
channel: EXTENSION_LOG_BROADCAST_CHANNEL,
payload: logEntry
payload: {
logEntry,
debugId: this.environmentService.debugExtensionHost.debugId
}
});
}
}
......@@ -411,7 +417,9 @@ export class ExtensionHostProcessWorker {
if (this.isExtensionDevelopmentHost && !this.isExtensionDevelopmentTestFromCli && !this.isExtensionDevelopmentDebug) {
this.broadcastService.broadcast({
channel: EXTENSION_TERMINATE_BROADCAST_CHANNEL,
payload: true
payload: {
debugId: this.environmentService.debugExtensionHost.debugId
}
});
event.veto(TPromise.timeout(100 /* wait a bit for IPC to get delivered */).then(() => false));
......
......@@ -331,6 +331,7 @@ export interface IEnvConfig {
internalConsoleOptions?: string;
preLaunchTask?: string;
__restart?: any;
__sessionId?: string;
debugServer?: number;
noDebug?: boolean;
port?: number;
......
......@@ -166,16 +166,12 @@ export class DebugService implements debug.IDebugService {
private onBroadcast(broadcast: IBroadcast): void {
// attach: PH is ready to be attached to
const process = this.model.getProcesses().filter(p => strings.equalsIgnoreCase(p.configuration.type, 'extensionhost')).pop();
if (!process) {
return; // TODO@Andre TODO@Isidor the broadcast should carry over the session ID so that we can do the correct thing here (see https://github.com/Microsoft/vscode/issues/30698)
}
const process = this.model.getProcesses().filter(p => p.getId() === broadcast.payload.debugId).pop();
const session = process ? <RawDebugSession>process.session : null;
if (broadcast.channel === EXTENSION_ATTACH_BROADCAST_CHANNEL) {
if (session) {
// Only support one extension host session at a time. More details #29884
this.onSessionEnd(session);
session.attach({ port: broadcast.payload.port }).done(undefined, errors.onUnexpectedError);
return;
}
const config = this.configurationManager.getConfiguration(this.viewModel.selectedConfigurationName);
......@@ -188,10 +184,8 @@ export class DebugService implements debug.IDebugService {
return;
}
if (broadcast.channel === EXTENSION_TERMINATE_BROADCAST_CHANNEL) {
if (session) {
this.onSessionEnd(session);
}
if (session && broadcast.channel === EXTENSION_TERMINATE_BROADCAST_CHANNEL) {
this.onSessionEnd(session);
return;
}
......@@ -202,7 +196,7 @@ export class DebugService implements debug.IDebugService {
// an extension logged output, show it inside the REPL
if (broadcast.channel === EXTENSION_LOG_BROADCAST_CHANNEL) {
let extensionOutput: ILogEntry = broadcast.payload;
let extensionOutput: ILogEntry = broadcast.payload.logEntry;
let sev = extensionOutput.severity === 'warn' ? severity.Warning : extensionOutput.severity === 'error' ? severity.Error : severity.Info;
let args: any[] = [];
......@@ -773,6 +767,7 @@ export class DebugService implements debug.IDebugService {
private doCreateProcess(configuration: debug.IConfig): TPromise<debug.IProcess> {
const sessionId = generateUuid();
configuration.__sessionId = sessionId;
this.updateStateAndEmit(sessionId, debug.State.Initializing);
return this.telemetryService.getTelemetryInfo().then(info => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册