Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 08, 2011
@mootoh mootoh added debugHost for remote debugging. 5154aa5
Commits on Jun 17, 2011
Fuji Goro Tweaks for output messages 60e9104
Commits on Jun 27, 2011
Fuji Goro Add --debug-host and --debug-port options 88e7fb4
Showing with 34 additions and 12 deletions.
  1. +20 −4 bin/inspector.js
  2. +6 −3 lib/debug-server.js
  3. +3 −2 lib/debugger.js
  4. +5 −3 lib/session.js
View
24 bin/inspector.js
@@ -3,7 +3,10 @@
var dserver = require('../lib/debug-server'),
fs = require('fs'),
path = require('path'),
- options = {};
+ options = { // default settings
+ debugPort: 5858,
+ webPort: 8080,
+ };
process.argv.forEach(function (arg) {
var parts;
@@ -15,6 +18,12 @@ process.argv.forEach(function (arg) {
case '--agent-port':
options.webPort = parseInt(parts[1], 10);
break;
+ case '--debug-port':
+ options.debugPort = parseInt(parts[1], 10);
+ break;
+ case '--debug-host':
+ options.debugHost = parts[1];
+ break;
default:
console.log('unknown option: ' + parts[0]);
break;
@@ -23,7 +32,11 @@ process.argv.forEach(function (arg) {
else if (parts[0] === '--help') {
console.log('Usage: node [node_options] debug-agent.js [options]');
console.log('Options:');
- console.log('--web-port=[port] port to host the inspector (default 8080)');
+ console.log('--web-port=[port] port to host the inspector (default %s)', webPort);
+ console.log('--debug-port=[port] port to the debuggee (default %s)',
+ options.debugPort);
+ console.log('--debug-host=[host] host to the debuggee (default localhost)',
+ options.debugHost);
process.exit();
}
}
@@ -44,10 +57,13 @@ fs.readFile(path.join(__dirname, '../config.json'), function(err, data) {
}
}
if (!config.webPort) {
- config.webPort = 8080;
+ config.webPort = options.webPort;
}
if (!config.debugPort) {
- config.debugPort = 5858;
+ config.debugPort = options.debugPort;
+ }
+ if(!config.debugHost) {
+ config.debugHost = options.debugHost;
}
dserver.create(options, config).on('close', function () {
console.log('session closed');
View
9 lib/debug-server.js
@@ -25,12 +25,13 @@ exports.create = function(options, config) {
settings = override(options || {}, defaults),
httpServer = Http.createServer(staticFile),
wsServer = WebSocket.createServer({server: httpServer}),
- debugPort = config.debugPort.toString();
+ debugPort = config.debugPort.toString(),
+ debugHost = config.debugHost ? config.debugHost.toString() : null;
wsServer.on('connection', function(conn) {
var port =
parseInt((/\?port=(\d+)/.exec(conn._req.url) || [null, debugPort])[1], 10),
- session = Session.create(conn, debugr, port, config);
+ session = Session.create(conn, debugr, port, debugHost, config);
conn.on('message', function(data) {
session.handleRequest(data);
@@ -47,7 +48,9 @@ exports.create = function(options, config) {
console.log(
'visit http://0.0.0.0:' +
settings.webPort +
- '/debug?port=5858 to start debugging');
+ '/debug?port=' +
+ debugPort +
+ ' to start debugging');
});
return Object.create(EventEmitter.prototype, {
View
5 lib/debugger.js
@@ -14,11 +14,11 @@ function makeMessage() {
///////////////////////////////////////////////////////////
// exports
-exports.attachDebugger = function(port) {
+exports.attachDebugger = function(port, host) {
var connected = false,
debugBuffer = '',
msg = false,
- conn = Net.createConnection(port),
+ conn = host ? Net.createConnection(port, host) : Net.createConnection(port),
debugr,
offset,
contentLengthMatch;
@@ -127,6 +127,7 @@ exports.attachDebugger = function(port) {
debugr.emit('close');
});
+ console.log("attachDebugger %s:%s", host, port);
return debugr;
};
View
8 lib/session.js
@@ -5,7 +5,7 @@ var http = require('http'),
///////////////////////////////////////////////////////////
// exports
-exports.create = function(conn, debugr, debuggerPort, config) {
+exports.create = function(conn, debugr, debuggerPort, debuggerHost, config) {
var debug = null,
//map from sourceID:lineNumber to breakpoint
breakpoints = {},
@@ -232,7 +232,7 @@ exports.create = function(conn, debugr, debuggerPort, config) {
}
function attach() {
- debug = debugr.attachDebugger(debuggerPort);
+ debug = debugr.attachDebugger(debuggerPort, debuggerHost);
debug.on('break', breakEvent);
debug.on('close', function() {
//TODO determine proper close behavior
@@ -244,6 +244,7 @@ exports.create = function(conn, debugr, debuggerPort, config) {
sendEvent('debuggerWasDisabled');
});
debug.on('connect', function() {
+ console.log("debugger connected\n");
sendEvent('debuggerWasEnabled');
var args = { arguments: { includeSource: true, types: 4 }};
debug.request('scripts', args, function(msg) {
@@ -275,6 +276,7 @@ exports.create = function(conn, debugr, debuggerPort, config) {
breakEvent(msg);
});
debug.on('error', function(e) {
+ console.log("debugger error: %s", e);
sendEvent('showPanel', { name: 'console' });
var err = e.toString(), data;
if (err.match(/ECONNREFUSED/)) {
@@ -693,7 +695,7 @@ exports.create = function(conn, debugr, debuggerPort, config) {
debug.request('flags', params, function(msg) {
var value = 0;
if (msg.success) {
- if (msg.body.flags.some(function(x) {
+ if (msg.body && msg.body.flags.some(function(x) {
return x.name === 'breakOnCaughtException' && x.value})) {
value = 1;
}

No commit comments for this range

Something went wrong with that request. Please try again.