debugger: fix backtrace with no frames

Fixes #1768
This commit is contained in:
Fedor Indutny 2011-09-26 02:20:47 +07:00 committed by Ryan Dahl
parent 02e0a0aa10
commit c26cf84a08
3 changed files with 25 additions and 1 deletions

View File

@ -587,6 +587,7 @@ Client.prototype.fullTrace = function(cb) {
this.reqBacktrace(function(err, trace) {
if (err) return cb(err);
if (trace.totalFrames <= 0) return cb(Error('No frames'));
var refs = [];
@ -615,6 +616,8 @@ Client.prototype.fullTrace = function(cb) {
}
self.reqLookup(refs, function(res) {
if (!res.success) return cb(res.message || true);
for (var i = 0; i < trace.frames.length; i++) {
var frame = trace.frames[i];
frame.script = res.body[frame.script.ref];
@ -1104,7 +1107,7 @@ Interface.prototype.backtrace = function() {
self.pause();
client.fullTrace(function(err, bt) {
if (err) return self.error(err);
if (err) return self.error('Can\'t request backtrace now');
if (bt.totalFrames == 0) {
self.print('(empty stack)');
} else {

View File

@ -14,3 +14,8 @@ a();
a(1);
b();
b();
setInterval(function() {
}, 5000);

View File

@ -43,6 +43,7 @@ child.stderr.pipe(process.stdout);
var expected = [];
child.on('line', function(line) {
console.log(JSON.stringify(line));
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
var expectedLine = expected[0].lines.shift();
@ -110,6 +111,21 @@ addTest('o', [
"\b 16 b();"
]);
// Continue
addTest('c', [
"debug> debug> debug> \bbreak in [unnamed]:7",
"\b 5 var i = 10;",
"\b 6 while (--i != 0);",
"\b 7 debugger;",
"\b 8 return i;",
"\b 9 };"
]);
// Continue
addTest('c, bt', [
"debug> \bCan't request backtrace now"
]);
function finish() {
process.exit(0);