|
@ -278,7 +278,8 @@ Client.prototype.step = function(action, count, cb) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var helpMessage = "Commands: run, print, step, next, continue, scripts, backtrace, version, quit"; |
|
|
var helpMessage = "Commands: run, kill, print, step, next, " + |
|
|
|
|
|
"continue, scripts, backtrace, version, quit"; |
|
|
|
|
|
|
|
|
function SourceUnderline(sourceText, position) { |
|
|
function SourceUnderline(sourceText, position) { |
|
|
if (!sourceText) return; |
|
|
if (!sourceText) return; |
|
@ -420,10 +421,15 @@ Interface.prototype.handleCommand = function(cmd) { |
|
|
if (self.child) { |
|
|
if (self.child) { |
|
|
self.restartQuestion(function (yes) { |
|
|
self.restartQuestion(function (yes) { |
|
|
if (!yes) { |
|
|
if (!yes) { |
|
|
|
|
|
self._lastCommand = null; |
|
|
term.prompt(); |
|
|
term.prompt(); |
|
|
} else { |
|
|
} else { |
|
|
console.log("restarting..."); |
|
|
console.log("restarting..."); |
|
|
|
|
|
self.killChild(); |
|
|
|
|
|
// XXX need to wait a little bit for the restart to work?
|
|
|
|
|
|
setTimeout(function () { |
|
|
self.trySpawn(); |
|
|
self.trySpawn(); |
|
|
|
|
|
}, 1000); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
@ -488,9 +494,22 @@ Interface.prototype.handleCommand = function(cmd) { |
|
|
self.printNotConnected(); |
|
|
self.printNotConnected(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
client.reqContinue(function (res) { |
|
|
client.reqContinue(); |
|
|
// Wait for break point. (disable raw mode?)
|
|
|
|
|
|
|
|
|
} else if (/^k(ill)?/.test(cmd)) { |
|
|
|
|
|
// kill
|
|
|
|
|
|
if (self.child) { |
|
|
|
|
|
self.killQuestion(function (yes) { |
|
|
|
|
|
if (yes) { |
|
|
|
|
|
self.killChild(); |
|
|
|
|
|
} else { |
|
|
|
|
|
self._lastCommand = null; |
|
|
|
|
|
} |
|
|
|
|
|
self.term.prompt(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
self.term.prompt(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else if (/^next/.test(cmd) || /^n/.test(cmd)) { |
|
|
} else if (/^next/.test(cmd) || /^n/.test(cmd)) { |
|
|
if (!client) { |
|
|
if (!client) { |
|
@ -541,13 +560,10 @@ Interface.prototype.handleCommand = function(cmd) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var restartQuestionPrompt = "The program being debugged has " + |
|
|
|
|
|
"been started already.\n" + |
|
|
|
|
|
"Start it from the beginning? (y or n): "; |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.restartQuestion = function(cb) { |
|
|
Interface.prototype.yesNoQuestion = function(prompt, cb) { |
|
|
var self = this; |
|
|
var self = this; |
|
|
this.term.question(restartQuestionPrompt, function (answer) { |
|
|
this.term.question(prompt, function (answer) { |
|
|
if (/^y(es)?$/i.test(answer)) { |
|
|
if (/^y(es)?$/i.test(answer)) { |
|
|
cb(true); |
|
|
cb(true); |
|
|
} else if (/^n(o)?$/i.test(answer)) { |
|
|
} else if (/^n(o)?$/i.test(answer)) { |
|
@ -560,16 +576,27 @@ Interface.prototype.restartQuestion = function(cb) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.killChild = function() { |
|
|
Interface.prototype.restartQuestion = function(cb) { |
|
|
if (this.client) { |
|
|
this.yesNoQuestion("The program being debugged has been started already.\n" + |
|
|
this.client.destroy(); |
|
|
"Start it from the beginning? (y or n) ", cb); |
|
|
this.client = null; |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.killQuestion = function(cb) { |
|
|
|
|
|
this.yesNoQuestion("Kill the program being debugged? (y or n) ", cb); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.killChild = function() { |
|
|
if (this.child) { |
|
|
if (this.child) { |
|
|
this.child.kill(); |
|
|
this.child.kill(); |
|
|
this.child = null; |
|
|
this.child = null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.client) { |
|
|
|
|
|
this.client.destroy(); |
|
|
|
|
|
this.client = null; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -598,7 +625,6 @@ Interface.prototype.trySpawn = function(cb) { |
|
|
console.log("\nprogram terminated"); |
|
|
console.log("\nprogram terminated"); |
|
|
self.client = null; |
|
|
self.client = null; |
|
|
self.killChild(); |
|
|
self.killChild(); |
|
|
self.term.prompt(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
client.on('unhandledResponse', function (res) { |
|
|
client.on('unhandledResponse', function (res) { |
|
|