Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 08fb68c

Browse files
author
Matt Loring
committed
Enable maxFrames config option
1 parent 14ac9e4 commit 08fb68c

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ module.exports = {
4141

4242
// Maximum number of stack frames to capture data for. The limit is aimed
4343
// to reduce overall capture time
44-
// TODO: implement this
45-
//maxFrames: 20,
44+
maxFrames: 20,
4645

4746
// Only collect locals and arguments on a few top frames. For the rest
4847
// only collect the source location

lib/state.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,11 @@ StateResolver.prototype.trimVariableTable_ = function(fromIndex, frames) {
180180

181181
StateResolver.prototype.resolveFrames_ = function() {
182182
// TODO(ofrobots): only gather variables for top n frames (python: 5)
183-
// TODO(ofrobots): Do not gather the full stack trace (python: 20)
184183

185184
var frames = [];
186-
for (var i = 0; i < this.state_.frameCount(); i++) {
185+
var frameCount = Math.min(this.state_.frameCount(),
186+
this.config_.capture.maxFrames);
187+
for (var i = 0; i < frameCount; i++) {
187188
var frame = this.state_.frame(i);
188189
if (this.shouldFrameBeResolved_(frame)) {
189190
var resolveVars = i < this.config_.capture.maxExpandFrames;

test/test-v8debugapi.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,30 @@ describe('v8debugapi', function() {
336336
});
337337
});
338338

339+
it('should capture correct frame count', function(done) {
340+
// clone a clean breakpointInFoo
341+
var bp = {id: breakpointInFoo.id, location: breakpointInFoo.location};
342+
var oldMax = config.capture.maxFrames;
343+
config.capture.maxFrames = 1;
344+
api.set(bp, function(err) {
345+
assert.ifError(err);
346+
api.wait(bp, function(err) {
347+
assert.ifError(err);
348+
assert.ok(bp.stackFrames);
349+
assert.equal(bp.stackFrames.length, config.capture.maxFrames);
350+
var topFrame = bp.stackFrames[0];
351+
assert.ok(topFrame);
352+
assert.equal(topFrame['function'], 'foo');
353+
assert.equal(topFrame.arguments[0].name, 'n');
354+
assert.equal(topFrame.arguments[0].value, '2');
355+
api.clear(bp);
356+
config.capture.maxFrames = oldMax;
357+
done();
358+
});
359+
process.nextTick(function() {foo(2);});
360+
});
361+
});
362+
339363
it('should capture state with watch expressions', function(done) {
340364
// clone a clean breakpointInFoo
341365
var bp = {

0 commit comments

Comments
 (0)