debug session: pass configuration as args for restart

#118196
This commit is contained in:
isidor 2021-04-16 15:52:31 +02:00
parent 5d72ea7c19
commit 4430569ad0
No known key found for this signature in database
GPG key ID: F9280366A8370105
3 changed files with 36 additions and 35 deletions

View file

@ -675,6 +675,39 @@ export class DebugService implements IDebugService {
return;
}
// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let needsToSubstitute = false;
let unresolved: IConfig | undefined;
const launch = session.root ? this.configurationManager.getLaunch(session.root.uri) : undefined;
if (launch) {
unresolved = launch.getConfiguration(session.configuration.name);
if (unresolved && !equals(unresolved, session.unresolvedConfiguration)) {
// Take the type from the session since the debug extension might overwrite it #21316
unresolved.type = session.configuration.type;
unresolved.noDebug = session.configuration.noDebug;
needsToSubstitute = true;
}
}
let resolved: IConfig | undefined | null = session.configuration;
if (launch && needsToSubstitute && unresolved) {
const initCancellationToken = new CancellationTokenSource();
this.sessionCancellationTokens.set(session.getId(), initCancellationToken);
const resolvedByProviders = await this.configurationManager.resolveConfigurationByProviders(launch.workspace ? launch.workspace.uri : undefined, unresolved.type, unresolved, initCancellationToken.token);
if (resolvedByProviders) {
resolved = await this.substituteVariables(launch, resolvedByProviders);
if (resolved && !initCancellationToken.token.isCancellationRequested) {
resolved = await this.configurationManager.resolveDebugConfigurationWithSubstitutedVariables(launch && launch.workspace ? launch.workspace.uri : undefined, unresolved.type, resolved, initCancellationToken.token);
}
} else {
resolved = resolvedByProviders;
}
}
if (resolved) {
session.setConfiguration({ resolved, unresolved });
}
session.configuration.__restart = restartData;
if (session.capabilities.supportsRestartRequest) {
const taskResult = await runTasks();
if (taskResult === TaskRunResult.Success) {
@ -699,42 +732,10 @@ export class DebugService implements IDebugService {
return;
}
// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let needsToSubstitute = false;
let unresolved: IConfig | undefined;
const launch = session.root ? this.configurationManager.getLaunch(session.root.uri) : undefined;
if (launch) {
unresolved = launch.getConfiguration(session.configuration.name);
if (unresolved && !equals(unresolved, session.unresolvedConfiguration)) {
// Take the type from the session since the debug extension might overwrite it #21316
unresolved.type = session.configuration.type;
unresolved.noDebug = session.configuration.noDebug;
needsToSubstitute = true;
}
}
let resolved: IConfig | undefined | null = session.configuration;
if (launch && needsToSubstitute && unresolved) {
const initCancellationToken = new CancellationTokenSource();
this.sessionCancellationTokens.set(session.getId(), initCancellationToken);
const resolvedByProviders = await this.configurationManager.resolveConfigurationByProviders(launch.workspace ? launch.workspace.uri : undefined, unresolved.type, unresolved, initCancellationToken.token);
if (resolvedByProviders) {
resolved = await this.substituteVariables(launch, resolvedByProviders);
if (resolved && !initCancellationToken.token.isCancellationRequested) {
resolved = await this.configurationManager.resolveDebugConfigurationWithSubstitutedVariables(launch && launch.workspace ? launch.workspace.uri : undefined, unresolved.type, resolved, initCancellationToken.token);
}
} else {
resolved = resolvedByProviders;
}
}
if (!resolved) {
return c(undefined);
}
session.setConfiguration({ resolved, unresolved });
session.configuration.__restart = restartData;
try {
await this.launchOrAttachToSession(session, shouldFocus);
this._onDidNewSession.fire(session);

View file

@ -337,7 +337,7 @@ export class DebugSession implements IDebugSession {
}
this.cancelAllRequests();
await this.raw.restart();
await this.raw.restart({ arguments: this.configuration });
}
async sendBreakpoints(modelUri: URI, breakpointsToSend: IBreakpoint[], sourceModified: boolean): Promise<void> {

View file

@ -303,9 +303,9 @@ export class RawDebugSession implements IDisposable {
return Promise.reject(new Error('terminated not supported'));
}
restart(): Promise<DebugProtocol.RestartResponse | undefined> {
restart(args: DebugProtocol.RestartArguments): Promise<DebugProtocol.RestartResponse | undefined> {
if (this.capabilities.supportsRestartRequest) {
return this.send('restart', null);
return this.send('restart', args);
}
return Promise.reject(new Error('restart not supported'));
}