forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugger: fix --debug-brk interaction with -e
The command line flag `--debug-brk` was ignored when the `-e` flag was also present. This change allows the flags to both be honored when they are used in a single command line. Fixes: nodejs#3589
- Loading branch information
Showing
10 changed files
with
83 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const spawn = require('child_process').spawn; | ||
|
||
const args = [`--debug-brk=${common.PORT}`, '-e', '0']; | ||
const proc = spawnSync(process.execPath, args, {encoding: 'utf8'}); | ||
assert(/Debugger listening on/.test(proc.stderr)); | ||
var procStderr = ''; | ||
var agentStdout = ''; | ||
var needToSpawnAgent = true; | ||
var needToExit = true; | ||
|
||
const procArgs = [`--debug-brk=${common.PORT}`, '-e', '0']; | ||
const proc = spawn(process.execPath, procArgs); | ||
proc.stderr.setEncoding('utf8'); | ||
|
||
const exitAll = common.mustCall((processes) => { | ||
processes.forEach((myProcess) => { myProcess.kill(); }); | ||
}); | ||
|
||
proc.stderr.on('data', (chunk) => { | ||
procStderr += chunk; | ||
if (/Debugger listening on/.test(procStderr) && needToSpawnAgent) { | ||
needToSpawnAgent = false; | ||
const agentArgs = ['debug', `localhost:${common.PORT}`]; | ||
const agent = spawn(process.execPath, agentArgs); | ||
agent.stdout.setEncoding('utf8'); | ||
|
||
agent.stdout.on('data', (chunk) => { | ||
agentStdout += chunk; | ||
if (/connecting to .+ ok/.test(agentStdout)) { | ||
if (needToExit) { | ||
needToExit = false; | ||
exitAll([proc, agent]); | ||
} | ||
} | ||
}); | ||
} | ||
}); |