lib: remove _debugger.js
The file no longer works after the removal of the --debug/--debug-brk switches in commit 47f8f74 ("src: remove support for --debug".) This commit also removes several tests that still referenced the old debugger but were either unit-testing its internals or passing for the wrong reason (like expecting an operation to fail, which it did because the debugger is gone.) PR-URL: https://github.com/nodejs/node/pull/12495 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e0b076a949
commit
90476ac6ee
1791
lib/_debugger.js
1791
lib/_debugger.js
File diff suppressed because it is too large
Load Diff
33
lib/internal/bootstrap_node.js
vendored
33
lib/internal/bootstrap_node.js
vendored
@ -122,9 +122,7 @@
|
|||||||
|
|
||||||
const internalModule = NativeModule.require('internal/module');
|
const internalModule = NativeModule.require('internal/module');
|
||||||
internalModule.addBuiltinLibsToObject(global);
|
internalModule.addBuiltinLibsToObject(global);
|
||||||
run(() => {
|
evalScript('[eval]');
|
||||||
evalScript('[eval]');
|
|
||||||
});
|
|
||||||
} else if (process.argv[1]) {
|
} else if (process.argv[1]) {
|
||||||
// make process.argv[1] into a full path
|
// make process.argv[1] into a full path
|
||||||
const path = NativeModule.require('path');
|
const path = NativeModule.require('path');
|
||||||
@ -143,7 +141,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
preloadModules();
|
preloadModules();
|
||||||
run(Module.runMain);
|
Module.runMain();
|
||||||
} else {
|
} else {
|
||||||
preloadModules();
|
preloadModules();
|
||||||
// If -i or --interactive were passed, or stdin is a TTY.
|
// If -i or --interactive were passed, or stdin is a TTY.
|
||||||
@ -417,33 +415,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDebugBreak() {
|
|
||||||
return process.execArgv.some((arg) => /^--debug-brk(=[0-9]+)?$/.test(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(entryFunction) {
|
|
||||||
if (process._debugWaitConnect && isDebugBreak()) {
|
|
||||||
|
|
||||||
// XXX Fix this terrible hack!
|
|
||||||
//
|
|
||||||
// Give the client program a few ticks to connect.
|
|
||||||
// Otherwise, there's a race condition where `node debug foo.js`
|
|
||||||
// will not be able to connect in time to catch the first
|
|
||||||
// breakpoint message on line 1.
|
|
||||||
//
|
|
||||||
// A better fix would be to somehow get a message from the
|
|
||||||
// V8 debug object about a connection, and runMain when
|
|
||||||
// that occurs. --isaacs
|
|
||||||
|
|
||||||
const debugTimeout = +process.env.NODE_DEBUG_TIMEOUT || 50;
|
|
||||||
setTimeout(entryFunction, debugTimeout);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Main entry point into most programs:
|
|
||||||
entryFunction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkScriptSyntax(source, filename) {
|
function checkScriptSyntax(source, filename) {
|
||||||
const Module = NativeModule.require('module');
|
const Module = NativeModule.require('module');
|
||||||
const vm = NativeModule.require('vm');
|
const vm = NativeModule.require('vm');
|
||||||
|
1
node.gyp
1
node.gyp
@ -23,7 +23,6 @@
|
|||||||
'library_files': [
|
'library_files': [
|
||||||
'lib/internal/bootstrap_node.js',
|
'lib/internal/bootstrap_node.js',
|
||||||
'lib/_debug_agent.js',
|
'lib/_debug_agent.js',
|
||||||
'lib/_debugger.js',
|
|
||||||
'lib/assert.js',
|
'lib/assert.js',
|
||||||
'lib/buffer.js',
|
'lib/buffer.js',
|
||||||
'lib/child_process.js',
|
'lib/child_process.js',
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
// Copyright Joyent, Inc. and other Node contributors.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the
|
|
||||||
// "Software"), to deal in the Software without restriction, including
|
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
||||||
// persons to whom the Software is furnished to do so, subject to the
|
|
||||||
// following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
||||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
const common = require('../common');
|
|
||||||
const path = require('path');
|
|
||||||
const assert = require('assert');
|
|
||||||
const spawn = require('child_process').spawn;
|
|
||||||
const debug = require('_debugger');
|
|
||||||
|
|
||||||
const scenarios = [];
|
|
||||||
|
|
||||||
addScenario('global.js', 2);
|
|
||||||
addScenario('timeout.js', 2);
|
|
||||||
|
|
||||||
run();
|
|
||||||
|
|
||||||
/***************** IMPLEMENTATION *****************/
|
|
||||||
|
|
||||||
function addScenario(scriptName, throwsOnLine) {
|
|
||||||
scenarios.push(
|
|
||||||
runScenario.bind(null, scriptName, throwsOnLine, run)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function run() {
|
|
||||||
const next = scenarios.shift();
|
|
||||||
if (next) next();
|
|
||||||
}
|
|
||||||
|
|
||||||
function runScenario(scriptName, throwsOnLine, next) {
|
|
||||||
let asserted = false;
|
|
||||||
const port = common.PORT;
|
|
||||||
|
|
||||||
const testScript = path.join(
|
|
||||||
common.fixturesDir,
|
|
||||||
'uncaught-exceptions',
|
|
||||||
scriptName
|
|
||||||
);
|
|
||||||
|
|
||||||
const child = spawn(process.execPath, [ '--debug-brk=' + port, testScript ]);
|
|
||||||
child.on('close', function() {
|
|
||||||
assert(asserted, 'debugger did not pause on exception');
|
|
||||||
if (next) next();
|
|
||||||
});
|
|
||||||
|
|
||||||
const exceptions = [];
|
|
||||||
|
|
||||||
let stderr = '';
|
|
||||||
|
|
||||||
function stderrListener(data) {
|
|
||||||
stderr += data;
|
|
||||||
if (stderr.includes('Debugger listening on ')) {
|
|
||||||
setTimeout(setupClient.bind(null, runTest), 200);
|
|
||||||
child.stderr.removeListener('data', stderrListener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
child.stderr.setEncoding('utf8');
|
|
||||||
child.stderr.on('data', stderrListener);
|
|
||||||
|
|
||||||
function setupClient(callback) {
|
|
||||||
const client = new debug.Client();
|
|
||||||
|
|
||||||
client.once('ready', callback.bind(null, client));
|
|
||||||
|
|
||||||
client.on('unhandledResponse', function(body) {
|
|
||||||
console.error('unhandled response: %j', body);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('error', function(err) {
|
|
||||||
if (asserted) return;
|
|
||||||
assert.ifError(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.connect(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
let interval;
|
|
||||||
function runTest(client) {
|
|
||||||
client.req(
|
|
||||||
{
|
|
||||||
command: 'setexceptionbreak',
|
|
||||||
arguments: {
|
|
||||||
type: 'uncaught',
|
|
||||||
enabled: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
assert.ifError(error);
|
|
||||||
|
|
||||||
client.on('exception', function(event) {
|
|
||||||
exceptions.push(event.body);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.reqContinue(function(error) {
|
|
||||||
assert.ifError(error);
|
|
||||||
interval = setInterval(assertHasPaused.bind(null, client), 10);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertHasPaused(client) {
|
|
||||||
if (!exceptions.length) return;
|
|
||||||
|
|
||||||
assert.strictEqual(exceptions.length, 1,
|
|
||||||
'debugger did not pause on exception');
|
|
||||||
assert.strictEqual(exceptions[0].uncaught, true);
|
|
||||||
assert.strictEqual(exceptions[0].script.name, testScript);
|
|
||||||
assert.strictEqual(exceptions[0].sourceLine + 1, throwsOnLine);
|
|
||||||
asserted = true;
|
|
||||||
client.reqContinue(assert.ifError);
|
|
||||||
clearInterval(interval);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,237 +0,0 @@
|
|||||||
// Copyright Joyent, Inc. and other Node contributors.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the
|
|
||||||
// "Software"), to deal in the Software without restriction, including
|
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
||||||
// persons to whom the Software is furnished to do so, subject to the
|
|
||||||
// following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
||||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const debug = require('_debugger');
|
|
||||||
|
|
||||||
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
|
|
||||||
const debugPort = common.PORT;
|
|
||||||
debug.port = debugPort;
|
|
||||||
const spawn = require('child_process').spawn;
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
if (nodeProcess) nodeProcess.kill('SIGTERM');
|
|
||||||
throw new Error('timeout');
|
|
||||||
}, 10000).unref();
|
|
||||||
|
|
||||||
|
|
||||||
let resCount = 0;
|
|
||||||
const p = new debug.Protocol();
|
|
||||||
p.onResponse = function() {
|
|
||||||
resCount++;
|
|
||||||
};
|
|
||||||
|
|
||||||
p.execute('Type: connect\r\n' +
|
|
||||||
'V8-Version: 3.0.4.1\r\n' +
|
|
||||||
'Protocol-Version: 1\r\n' +
|
|
||||||
'Embedding-Host: node v0.3.3-pre\r\n' +
|
|
||||||
'Content-Length: 0\r\n\r\n');
|
|
||||||
assert.strictEqual(resCount, 1);
|
|
||||||
|
|
||||||
// Make sure split messages go in.
|
|
||||||
|
|
||||||
const parts = [];
|
|
||||||
parts.push('Content-Length: 336\r\n');
|
|
||||||
assert.strictEqual(parts[0].length, 21);
|
|
||||||
parts.push('\r\n');
|
|
||||||
assert.strictEqual(parts[1].length, 2);
|
|
||||||
let bodyLength = 0;
|
|
||||||
|
|
||||||
parts.push('{"seq":12,"type":"event","event":"break","body":' +
|
|
||||||
'{"invocationText":"#<a Server>');
|
|
||||||
assert.strictEqual(parts[2].length, 78);
|
|
||||||
bodyLength += parts[2].length;
|
|
||||||
|
|
||||||
parts.push('.[anonymous](req=#<an IncomingMessage>, ' +
|
|
||||||
'res=#<a ServerResponse>)","sourceLine"');
|
|
||||||
assert.strictEqual(parts[3].length, 78);
|
|
||||||
bodyLength += parts[3].length;
|
|
||||||
|
|
||||||
parts.push(':45,"sourceColumn":4,"sourceLineText":" debugger;",' +
|
|
||||||
'"script":{"id":24,"name":"/home/ryan/projects/node/' +
|
|
||||||
'benchmark/http_simple.js","lineOffset":0,"columnOffset":0,' +
|
|
||||||
'"lineCount":98}}}');
|
|
||||||
assert.strictEqual(parts[4].length, 180);
|
|
||||||
bodyLength += parts[4].length;
|
|
||||||
|
|
||||||
assert.strictEqual(bodyLength, 336);
|
|
||||||
|
|
||||||
for (let i = 0; i < parts.length; i++) {
|
|
||||||
p.execute(parts[i]);
|
|
||||||
}
|
|
||||||
assert.strictEqual(resCount, 2);
|
|
||||||
|
|
||||||
|
|
||||||
// Make sure that if we get backed up, we still manage to get all the
|
|
||||||
// messages
|
|
||||||
const d = 'Content-Length: 466\r\n\r\n' +
|
|
||||||
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
|
|
||||||
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
|
|
||||||
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
|
|
||||||
'"sourceStart":"(function(module, exports, require) {' +
|
|
||||||
'var dns = process.binding(\'cares\')' +
|
|
||||||
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType"' +
|
|
||||||
':0,"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
|
|
||||||
'[{"handle":0' +
|
|
||||||
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
|
|
||||||
'\r\n\r\nContent-Length: 119\r\n\r\n' +
|
|
||||||
'{"seq":11,"type":"event","event":"scriptCollected","success":true' +
|
|
||||||
',"body":{"script":{"id":26}},"refs":[],"running":true}';
|
|
||||||
p.execute(d);
|
|
||||||
assert.strictEqual(resCount, 4);
|
|
||||||
|
|
||||||
let expectedConnections = 0;
|
|
||||||
const tests = [];
|
|
||||||
function addTest(cb) {
|
|
||||||
expectedConnections++;
|
|
||||||
tests.push(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
addTest(function(client, done) {
|
|
||||||
console.error('requesting version');
|
|
||||||
client.reqVersion(function(err, v) {
|
|
||||||
assert.ifError(err);
|
|
||||||
console.log('version: %s', v);
|
|
||||||
assert.strictEqual(process.versions.v8, v);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
addTest(function(client, done) {
|
|
||||||
console.error('requesting scripts');
|
|
||||||
client.reqScripts(function(err) {
|
|
||||||
assert.ifError(err);
|
|
||||||
console.error('got %d scripts', Object.keys(client.scripts).length);
|
|
||||||
|
|
||||||
let foundMainScript = false;
|
|
||||||
for (const k in client.scripts) {
|
|
||||||
const script = client.scripts[k];
|
|
||||||
if (script && script.name === 'bootstrap_node.js') {
|
|
||||||
foundMainScript = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert.ok(foundMainScript);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
addTest(function(client, done) {
|
|
||||||
console.error('eval 2+2');
|
|
||||||
client.reqEval('2+2', function(err, res) {
|
|
||||||
console.error(res);
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.strictEqual(res.text, '4');
|
|
||||||
assert.strictEqual(res.value, 4);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
let connectCount = 0;
|
|
||||||
const script = 'setTimeout(function() { console.log("blah"); });' +
|
|
||||||
'setInterval(common.noop, 1000000);';
|
|
||||||
|
|
||||||
let nodeProcess;
|
|
||||||
|
|
||||||
function doTest(cb, done) {
|
|
||||||
const args = ['--debug=' + debugPort, '-e', script];
|
|
||||||
nodeProcess = spawn(process.execPath, args);
|
|
||||||
|
|
||||||
nodeProcess.stdout.once('data', function() {
|
|
||||||
console.log('>>> new node process: %d', nodeProcess.pid);
|
|
||||||
let failed = true;
|
|
||||||
try {
|
|
||||||
process._debugProcess(nodeProcess.pid);
|
|
||||||
failed = false;
|
|
||||||
} finally {
|
|
||||||
// At least TRY not to leave zombie procs if this fails.
|
|
||||||
if (failed)
|
|
||||||
nodeProcess.kill('SIGTERM');
|
|
||||||
}
|
|
||||||
console.log('>>> starting debugger session');
|
|
||||||
});
|
|
||||||
|
|
||||||
let didTryConnect = false;
|
|
||||||
nodeProcess.stderr.setEncoding('utf8');
|
|
||||||
let b = '';
|
|
||||||
nodeProcess.stderr.on('data', function(data) {
|
|
||||||
console.error('got stderr data %j', data);
|
|
||||||
nodeProcess.stderr.resume();
|
|
||||||
b += data;
|
|
||||||
if (didTryConnect === false && b.match(/Debugger listening on /)) {
|
|
||||||
didTryConnect = true;
|
|
||||||
|
|
||||||
// The timeout is here to expose a race in the bootstrap process.
|
|
||||||
// Without the early SIGUSR1 debug handler, it effectively results
|
|
||||||
// in an infinite ECONNREFUSED loop.
|
|
||||||
setTimeout(tryConnect, 100);
|
|
||||||
|
|
||||||
function tryConnect() {
|
|
||||||
// Wait for some data before trying to connect
|
|
||||||
const c = new debug.Client();
|
|
||||||
console.error('>>> connecting...');
|
|
||||||
c.connect(debug.port);
|
|
||||||
c.on('break', function() {
|
|
||||||
c.reqContinue(common.noop);
|
|
||||||
});
|
|
||||||
c.on('ready', function() {
|
|
||||||
connectCount++;
|
|
||||||
console.log('ready!');
|
|
||||||
cb(c, function() {
|
|
||||||
c.end();
|
|
||||||
c.on('end', function() {
|
|
||||||
console.error(
|
|
||||||
'>>> killing node process %d\n\n',
|
|
||||||
nodeProcess.pid);
|
|
||||||
nodeProcess.kill();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
c.on('error', function(err) {
|
|
||||||
if (err.code !== 'ECONNREFUSED') throw err;
|
|
||||||
setTimeout(tryConnect, 10);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function run() {
|
|
||||||
const t = tests[0];
|
|
||||||
if (!t) return;
|
|
||||||
|
|
||||||
doTest(t, function() {
|
|
||||||
tests.shift();
|
|
||||||
run();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run();
|
|
||||||
|
|
||||||
process.on('exit', function(code) {
|
|
||||||
if (!code)
|
|
||||||
assert.strictEqual(connectCount, expectedConnections);
|
|
||||||
});
|
|
@ -1,61 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const spawn = require('child_process').spawn;
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const PORT = common.PORT;
|
|
||||||
const scriptToDebug = path.join(common.fixturesDir, 'empty.js');
|
|
||||||
|
|
||||||
// running with debug agent
|
|
||||||
const child = spawn(process.execPath, [`--debug-brk=${PORT}`, scriptToDebug]);
|
|
||||||
|
|
||||||
// connect to debug agent
|
|
||||||
const interfacer = spawn(process.execPath, ['debug', `localhost:${PORT}`]);
|
|
||||||
interfacer.stdout.setEncoding('utf-8');
|
|
||||||
|
|
||||||
// fail the test if either of the processes exit normally
|
|
||||||
const debugBreakExit = common.mustNotCall('child should not exit normally');
|
|
||||||
const debugExit = common.mustNotCall('interfacer should not exit normally');
|
|
||||||
child.on('exit', debugBreakExit);
|
|
||||||
interfacer.on('exit', debugExit);
|
|
||||||
|
|
||||||
let buffer = '';
|
|
||||||
const expected = [
|
|
||||||
`\bconnecting to localhost:${PORT} ... ok`,
|
|
||||||
'\bbreak in test/fixtures/empty.js:2'
|
|
||||||
];
|
|
||||||
const actual = [];
|
|
||||||
interfacer.stdout.on('data', function(data) {
|
|
||||||
data = (buffer + data).split('\n');
|
|
||||||
buffer = data.pop();
|
|
||||||
data.forEach(function(line) {
|
|
||||||
interfacer.emit('line', line);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
interfacer.on('line', function(line) {
|
|
||||||
line = line.replace(/^(debug> *)+/, '');
|
|
||||||
if (expected.includes(line)) {
|
|
||||||
actual.push(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// allow time to start up the debugger
|
|
||||||
setTimeout(function() {
|
|
||||||
// remove the exit handlers before killing the processes
|
|
||||||
child.removeListener('exit', debugBreakExit);
|
|
||||||
interfacer.removeListener('exit', debugExit);
|
|
||||||
|
|
||||||
child.kill();
|
|
||||||
interfacer.kill();
|
|
||||||
}, common.platformTimeout(2000));
|
|
||||||
|
|
||||||
process.on('exit', function() {
|
|
||||||
// additional checks to ensure that both the processes were actually killed
|
|
||||||
assert(child.killed);
|
|
||||||
assert(interfacer.killed);
|
|
||||||
assert.deepStrictEqual(actual, expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
interfacer.stderr.pipe(process.stderr);
|
|
18
test/fixtures/debug-uncaught-async.js
vendored
18
test/fixtures/debug-uncaught-async.js
vendored
@ -1,18 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const debug = require('_debugger');
|
|
||||||
|
|
||||||
function emit() {
|
|
||||||
const error = new Error('fhqwhgads');
|
|
||||||
process.emit('uncaughtException', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.doesNotThrow(emit);
|
|
||||||
|
|
||||||
// Send debug.start() an argv array of length 1 to avoid code that exits
|
|
||||||
// if argv is empty.
|
|
||||||
debug.start(['sterrance']);
|
|
||||||
|
|
||||||
setImmediate(emit);
|
|
16
test/fixtures/debug-uncaught.js
vendored
16
test/fixtures/debug-uncaught.js
vendored
@ -1,16 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const debug = require('_debugger');
|
|
||||||
|
|
||||||
function emit() {
|
|
||||||
const error = new Error('sterrance');
|
|
||||||
process.emit('uncaughtException', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.doesNotThrow(emit);
|
|
||||||
|
|
||||||
debug.start(['fhqwhgads']);
|
|
||||||
|
|
||||||
emit();
|
|
@ -1,99 +0,0 @@
|
|||||||
/* eslint-disable no-debugger */
|
|
||||||
// Flags: --expose_internals
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const cluster = require('cluster');
|
|
||||||
const net = require('net');
|
|
||||||
|
|
||||||
const Protocol = require('_debugger').Protocol;
|
|
||||||
|
|
||||||
if (common.isWindows) {
|
|
||||||
common.skip('SCHED_RR not reliable on Windows');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cluster.schedulingPolicy = cluster.SCHED_RR;
|
|
||||||
|
|
||||||
// Worker sends back a "I'm here" message, then immediately suspends
|
|
||||||
// inside the debugger. The master connects to the debug agent first,
|
|
||||||
// connects to the TCP server second, then disconnects the worker and
|
|
||||||
// unsuspends it again. The ultimate goal of this tortured exercise
|
|
||||||
// is to make sure the connection is still sitting in the master's
|
|
||||||
// pending handle queue.
|
|
||||||
if (cluster.isMaster) {
|
|
||||||
let isKilling = false;
|
|
||||||
const handles = require('internal/cluster/utils').handles;
|
|
||||||
const address = common.hasIPv6 ? '[::1]' : common.localhostIPv4;
|
|
||||||
cluster.setupMaster({ execArgv: [`--debug=${address}:${common.PORT}`] });
|
|
||||||
const worker = cluster.fork();
|
|
||||||
worker.once('exit', common.mustCall((code, signal) => {
|
|
||||||
assert.strictEqual(code, 0, 'worker did not exit normally');
|
|
||||||
assert.strictEqual(signal, null, 'worker did not exit normally');
|
|
||||||
}));
|
|
||||||
worker.on('message', common.mustCall((message) => {
|
|
||||||
assert.strictEqual(Array.isArray(message), true);
|
|
||||||
assert.strictEqual(message[0], 'listening');
|
|
||||||
let continueRecv = false;
|
|
||||||
const address = message[1];
|
|
||||||
const host = address.address;
|
|
||||||
const debugClient = net.connect({ host, port: common.PORT });
|
|
||||||
const protocol = new Protocol();
|
|
||||||
debugClient.setEncoding('utf8');
|
|
||||||
debugClient.on('data', (data) => protocol.execute(data));
|
|
||||||
debugClient.once('connect', common.mustCall(() => {
|
|
||||||
protocol.onResponse = common.mustCall((res) => {
|
|
||||||
protocol.onResponse = (res) => {
|
|
||||||
// It can happen that the first continue was sent before the break
|
|
||||||
// event was received. If that's the case, send also a continue from
|
|
||||||
// here so the worker exits
|
|
||||||
if (res.body.command === 'continue') {
|
|
||||||
continueRecv = true;
|
|
||||||
} else if (res.body.event === 'break' && continueRecv) {
|
|
||||||
const req = protocol.serialize({ command: 'continue' });
|
|
||||||
debugClient.write(req);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const conn = net.connect({ host, port: address.port });
|
|
||||||
conn.once('connect', common.mustCall(() => {
|
|
||||||
conn.destroy();
|
|
||||||
assert.notDeepStrictEqual(handles, {});
|
|
||||||
worker.disconnect();
|
|
||||||
assert.deepStrictEqual(handles, {});
|
|
||||||
// Always send the continue, as the break event might have already
|
|
||||||
// been received.
|
|
||||||
const req = protocol.serialize({ command: 'continue' });
|
|
||||||
debugClient.write(req);
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}));
|
|
||||||
process.on('exit', () => assert.deepStrictEqual(handles, {}));
|
|
||||||
process.on('uncaughtException', function(ex) {
|
|
||||||
// Make sure we clean up so as not to leave a stray worker process running
|
|
||||||
// if we encounter a connection or other error
|
|
||||||
if (!worker.isDead()) {
|
|
||||||
if (!isKilling) {
|
|
||||||
isKilling = true;
|
|
||||||
worker.once('exit', function() {
|
|
||||||
throw ex;
|
|
||||||
});
|
|
||||||
worker.process.kill();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw ex;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const server = net.createServer((socket) => socket.pipe(socket));
|
|
||||||
const cb = () => {
|
|
||||||
process.send(['listening', server.address()]);
|
|
||||||
debugger;
|
|
||||||
};
|
|
||||||
if (common.hasIPv6)
|
|
||||||
server.listen(0, '::1', cb);
|
|
||||||
else
|
|
||||||
server.listen(0, common.localhostIPv4, cb);
|
|
||||||
process.on('disconnect', process.exit);
|
|
||||||
}
|
|
@ -11,5 +11,5 @@ RangeError: Invalid input
|
|||||||
at Module.load (module.js:*:*)
|
at Module.load (module.js:*:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*:*)
|
at Function.Module._load (module.js:*:*)
|
||||||
at Module.runMain (module.js:*:*)
|
at Function.Module.runMain (module.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
|
@ -10,7 +10,6 @@ AssertionError: 1 === 2
|
|||||||
at Module.load (module.js:*:*)
|
at Module.load (module.js:*:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*:*)
|
at Function.Module._load (module.js:*:*)
|
||||||
at Module.runMain (module.js:*:*)
|
at Function.Module.runMain (module.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at startup (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
at bootstrap_node.js:*:*
|
at bootstrap_node.js:*:*
|
||||||
|
@ -8,8 +8,6 @@ SyntaxError: Strict mode code may not include a with statement
|
|||||||
at Object.<anonymous> ([eval]-wrapper:*:*)
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
||||||
at Module._compile (module.js:*:*)
|
at Module._compile (module.js:*:*)
|
||||||
at evalScript (bootstrap_node.js:*:*)
|
at evalScript (bootstrap_node.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at startup (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
at bootstrap_node.js:*:*
|
at bootstrap_node.js:*:*
|
||||||
42
|
42
|
||||||
@ -25,8 +23,6 @@ Error: hello
|
|||||||
at Object.<anonymous> ([eval]-wrapper:*:*)
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
||||||
at Module._compile (module.js:*:*)
|
at Module._compile (module.js:*:*)
|
||||||
at evalScript (bootstrap_node.js:*:*)
|
at evalScript (bootstrap_node.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at startup (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
at bootstrap_node.js:*:*
|
at bootstrap_node.js:*:*
|
||||||
|
|
||||||
@ -41,8 +37,6 @@ Error: hello
|
|||||||
at Object.<anonymous> ([eval]-wrapper:*:*)
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
||||||
at Module._compile (module.js:*:*)
|
at Module._compile (module.js:*:*)
|
||||||
at evalScript (bootstrap_node.js:*:*)
|
at evalScript (bootstrap_node.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at startup (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
at bootstrap_node.js:*:*
|
at bootstrap_node.js:*:*
|
||||||
100
|
100
|
||||||
@ -57,8 +51,6 @@ ReferenceError: y is not defined
|
|||||||
at Object.<anonymous> ([eval]-wrapper:*:*)
|
at Object.<anonymous> ([eval]-wrapper:*:*)
|
||||||
at Module._compile (module.js:*:*)
|
at Module._compile (module.js:*:*)
|
||||||
at evalScript (bootstrap_node.js:*:*)
|
at evalScript (bootstrap_node.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at startup (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
at bootstrap_node.js:*:*
|
at bootstrap_node.js:*:*
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ ReferenceError: undefined_reference_error_maker is not defined
|
|||||||
at *test*message*nexttick_throw.js:*:*
|
at *test*message*nexttick_throw.js:*:*
|
||||||
at _combinedTickCallback (internal/process/next_tick.js:*:*)
|
at _combinedTickCallback (internal/process/next_tick.js:*:*)
|
||||||
at process._tickCallback (internal/process/next_tick.js:*:*)
|
at process._tickCallback (internal/process/next_tick.js:*:*)
|
||||||
at Module.runMain (module.js:*:*)
|
at Function.Module.runMain (module.js:*:*)
|
||||||
at run (bootstrap_node.js:*:*)
|
|
||||||
at startup (bootstrap_node.js:*:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
at bootstrap_node.js:*:*
|
at bootstrap_node.js:*:*
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
at *
|
at *
|
||||||
at *
|
at *
|
||||||
at *
|
at *
|
||||||
at *
|
|
||||||
(node:*) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
|
(node:*) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
|
||||||
at *
|
at *
|
||||||
at *
|
at *
|
||||||
@ -18,7 +17,6 @@
|
|||||||
at *
|
at *
|
||||||
at *
|
at *
|
||||||
at *
|
at *
|
||||||
at *
|
|
||||||
(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
|
(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
|
||||||
at getAsynchronousRejectionWarningObject (internal/process/promises.js:*)
|
at getAsynchronousRejectionWarningObject (internal/process/promises.js:*)
|
||||||
at rejectionHandled (internal/process/promises.js:*)
|
at rejectionHandled (internal/process/promises.js:*)
|
||||||
|
@ -13,4 +13,4 @@ Error: boo!
|
|||||||
at Module.load (module.js:*)
|
at Module.load (module.js:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*)
|
at Function.Module._load (module.js:*)
|
||||||
at Module.runMain (module.js:*)
|
at Function.Module.runMain (module.js:*)
|
||||||
|
@ -11,8 +11,8 @@ SyntaxError: Unexpected number
|
|||||||
at Module.load (module.js:*)
|
at Module.load (module.js:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*)
|
at Function.Module._load (module.js:*)
|
||||||
at Module.runMain (module.js:*)
|
at Function.Module.runMain (module.js:*)
|
||||||
at run (bootstrap_node.js:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
test.vm:1
|
test.vm:1
|
||||||
var 5;
|
var 5;
|
||||||
^
|
^
|
||||||
@ -25,5 +25,5 @@ SyntaxError: Unexpected number
|
|||||||
at Module.load (module.js:*)
|
at Module.load (module.js:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*)
|
at Function.Module._load (module.js:*)
|
||||||
at Module.runMain (module.js:*)
|
at Function.Module.runMain (module.js:*)
|
||||||
at run (bootstrap_node.js:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
|
@ -14,4 +14,4 @@ Error: boo!
|
|||||||
at Module.load (module.js:*)
|
at Module.load (module.js:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*)
|
at Function.Module._load (module.js:*)
|
||||||
at Module.runMain (module.js:*)
|
at Function.Module.runMain (module.js:*)
|
||||||
|
@ -13,5 +13,5 @@ SyntaxError: Unexpected number
|
|||||||
at Module.load (module.js:*)
|
at Module.load (module.js:*)
|
||||||
at tryModuleLoad (module.js:*:*)
|
at tryModuleLoad (module.js:*:*)
|
||||||
at Function.Module._load (module.js:*)
|
at Function.Module._load (module.js:*)
|
||||||
at Module.runMain (module.js:*)
|
at Function.Module.runMain (module.js:*)
|
||||||
at run (bootstrap_node.js:*)
|
at startup (bootstrap_node.js:*:*)
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const debug = require('_debugger');
|
|
||||||
|
|
||||||
const protocol = new debug.Protocol();
|
|
||||||
|
|
||||||
assert.strictEqual(protocol.state, 'headers');
|
|
||||||
|
|
||||||
protocol.execute('Content-Length: 10\r\n\r\nfhqwhgads');
|
|
||||||
|
|
||||||
assert.strictEqual(protocol.state, 'body');
|
|
||||||
assert.strictEqual(protocol.res.body, undefined);
|
|
||||||
|
|
||||||
protocol.state = 'sterrance';
|
|
||||||
assert.throws(
|
|
||||||
() => { protocol.execute('grumblecakes'); },
|
|
||||||
/^Error: Unknown state$/
|
|
||||||
);
|
|
@ -1,22 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const path = require('path');
|
|
||||||
const spawn = require('child_process').spawn;
|
|
||||||
|
|
||||||
const emitUncaught = path.join(common.fixturesDir, 'debug-uncaught-async.js');
|
|
||||||
const result = spawn(process.execPath, [emitUncaught], {encoding: 'utf8'});
|
|
||||||
|
|
||||||
let stderr = '';
|
|
||||||
result.stderr.on('data', (data) => {
|
|
||||||
stderr += data;
|
|
||||||
});
|
|
||||||
|
|
||||||
result.on('close', (code) => {
|
|
||||||
const expectedMessage =
|
|
||||||
"There was an internal error in Node's debugger. Please report this bug.";
|
|
||||||
|
|
||||||
assert.strictEqual(code, 1);
|
|
||||||
assert(stderr.includes(expectedMessage));
|
|
||||||
assert(stderr.includes('Error: fhqwhgads'));
|
|
||||||
});
|
|
@ -1,17 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const common = require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const path = require('path');
|
|
||||||
const spawnSync = require('child_process').spawnSync;
|
|
||||||
|
|
||||||
const emitUncaught = path.join(common.fixturesDir, 'debug-uncaught.js');
|
|
||||||
const result = spawnSync(process.execPath, [emitUncaught], {encoding: 'utf8'});
|
|
||||||
|
|
||||||
const expectedMessage =
|
|
||||||
"There was an internal error in Node's debugger. Please report this bug.";
|
|
||||||
|
|
||||||
assert.strictEqual(result.status, 1);
|
|
||||||
assert(result.stderr.includes(expectedMessage));
|
|
||||||
assert(result.stderr.includes('Error: sterrance'));
|
|
||||||
|
|
||||||
console.log(result.stdout);
|
|
@ -1,44 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
require('../common');
|
|
||||||
const assert = require('assert');
|
|
||||||
const Client = require('_debugger').Client;
|
|
||||||
|
|
||||||
{
|
|
||||||
const client = new Client();
|
|
||||||
assert.deepStrictEqual(client.handles, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const client = new Client();
|
|
||||||
client._addHandle(null);
|
|
||||||
assert.deepStrictEqual(client.handles, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const client = new Client();
|
|
||||||
client._addHandle('not an object');
|
|
||||||
assert.deepStrictEqual(client.handles, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const client = new Client();
|
|
||||||
client._addHandle({ handle: 'not a number' });
|
|
||||||
assert.deepStrictEqual(client.handles, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const client = new Client();
|
|
||||||
const validNoScript = { handle: 6, id: 'foo', type: 'not a script' };
|
|
||||||
client._addHandle(validNoScript);
|
|
||||||
assert.deepStrictEqual(client.handles, { 6: validNoScript });
|
|
||||||
assert.deepStrictEqual(client.scripts, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const client = new Client();
|
|
||||||
const validWithScript = { handle: 5, id: 'bar', type: 'script' };
|
|
||||||
client._addHandle(validWithScript);
|
|
||||||
assert.deepStrictEqual(client.handles, { 5: validWithScript });
|
|
||||||
assert.deepStrictEqual(client.scripts, { bar: validWithScript });
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user