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

Commit 474c2dc

Browse files
Remove misleading arguments/locals message (#220)
When within the frame capture range omit status messages declaming that arguments/locals are only captured for frames in the capture range. 01/18/2016 - Update `resolveFrame_` to have simpler implmentation with less branching.
1 parent 944c1d5 commit 474c2dc

File tree

5 files changed

+48
-59
lines changed

5 files changed

+48
-59
lines changed

src/agent/state.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,12 @@ StateResolver.prototype.resolveFrames_ = function() {
224224
var frames = [];
225225
var frameCount = Math.min(this.state_.frameCount(),
226226
this.config_.capture.maxFrames);
227+
227228
for (var i = 0; i < frameCount; i++) {
228229
var frame = this.state_.frame(i);
229230
if (this.shouldFrameBeResolved_(frame)) {
230-
var resolveVars = i < this.config_.capture.maxExpandFrames;
231-
frames.push(this.resolveFrame_(frame, resolveVars));
231+
frames.push(this.resolveFrame_(frame,
232+
(i < this.config_.capture.maxExpandFrames)));
232233
}
233234
}
234235
return frames;
@@ -286,32 +287,36 @@ StateResolver.prototype.isPathInNodeModulesDirectory_ = function(path) {
286287
return path.indexOf('node_modules') === 0;
287288
};
288289

289-
StateResolver.prototype.resolveFrame_ = function(frame, resolveVars) {
290-
var noArgs = [{
291-
name: 'arguments_not_available',
292-
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX
293-
}];
294-
var noLocals = [{
295-
name: 'locals_not_available',
296-
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX
297-
}];
298-
var args = this.extractArgumentsList_(frame);
299-
var locals = resolveVars ? this.resolveLocalsList_(frame, args) : noLocals;
300-
if (isEmpty(locals)) {
301-
locals = noLocals;
302-
}
303-
if (semver.satisfies(process.version, '<1.6')) {
304-
// If the node version is over 1.6 we do not read the frame arguments since
305-
// the values produced by the frame for the arguments may contain inaccurate
306-
// values. If the version is lower than 1.6, though, the frame's argument
307-
// list can be relied upon to produce accurate values for arguments.
308-
args = resolveVars && (!isEmpty(args)) ? this.resolveArgumentList_(args) :
309-
noArgs;
290+
StateResolver.prototype.resolveFrame_ = function(frame, underFrameCap) {
291+
var args = [];
292+
var locals = [];
293+
if (!underFrameCap) {
294+
args.push({
295+
name: 'arguments_not_available',
296+
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX
297+
});
298+
locals.push({
299+
name: 'locals_not_available',
300+
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX
301+
});
310302
} else {
311-
// Otherwise, if the version is 1.6 or higher than we will use the values
312-
// aggregated from the ScopeMirror traversal stored in locals which will
313-
// include any applicable arguments from the invocation.
314-
args = noArgs;
303+
args = this.extractArgumentsList_(frame);
304+
locals = this.resolveLocalsList_(frame, args);
305+
if (isEmpty(locals)) {
306+
locals = [];
307+
}
308+
if (semver.satisfies(process.version, '<1.6')) {
309+
// If the node version is over 1.6 we do not read the frame arguments since
310+
// the values produced by the frame for the arguments may contain inaccurate
311+
// values. If the version is lower than 1.6, though, the frame's argument
312+
// list can be relied upon to produce accurate values for arguments.
313+
args = !isEmpty(args) ? this.resolveArgumentList_(args) : [];
314+
} else {
315+
// Otherwise, if the version is 1.6 or higher than we will use the values
316+
// aggregated from the ScopeMirror traversal stored in locals which will
317+
// include any applicable arguments from the invocation.
318+
args = [];
319+
}
315320
}
316321
return {
317322
function: this.resolveFunctionName_(frame.func()),

test/standalone/test-duplicate-nested-expressions.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ describe('v8debugapi', function() {
8989
args[0],
9090
{name: 'a', value: '11'}
9191
);
92-
assert.equal(locals.length, 1);
93-
assert.equal(locals[0].name, 'locals_not_available');
92+
assert.equal(locals.length, 0);
9493
} else {
95-
assert.equal(args.length, 1, 'There should be one argument');
96-
assert.equal(args[0].name, 'arguments_not_available');
94+
assert.equal(args.length, 0, 'There should be zero arguments');
9795
assert.equal(locals.length, 1, 'There should be one locals');
9896
assert.deepEqual(
9997
locals[0],
@@ -125,11 +123,9 @@ describe('v8debugapi', function() {
125123
args[0],
126124
{name: 'a', value: '11'}
127125
);
128-
assert.equal(locals.length, 1);
129-
assert.equal(locals[0].name, 'locals_not_available');
126+
assert.equal(locals.length, 0);
130127
} else {
131-
assert.equal(args.length, 1, 'There should be one argument');
132-
assert.equal(args[0].name, 'arguments_not_available');
128+
assert.equal(args.length, 0, 'There should be zero arguments');
133129
assert.equal(locals.length, 1, 'There should be one local');
134130
assert.deepEqual(
135131
locals[0],
@@ -161,11 +157,9 @@ describe('v8debugapi', function() {
161157
args[0],
162158
{name: 'a', value: '11'}
163159
);
164-
assert.equal(locals.length, 1);
165-
assert.equal(locals[0].name, 'locals_not_available');
160+
assert.equal(locals.length, 0);
166161
} else {
167-
assert.equal(args.length, 1, 'There should be one argument');
168-
assert.equal(args[0].name, 'arguments_not_available');
162+
assert.equal(args.length, 0, 'There should be zero arguments');
169163
assert.equal(locals.length, 1, 'There should be one local');
170164
assert.deepEqual(
171165
locals[0],
@@ -200,8 +194,7 @@ describe('v8debugapi', function() {
200194
var frame = brk.stackFrames[0];
201195
var args = frame.arguments;
202196
var locals = frame.locals;
203-
assert.equal(args.length, 1, 'There should be one argument');
204-
assert.equal(args[0].name, 'arguments_not_available');
197+
assert.equal(args.length, 0, 'There should be zero arguments');
205198
assert.equal(locals.length, 2, 'There should be two locals');
206199
assert.deepEqual(
207200
locals[0],

test/standalone/test-fat-arrow.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ describe('v8debugapi', function() {
8484
var frame = brk.stackFrames[0];
8585
var args = frame.arguments;
8686
var locals = frame.locals;
87-
assert.equal(args.length, 1, 'There should be one argument');
88-
assert.equal(args[0].name, 'arguments_not_available');
87+
assert.equal(args.length, 0, 'There should be zero arguments');
8988
assert.equal(locals.length, 1, 'There should be one local');
9089
assert.deepEqual(
9190
locals[0],
@@ -109,8 +108,7 @@ describe('v8debugapi', function() {
109108
var frame = brk.stackFrames[0];
110109
var args = frame.arguments;
111110
var locals = frame.locals;
112-
assert.equal(args.length, 1, 'There should be one argument');
113-
assert.equal(args[0].name, 'arguments_not_available');
111+
assert.equal(args.length, 0, 'There should be zero arguments');
114112
assert.equal(locals.length, 1, 'There should be one local');
115113
assert.deepEqual(
116114
locals[0],

test/standalone/test-this-context.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ describe('v8debugapi', function() {
9898
);
9999
assert.deepEqual(locals[0].name, 'context');
100100
} else {
101-
assert.equal(args.length, 1, 'There should be one argument');
102-
assert.equal(args[0].name, 'arguments_not_available');
101+
assert.equal(args.length, 0, 'There should be zero arguments');
103102
assert.equal(locals.length, 2, 'There should be two locals');
104103
assert.deepEqual(locals[0], {name: 'b', value: '1'});
105104
assert.deepEqual(locals[1].name, 'context');
@@ -124,15 +123,13 @@ describe('v8debugapi', function() {
124123
var locals = frame.locals;
125124
if (semver.satisfies(process.version, '<1.6')) {
126125
assert.equal(args.length, 1, 'There should be one argument');
127-
assert.equal(locals.length, 1, 'There should be one local');
126+
assert.equal(locals.length, 0);
128127
assert.deepEqual(
129128
args[0],
130129
{name: 'j', value: '1'}
131130
);
132-
assert.equal(locals[0].name, 'locals_not_available');
133131
} else {
134-
assert.equal(args.length, 1, 'There should be one argument');
135-
assert.equal(args[0].name, 'arguments_not_available');
132+
assert.equal(args.length, 0, 'There should be zero arguments');
136133
assert.equal(locals.length, 1, 'There should be one local');
137134
assert.deepEqual(locals[0], {name: 'j', value: '1'});
138135
}

test/standalone/test-try-catch.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ describe('v8debugapi', function() {
8383
var frame = brk.stackFrames[0];
8484
var args = frame.arguments;
8585
var locals = frame.locals;
86-
assert.equal(args.length, 1, 'There should be one argument');
8786
assert.equal(locals.length, 1, 'There should be one local');
8887
if (semver.satisfies(process.version, '<1.6')) {
8988
// Try/Catch scope-walking does not work on 0.12
@@ -92,13 +91,12 @@ describe('v8debugapi', function() {
9291
{name: 'e', value: 'undefined'}
9392
);
9493
} else {
94+
assert.equal(args.length, 0, 'There should be zero arguments');
9595
var e = locals[0];
9696
assert(e.name === 'e');
9797
assert(Number.isInteger(e.varTableIndex));
9898
}
99-
var arg0 = args[0];
100-
assert(arg0.name === 'arguments_not_available');
101-
assert(Number.isInteger(arg0.varTableIndex));
99+
assert.equal(args.length, 0, 'There should be zero arguments');
102100
api.clear(brk);
103101
done();
104102
});
@@ -124,15 +122,13 @@ describe('v8debugapi', function() {
124122
{name: 'e', value: 'undefined'}
125123
);
126124
} else {
127-
assert.equal(args.length, 1, 'There should be one argument');
125+
assert.equal(args.length, 0, 'There should be zero arguments');
128126
assert.equal(locals.length, 1, 'There should be one local');
129127
assert.deepEqual(
130128
locals[0],
131129
{name: 'e', value: '2'}
132130
);
133-
var arg0 = args[0];
134-
assert(arg0.name === 'arguments_not_available');
135-
assert(Number.isInteger(arg0.varTableIndex));
131+
assert.equal(args.length, 0, 'There should be zero arguments');
136132
}
137133
api.clear(brk);
138134
done();

0 commit comments

Comments
 (0)