debugger: Disable/Enable raw mode for child
This commit is contained in:
parent
0946474b5c
commit
62e0ca05a6
@ -43,6 +43,7 @@ var server = http.createServer(function (req, res) {
|
|||||||
|
|
||||||
if (command == "bytes") {
|
if (command == "bytes") {
|
||||||
var n = parseInt(arg, 10)
|
var n = parseInt(arg, 10)
|
||||||
|
debugger;
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
throw "bytes called with n <= 0"
|
throw "bytes called with n <= 0"
|
||||||
if (stored[n] === undefined) {
|
if (stored[n] === undefined) {
|
||||||
|
@ -310,6 +310,7 @@ function SourceUnderline(sourceText, position) {
|
|||||||
return sourceText + '\n' + underline;
|
return sourceText + '\n' + underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function SourceInfo(body) {
|
function SourceInfo(body) {
|
||||||
var result = '';
|
var result = '';
|
||||||
|
|
||||||
@ -340,8 +341,8 @@ function Interface() {
|
|||||||
self.killChild();
|
self.killChild();
|
||||||
});
|
});
|
||||||
|
|
||||||
var stdin = process.openStdin();
|
this.stdin = process.openStdin();
|
||||||
stdin.addListener('data', function(chunk) {
|
this.stdin.addListener('data', function(chunk) {
|
||||||
term.write(chunk);
|
term.write(chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -350,11 +351,13 @@ function Interface() {
|
|||||||
|
|
||||||
this.quitTried = false;
|
this.quitTried = false;
|
||||||
|
|
||||||
|
process.on('SIGINT', function () {
|
||||||
term.on('SIGINT', function () {
|
self.handleSIGINT();
|
||||||
self.tryQuit();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
term.on('SIGINT', function () {
|
||||||
|
self.handleSIGINT();
|
||||||
|
});
|
||||||
|
|
||||||
term.on('close', function () {
|
term.on('close', function () {
|
||||||
self.tryQuit();
|
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() {
|
Interface.prototype.tryQuit = function() {
|
||||||
if (this.quitTried) return;
|
if (this.quitTried) return;
|
||||||
this.quitTried = true;
|
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) {
|
Interface.prototype.handleBreak = function(r) {
|
||||||
var result = '';
|
var result = '';
|
||||||
if (r.breakpoints) {
|
if (r.breakpoints) {
|
||||||
@ -413,7 +442,7 @@ Interface.prototype.handleBreak = function(r) {
|
|||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
this.term.prompt();
|
if(!this.resume()) this.term.prompt();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -504,7 +533,11 @@ Interface.prototype.handleCommand = function(cmd) {
|
|||||||
self.printNotConnected();
|
self.printNotConnected();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.reqContinue();
|
|
||||||
|
self.pause();
|
||||||
|
client.reqContinue(function () {
|
||||||
|
self.resume();
|
||||||
|
});
|
||||||
|
|
||||||
} else if (/^k(ill)?/.test(cmd)) {
|
} else if (/^k(ill)?/.test(cmd)) {
|
||||||
if (!client) {
|
if (!client) {
|
||||||
@ -611,15 +644,21 @@ Interface.prototype.killChild = function() {
|
|||||||
this.client.destroy();
|
this.client.destroy();
|
||||||
this.client = null;
|
this.client = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.resume();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Interface.prototype.trySpawn = function(cb) {
|
Interface.prototype.trySpawn = function(cb) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
this.killChild();
|
this.killChild();
|
||||||
|
|
||||||
this.child = spawn(process.execPath, args, { customFds: [0, 1, 2] });
|
this.child = spawn(process.execPath, args, { customFds: [0, 1, 2] });
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
this.pause();
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
process.stdout.write("connecting...");
|
process.stdout.write("connecting...");
|
||||||
var client = self.client = new Client();
|
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
|
// since we did debug-brk, we're hitting a break point immediately
|
||||||
// continue before anything else.
|
// continue before anything else.
|
||||||
client.reqContinue();
|
client.reqContinue(function () {
|
||||||
|
if (cb) cb();
|
||||||
if (cb) cb();
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('close', function () {
|
client.on('close', function () {
|
||||||
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) {
|
||||||
|
@ -154,6 +154,20 @@ Interface.prototype.close = function(d) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Interface.prototype.pause = function() {
|
||||||
|
if (this.enabled) {
|
||||||
|
tty.setRawMode(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Interface.prototype.resume = function() {
|
||||||
|
if (this.enabled) {
|
||||||
|
tty.setRawMode(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Interface.prototype.write = function(d) {
|
Interface.prototype.write = function(d) {
|
||||||
if (this._closed) return;
|
if (this._closed) return;
|
||||||
return this.enabled ? this._ttyWrite(d) : this._normalWrite(d);
|
return this.enabled ? this._ttyWrite(d) : this._normalWrite(d);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user