@@ -23,12 +23,30 @@ module.exports = {
2323
2424var assert = require ( 'assert' ) ;
2525var semver = require ( 'semver' ) ;
26+ var util = require ( 'util' ) ;
2627
2728var StatusMessage = require ( './apiclasses.js' ) . StatusMessage ;
2829
2930var BUFFER_FULL_MESSAGE_INDEX = 0 ;
3031var NATIVE_PROPERTY_MESSAGE_INDEX = 1 ;
3132var GETTER_MESSAGE_INDEX = 2 ;
33+ var ARG_LOCAL_LIMIT_MESSAGE_INDEX = 3 ;
34+
35+ var MESSAGE_TABLE = [ ] ;
36+ MESSAGE_TABLE [ BUFFER_FULL_MESSAGE_INDEX ] =
37+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
38+ 'Max data size reached' , true ) } ;
39+ MESSAGE_TABLE [ NATIVE_PROPERTY_MESSAGE_INDEX ] =
40+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
41+ 'Native properties are not available' , true ) } ;
42+ MESSAGE_TABLE [ GETTER_MESSAGE_INDEX ] =
43+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
44+ 'Properties with getters are not available' , true ) } ;
45+ MESSAGE_TABLE [ ARG_LOCAL_LIMIT_MESSAGE_INDEX ] =
46+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
47+ 'Locals and arguments are only displayed for the ' +
48+ 'top `config.capture.maxExpandFrames` stack frames.' ,
49+ true ) } ;
3250
3351// TODO: document this file
3452
@@ -83,17 +101,8 @@ function StateResolver(execState, expressions, config) {
83101 this . evaluatedExpressions_ = [ ] ;
84102 this . totalSize_ = 0 ;
85103
86- this . rawVariableTable_ = [ null , null , null ] ;
87- this . resolvedVariableTable_ = [ ] ;
88- this . resolvedVariableTable_ [ BUFFER_FULL_MESSAGE_INDEX ] =
89- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
90- 'Max data size reached' , true ) } ;
91- this . resolvedVariableTable_ [ NATIVE_PROPERTY_MESSAGE_INDEX ] =
92- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
93- 'Native properties are not available' , true ) } ;
94- this . resolvedVariableTable_ [ GETTER_MESSAGE_INDEX ] =
95- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
96- 'Properties with getters are not available' , true ) } ;
104+ this . resolvedVariableTable_ = util . _extend ( [ ] , MESSAGE_TABLE ) ;
105+ this . rawVariableTable_ = MESSAGE_TABLE . map ( function ( ) { return null ; } ) ;
97106}
98107
99108
@@ -122,7 +131,7 @@ StateResolver.prototype.capture = function() {
122131 }
123132
124133 // Now resolve the variables
125- var index = 3 ; // skip the sentinel values
134+ var index = MESSAGE_TABLE . length ; // skip the sentinel values
126135 while ( index < that . rawVariableTable_ . length && // NOTE: length changes in loop
127136 that . totalSize_ < that . config_ . capture . maxDataSize ) {
128137 assert ( ! that . resolvedVariableTable_ [ index ] ) ; // shouldn't have it resolved yet
@@ -177,7 +186,8 @@ StateResolver.prototype.resolveFrames_ = function() {
177186 for ( var i = 0 ; i < this . state_ . frameCount ( ) ; i ++ ) {
178187 var frame = this . state_ . frame ( i ) ;
179188 if ( this . shouldFrameBeResolved_ ( frame ) ) {
180- frames . push ( this . resolveFrame_ ( frame ) ) ;
189+ var resolveVars = i < this . config_ . capture . maxExpandFrames ;
190+ frames . push ( this . resolveFrame_ ( frame , resolveVars ) ) ;
181191 }
182192 }
183193 return frames ;
@@ -242,13 +252,20 @@ StateResolver.prototype.isPathInNodeModulesDirectory_ = function(path) {
242252} ;
243253
244254
245- StateResolver . prototype . resolveFrame_ = function ( frame ) {
246- var args = this . resolveArgumentList_ ( frame ) ;
255+ StateResolver . prototype . resolveFrame_ = function ( frame , resolveVars ) {
256+ var args = resolveVars ? this . resolveArgumentList_ ( frame ) : [ {
257+ name : 'arguments_not_available' ,
258+ varTableIndex : ARG_LOCAL_LIMIT_MESSAGE_INDEX
259+ } ] ;
260+ var locals = resolveVars ? this . resolveLocalsList_ ( frame , args ) : [ {
261+ name : 'locals_not_available' ,
262+ varTableIndex : ARG_LOCAL_LIMIT_MESSAGE_INDEX
263+ } ] ;
247264 return {
248265 function : this . resolveFunctionName_ ( frame . func ( ) ) ,
249266 location : this . resolveLocation_ ( frame ) ,
250267 arguments : args ,
251- locals : this . resolveLocalsList_ ( frame , args )
268+ locals : locals
252269 } ;
253270} ;
254271
0 commit comments