Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
debugger: fix backtrace with no frames
Browse files Browse the repository at this point in the history
Fixes #1768
  • Loading branch information
indutny authored and ry committed Sep 26, 2011
1 parent 02e0a0a commit c26cf84
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/_debugger.js
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/breakpoints.js
Expand Up @@ -14,3 +14,8 @@ a();
a(1);
b();
b();



setInterval(function() {
}, 5000);
16 changes: 16 additions & 0 deletions test/simple/test-debugger-repl.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c26cf84

Please sign in to comment.