Skip to content

Commit

Permalink
Add option for launching fresh PowerShell instances for debugging
Browse files Browse the repository at this point in the history
This change enables the user to configure their debugging sessions to
launch a fresh PowerShell process each time they start the debugger.
This is useful when debugging scripts or modules which use PowerShell
classes or managed assemblies which cannot be reloaded within the same
process.

Resolves PowerShell#367.
  • Loading branch information
daviwil committed Jun 15, 2017
1 parent b0d3e02 commit 1f28a0e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 168 deletions.
148 changes: 1 addition & 147 deletions scripts/Start-EditorServices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ param(
[switch]
$EnableConsoleRepl,

[string]
[switch]
$DebugServiceOnly,

[string[]]
Expand Down Expand Up @@ -272,149 +272,3 @@ catch [System.Exception] {
$e = $e.InnerException;
}
}

# SIG # Begin signature block
# MIIasAYJKoZIhvcNAQcCoIIaoTCCGp0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUpu7oVqr4fTIiTHDYLqwN5cNP
# 7VOgghWDMIIEwzCCA6ugAwIBAgITMwAAALfuAa/68MeouwAAAAAAtzANBgkqhkiG
# 9w0BAQUFADB3MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4G
# A1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSEw
# HwYDVQQDExhNaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EwHhcNMTYwOTA3MTc1ODQ1
# WhcNMTgwOTA3MTc1ODQ1WjCBszELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hp
# bmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jw
# b3JhdGlvbjENMAsGA1UECxMETU9QUjEn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l6CD7n9Hh04Wrhurai9aSj8xxN1Y
# DvoZ7KNpLUr8Jo1dxfaO+i8Aem3bQCNNwISlxBN7V4hvByAjP1YxXlhiIV7Ibr9d
# 7PVBSLIDRpNX6nptuEOkiexTFfJEOI1OSuZs50RAqXarAr3wAEZqn8mDAJMi9WpZ
# 14iT6OJYqWpPQxixFAoED1oSpiebV6qhNw+ryw/ilSkm5lWtL4gcjk5+kaiEw1k8
# jYFdXvc6mNe793BfInuWAbo8sZY=
# SIG # End signature block
39 changes: 34 additions & 5 deletions src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export namespace StartDebuggerNotification {
}

