|
@ -16,19 +16,9 @@ exports.start = function () { |
|
|
var child; |
|
|
var child; |
|
|
var c; |
|
|
var c; |
|
|
var term; |
|
|
var term; |
|
|
|
|
|
var args = process.argv.slice(2); |
|
|
|
|
|
args.unshift('--debug-brk'); |
|
|
|
|
|
|
|
|
function trySpawn(cb) { |
|
|
|
|
|
var args = process.argv.slice(2); |
|
|
|
|
|
args.unshift('--debug-brk'); |
|
|
|
|
|
|
|
|
|
|
|
console.log(args); |
|
|
|
|
|
|
|
|
|
|
|
child = spawn(process.execPath, args, { customFds: [0, 1, 2] }); |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
tryConnect(cb); |
|
|
|
|
|
}, 100); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function tryConnect(cb) { |
|
|
function tryConnect(cb) { |
|
|
c = new Client(); |
|
|
c = new Client(); |
|
@ -84,6 +74,27 @@ function tryConnect(cb) { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function trySpawn(cb) { |
|
|
|
|
|
if (child) { |
|
|
|
|
|
child.kill(); |
|
|
|
|
|
child = null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (c) { |
|
|
|
|
|
c.destroy(); |
|
|
|
|
|
c = null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
child = spawn(process.execPath, args, { customFds: [0, 1, 2] }); |
|
|
|
|
|
|
|
|
|
|
|
console.log("trySpawn"); |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
console.log("after timeout"); |
|
|
|
|
|
tryConnect(cb); |
|
|
|
|
|
}, 1000); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//
|
|
|
//
|
|
|
// Parser/Serializer for V8 debugger protocol
|
|
|
// Parser/Serializer for V8 debugger protocol
|
|
|
// http://code.google.com/p/v8/wiki/DebuggerProtocol
|
|
|
// http://code.google.com/p/v8/wiki/DebuggerProtocol
|
|
@ -305,7 +316,7 @@ Client.prototype.step = function(action, count, cb) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var helpMessage = "Commands: print, step, next, continue, scripts, backtrace, version, quit"; |
|
|
var helpMessage = "Commands: run, print, step, next, continue, scripts, backtrace, version, quit"; |
|
|
|
|
|
|
|
|
function SourceUnderline(source_text, position) { |
|
|
function SourceUnderline(source_text, position) { |
|
|
if (!source_text) { |
|
|
if (!source_text) { |
|
@ -348,6 +359,23 @@ function SourceInfo(body) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var restartQuestionPrompt = "The program being debugged has " + |
|
|
|
|
|
"been started already.\n" + |
|
|
|
|
|
"Start it from the beginning? (y or n): "; |
|
|
|
|
|
|
|
|
|
|
|
function restartQuestion (cb) { |
|
|
|
|
|
term.question(restartQuestionPrompt, function (answer) { |
|
|
|
|
|
if (/^y(es)?$/i.test(answer)) { |
|
|
|
|
|
cb(true); |
|
|
|
|
|
} else if (/^n(o)?$/i.test(answer)) { |
|
|
|
|
|
cb(false); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log("Please answer y or n."); |
|
|
|
|
|
restartQuestion(cb); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function startInterface() { |
|
|
function startInterface() { |
|
|
|
|
|
|
|
@ -387,11 +415,26 @@ function startInterface() { |
|
|
tryQuit(); |
|
|
tryQuit(); |
|
|
|
|
|
|
|
|
} else if (/^r(un)?/.test(cmd)) { |
|
|
} else if (/^r(un)?/.test(cmd)) { |
|
|
trySpawn(function () { |
|
|
if (child) { |
|
|
c.reqContinue(function (res) { |
|
|
restartQuestion(function (yes) { |
|
|
// Wait for break point. (disable raw mode?)
|
|
|
if (!yes) { |
|
|
|
|
|
term.prompt(); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log("restarting..."); |
|
|
|
|
|
trySpawn(function () { |
|
|
|
|
|
c.reqContinue(function (res) { |
|
|
|
|
|
// Wait for break point. (disable raw mode?)
|
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
|
|
|
trySpawn(function () { |
|
|
|
|
|
c.reqContinue(function (res) { |
|
|
|
|
|
// Wait for break point. (disable raw mode?)
|
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else if (/^help/.test(cmd)) { |
|
|
} else if (/^help/.test(cmd)) { |
|
|
console.log(helpMessage); |
|
|
console.log(helpMessage); |
|
|