Skip to content

Commit 9e71319

Browse files
author
Paul van Brenk
committed
Correctly escape script when using inspect
1 parent ec80503 commit 9e71319

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Nodejs/Product/Nodejs/Debugger/NodeDebugger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static NodeProcess StartNodeProcessWithInspect(string exe, string script,
120120
var debuggerPortOrDefault = debuggerPort ?? GetDebuggerPort();
121121

122122
// Node usage: node [options] [ -e script | script.js ] [arguments]
123-
string allArgs = $"--debug-brk={debuggerPortOrDefault} --nolazy {interpreterOptions} {script}";
123+
string allArgs = $"--inspect={debuggerPortOrDefault} --debug-brk --nolazy {interpreterOptions} \"{script}\"";
124124

125125
return StartNodeProcess(exe, dir, env, debugOptions, debuggerPortOrDefault, allArgs, createNodeWindow);
126126
}

Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ internal class NodejsProjectLauncher : IProjectLauncher {
4141
private readonly NodejsProjectNode _project;
4242
private int? _testServerPort;
4343

44+
private static readonly Guid WebkitDebuggerGuid = Guid.Parse("4cc6df14-0ab5-4a91-8bb4-eb0bf233d0fe");
45+
private static readonly Guid WebkitPortSupplierGuid = Guid.Parse("4103f338-2255-40c0-acf5-7380e2bea13d");
46+
4447
public NodejsProjectLauncher(NodejsProjectNode project) {
4548
_project = project;
4649

@@ -90,6 +93,7 @@ private int Start(string file, bool debug) {
9093

9194
private void StartAndAttachDebugger(string file, string nodePath) {
9295

96+
// start the node process
9397
string workingDir = _project.GetWorkingDirectory();
9498
string env = "";
9599
var interpreterOptions = _project.GetProjectProperty(NodeProjectProperty.NodeExeArguments);
@@ -98,20 +102,18 @@ private void StartAndAttachDebugger(string file, string nodePath) {
98102
process.Start();
99103

100104
// setup debug info and attach
101-
var webkitDebuggerGuid = Guid.Parse("4cc6df14-0ab5-4a91-8bb4-eb0bf233d0fe");
102-
var webkitPortSupplierGuid = Guid.Parse("4103f338-2255-40c0-acf5-7380e2bea13d");
103105
var debugUri = $"http://127.0.0.1:{process.DebuggerPort}";
104106

105107
var dbgInfo = new VsDebugTargetInfo4();
106108
dbgInfo.dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
107109
dbgInfo.LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop;
108110

109-
dbgInfo.guidLaunchDebugEngine = webkitDebuggerGuid;
111+
dbgInfo.guidLaunchDebugEngine = WebkitDebuggerGuid;
110112
dbgInfo.dwDebugEngineCount = 1;
111113

112-
var enginesPtr = MarshalDebugEngines(new[] { webkitDebuggerGuid });
114+
var enginesPtr = MarshalDebugEngines(new[] { WebkitDebuggerGuid });
113115
dbgInfo.pDebugEngines = enginesPtr;
114-
dbgInfo.guidPortSupplier = webkitPortSupplierGuid;
116+
dbgInfo.guidPortSupplier = WebkitPortSupplierGuid;
115117
dbgInfo.bstrPortName = debugUri;
116118

117119
// we connect through a URI, so no need to set the process,
@@ -124,13 +126,13 @@ private void StartAndAttachDebugger(string file, string nodePath) {
124126
private void AttachDebugger(VsDebugTargetInfo4 dbgInfo) {
125127
var serviceProvider = _project.Site;
126128

127-
var launchResults = new VsDebugTargetProcessInfo[1];
128129
var debugger = serviceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4;
129130

130131
if (debugger == null) {
131-
throw new InvalidOperationException();
132+
throw new InvalidOperationException("Failed to get the debugger service.");
132133
}
133134

135+
var launchResults = new VsDebugTargetProcessInfo[1];
134136
debugger.LaunchDebugTargets4(1, new[] { dbgInfo }, launchResults);
135137
}
136138

@@ -351,7 +353,7 @@ private bool SetupDebugInfo(ref VsDebugTargetInfo dbgInfo, string startupFile) {
351353
}
352354
}
353355

354-
//Environemnt variables should be passed as a
356+
//Environment variables should be passed as a
355357
//null-terminated block of null-terminated strings.
356358
//Each string is in the following form:name=value\0
357359
StringBuilder buf = new StringBuilder();

0 commit comments

Comments
 (0)