|
|
@ -310,6 +310,7 @@ function SourceUnderline(sourceText, position) { |
|
|
|
return sourceText + '\n' + underline; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function SourceInfo(body) { |
|
|
|
var result = ''; |
|
|
|
|
|
|
@ -340,8 +341,8 @@ function Interface() { |
|
|
|
self.killChild(); |
|
|
|
}); |
|
|
|
|
|
|
|
var stdin = process.openStdin(); |
|
|
|
stdin.addListener('data', function(chunk) { |
|
|
|
this.stdin = process.openStdin(); |
|
|
|
this.stdin.addListener('data', function(chunk) { |
|
|
|
term.write(chunk); |
|
|
|
}); |
|
|
|
|
|
|
@ -350,12 +351,14 @@ function Interface() { |
|
|
|
|
|
|
|
this.quitTried = false; |
|
|
|
|
|
|
|
process.on('SIGINT', function () { |
|
|
|
self.handleSIGINT(); |
|
|
|
}); |
|
|
|
|
|
|
|
term.on('SIGINT', function () { |
|
|
|
self.tryQuit(); |
|
|
|
self.handleSIGINT(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
term.on('close', function () { |
|
|
|
self.tryQuit(); |
|
|
|
}); |
|
|
@ -374,6 +377,15 @@ function Interface() { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.handleSIGINT = function() { |
|
|
|
if (this.paused) { |
|
|
|
this.child.kill('SIGINT'); |
|
|
|
} else { |
|
|
|
this.tryQuit(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.tryQuit = function() { |
|
|
|
if (this.quitTried) return; |
|
|
|
this.quitTried = true; |
|
|
@ -383,6 +395,23 @@ Interface.prototype.tryQuit = function() { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.pause = function() { |
|
|
|
this.paused = true; |
|
|
|
this.stdin.pause(); |
|
|
|
this.term.pause(); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.resume = function() { |
|
|
|
if (!this.paused) return false |
|
|
|
this.paused = false; |
|
|
|
this.stdin.resume(); |
|
|
|
this.term.resume(); |
|
|
|
this.term.prompt(); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.handleBreak = function(r) { |
|
|
|
var result = ''; |
|
|
|
if (r.breakpoints) { |
|
|
@ -413,7 +442,7 @@ Interface.prototype.handleBreak = function(r) { |
|
|
|
|
|
|
|
console.log(result); |
|
|
|
|
|
|
|
this.term.prompt(); |
|
|
|
if(!this.resume()) this.term.prompt(); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -504,7 +533,11 @@ Interface.prototype.handleCommand = function(cmd) { |
|
|
|
self.printNotConnected(); |
|
|
|
return; |
|
|
|
} |
|
|
|
client.reqContinue(); |
|
|
|
|
|
|
|
self.pause(); |
|
|
|
client.reqContinue(function () { |
|
|
|
self.resume(); |
|
|
|
}); |
|
|
|
|
|
|
|
} else if (/^k(ill)?/.test(cmd)) { |
|
|
|
if (!client) { |
|
|
@ -611,15 +644,21 @@ Interface.prototype.killChild = function() { |
|
|
|
this.client.destroy(); |
|
|
|
this.client = null; |
|
|
|
} |
|
|
|
|
|
|
|
this.resume(); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Interface.prototype.trySpawn = function(cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
this.killChild(); |
|
|
|
|
|
|
|
this.child = spawn(process.execPath, args, { customFds: [0, 1, 2] }); |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
this.pause(); |
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
process.stdout.write("connecting..."); |
|
|
|
var client = self.client = new Client(); |
|
|
@ -630,15 +669,16 @@ Interface.prototype.trySpawn = function(cb) { |
|
|
|
|
|
|
|
// since we did debug-brk, we're hitting a break point immediately
|
|
|
|
// continue before anything else.
|
|
|
|
client.reqContinue(); |
|
|
|
|
|
|
|
if (cb) cb(); |
|
|
|
client.reqContinue(function () { |
|
|
|
if (cb) cb(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
client.on('close', function () { |
|
|
|
console.log("\nprogram terminated"); |
|
|
|
self.client = null; |
|
|
|
self.killChild(); |
|
|
|
self.term.prompt(); |
|
|
|
}); |
|
|
|
|
|
|
|
client.on('unhandledResponse', function (res) { |
|
|
|