export class DebugSessionFeature implements IFeature {

private sessionCount: number = 1;
private command: vscode.Disposable;
private examplesPath: string;

Expand Down Expand Up @@ -42,6 +44,8 @@ export class DebugSessionFeature implements IFeature {
let debugCurrentScript = (config.script === "${file}") || !config.request;
let generateLaunchConfig = !config.request;

let newSession = true;

if (generateLaunchConfig) {
// No launch.json, create the default configuration for both unsaved (Untitled) and saved documents.
config.type = 'PowerShell';
Expand Down Expand Up @@ -112,14 +116,39 @@ export class DebugSessionFeature implements IFeature {
config.internalConsoleOptions = "neverOpen";

// Create or show the interactive console
// TODO #367: Check if "newSession" mode is configured
vscode.commands.executeCommand('PowerShell.ShowSessionConsole', true);

// Write out temporary debug session file
utils.writeSessionFile(
utils.getDebugSessionFilePath(),
this.sessionManager.getSessionDetails());
var sessionFilePath = utils.getDebugSessionFilePath();

if (newSession) {
var debugProcess =
this.sessionManager.getDebugSessionProcess(
sessionFilePath);

debugProcess
.start(`DebugSession-${this.sessionCount++}`)
.then(
sessionDetails => {
this.startDebugger(
config,
sessionFilePath,
sessionDetails);
});
}
else {
this.startDebugger(
config,
sessionFilePath,
this.sessionManager.getSessionDetails());
}
}

private startDebugger(
config: any,
sessionFilePath: string,
sessionDetails: utils.EditorServicesSessionDetails) {

utils.writeSessionFile(sessionFilePath, sessionDetails);
vscode.commands.executeCommand('vscode.startDebug', config);
}
}
Expand Down
20 changes: 9 additions & 11 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Logger } from './logging';

export class PowerShellProcess {

private sessionFilePath: string;
private consoleTerminal: vscode.Terminal = undefined;
private consoleCloseSubscription: vscode.Disposable;
private sessionDetails: utils.EditorServicesSessionDetails;
Expand All @@ -25,15 +24,14 @@ export class PowerShellProcess {

constructor(
public exePath: string,
private title: string,
private log: Logger,
private startArgs: string,
private sessionFilePath: string,
private sessionSettings: Settings.ISettings) {

this.sessionFilePath =
utils.getSessionFilePath(
Math.floor(100000 + Math.random() * 900000));
}

public start(startArgs: string): Thenable<utils.EditorServicesSessionDetails> {
public start(logFileName: string): Thenable<utils.EditorServicesSessionDetails> {

return new Promise<utils.EditorServicesSessionDetails>(
(resolve, reject) => {
Expand All @@ -44,14 +42,14 @@ export class PowerShellProcess {
__dirname,
'../scripts/Start-EditorServices.ps1');

var editorServicesLogPath = this.log.getLogFilePath("EditorServices");
var editorServicesLogPath = this.log.getLogFilePath(logFileName);

var featureFlags =
this.sessionSettings.developer.featureFlags !== undefined
? this.sessionSettings.developer.featureFlags.map(f => `'${f}'`).join(', ')
: "";

startArgs +=
this.startArgs +=
`-LogPath '${editorServicesLogPath}' ` +
`-SessionDetailsPath '${this.sessionFilePath}' ` +
`-FeatureFlags @(${featureFlags})`
Expand All @@ -68,7 +66,7 @@ export class PowerShellProcess {

powerShellArgs.push(
"-Command",
"& '" + startScriptPath + "' " + startArgs);
"& '" + startScriptPath + "' " + this.startArgs);

var powerShellExePath = this.exePath;

Expand All @@ -95,7 +93,7 @@ export class PowerShellProcess {
// Launch PowerShell in the integrated terminal
this.consoleTerminal =
vscode.window.createTerminal(
"PowerShell Integrated Console",
this.title,
powerShellExePath,
powerShellArgs);

Expand Down Expand Up @@ -148,7 +146,7 @@ export class PowerShellProcess {
"powershell.exe started --",
" pid: " + pid,
" exe: " + powerShellExePath,
" args: " + startScriptPath + ' ' + startArgs + os.EOL + os.EOL);
" args: " + startScriptPath + ' ' + this.startArgs + os.EOL + os.EOL);
});
}
catch (e)
Expand Down
28 changes: 23 additions & 5 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class SessionManager implements Middleware {

private hostVersion: string;
private isWindowsOS: boolean;
private editorServicesArgs: string;
private powerShellExePath: string = "";
private sessionStatus: SessionStatus;
private suppressRestartPrompt: boolean;
Expand Down Expand Up @@ -139,7 +140,7 @@ export class SessionManager implements Middleware {
}
}

var startArgs =
this.editorServicesArgs =
"-EditorServicesVersion '" + this.requiredEditorServicesVersion + "' " +
"-HostName 'Visual Studio Code Host' " +
"-HostProfileId 'Microsoft.VSCode' " +
Expand All @@ -148,17 +149,17 @@ export class SessionManager implements Middleware {
"-EnableConsoleRepl ";

if (this.sessionSettings.developer.editorServicesWaitForDebugger) {
startArgs += '-WaitForDebugger ';
this.editorServicesArgs += '-WaitForDebugger ';
}
if (this.sessionSettings.developer.editorServicesLogLevel) {
startArgs += "-LogLevel '" + this.sessionSettings.developer.editorServicesLogLevel + "' "
this.editorServicesArgs += "-LogLevel '" + this.sessionSettings.developer.editorServicesLogLevel + "' "
}

this.startPowerShell(
this.powerShellExePath,
this.sessionSettings.developer.powerShellExeIsWindowsDevBuild,
bundledModulesPath,
startArgs);
this.editorServicesArgs);
}
else {
this.setSessionFailure("PowerShell could not be started, click 'Show Logs' for more details.");
Expand Down Expand Up @@ -205,6 +206,16 @@ export class SessionManager implements Middleware {
this.registeredCommands.forEach(command => { command.dispose(); });
}

public getDebugSessionProcess(sessionPath: string): PowerShellProcess {
return new PowerShellProcess(
this.powerShellExePath,
"[DBG] PowerShell Integrated Console",
this.log,
this.editorServicesArgs + "-DebugServiceOnly ",
sessionPath,
Settings.load());
}

private onConfigurationUpdated() {
var settings = Settings.load();

Expand Down Expand Up @@ -265,10 +276,17 @@ export class SessionManager implements Middleware {
"Starting PowerShell...",
SessionStatus.Initializing);

var sessionFilePath =
utils.getSessionFilePath(
Math.floor(100000 + Math.random() * 900000));

this.powerShellProcess =
new PowerShellProcess(
this.powerShellExePath,
"PowerShell Integrated Console",
this.log,
startArgs,
sessionFilePath,
this.sessionSettings);

this.powerShellProcess.onExited(
Expand All @@ -280,7 +298,7 @@ export class SessionManager implements Middleware {
});

this.powerShellProcess
.start(startArgs)
.start("EditorServices")
.then(
sessionDetails => {
this.sessionDetails = sessionDetails;
Expand Down

0 comments on commit 1f28a0e

Please sign in to comment.