@@ -40,33 +40,6 @@ var NATIVE_PROPERTY_MESSAGE_INDEX = 1;
4040var GETTER_MESSAGE_INDEX = 2 ;
4141var ARG_LOCAL_LIMIT_MESSAGE_INDEX = 3 ;
4242var STRING_LIMIT_MESSAGE_INDEX = 4 ;
43- var DATA_LIMIT_MESSAGE_INDEX = 5 ;
44-
45- var MESSAGE_TABLE = [ ] ;
46- MESSAGE_TABLE [ BUFFER_FULL_MESSAGE_INDEX ] =
47- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
48- 'Max data size reached' , true ) } ;
49- MESSAGE_TABLE [ NATIVE_PROPERTY_MESSAGE_INDEX ] =
50- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
51- 'Native properties are not available' , true ) } ;
52- MESSAGE_TABLE [ GETTER_MESSAGE_INDEX ] =
53- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
54- 'Properties with getters are not available' , true ) } ;
55- MESSAGE_TABLE [ ARG_LOCAL_LIMIT_MESSAGE_INDEX ] =
56- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
57- 'Locals and arguments are only displayed for the ' +
58- 'top `config.capture.maxExpandFrames` stack frames.' ,
59- true ) } ;
60- MESSAGE_TABLE [ STRING_LIMIT_MESSAGE_INDEX ] =
61- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
62- 'Only first `config.capture.maxStringLength` chars' +
63- ' were captured.' ,
64- false ) } ;
65- MESSAGE_TABLE [ DATA_LIMIT_MESSAGE_INDEX ] =
66- { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
67- 'Truncating the results because the cap of ' +
68- '`config.capture.maxDataSize` has been reached.' ,
69- false ) } ;
7043
7144/**
7245 * Captures the stack and current execution state.
@@ -128,8 +101,32 @@ function StateResolver(execState, expressions, config, v8) {
128101 this . evaluatedExpressions_ = [ ] ;
129102 this . totalSize_ = 0 ;
130103
131- this . resolvedVariableTable_ = util . _extend ( [ ] , MESSAGE_TABLE ) ;
132- this . rawVariableTable_ = MESSAGE_TABLE . map ( function ( ) { return null ; } ) ;
104+ this . messageTable_ = [ ] ;
105+ this . messageTable_ [ BUFFER_FULL_MESSAGE_INDEX ] =
106+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
107+ 'Max data size reached' , true ) } ;
108+ this . messageTable_ [ NATIVE_PROPERTY_MESSAGE_INDEX ] =
109+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
110+ 'Native properties are not available' , true ) } ;
111+ this . messageTable_ [ GETTER_MESSAGE_INDEX ] =
112+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
113+ 'Properties with getters are not available' , true ) } ;
114+ this . messageTable_ [ ARG_LOCAL_LIMIT_MESSAGE_INDEX ] =
115+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
116+ 'Locals and arguments are only displayed for the ' +
117+ 'top `config.capture.maxExpandFrames=' +
118+ config . capture . maxExpandFrames +
119+ '` stack frames.' ,
120+ true ) } ;
121+ this . messageTable_ [ STRING_LIMIT_MESSAGE_INDEX ] =
122+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
123+ 'Only first `config.capture.maxStringLength=' +
124+ config . capture . maxStringLength +
125+ '` chars were captured.' ,
126+ false ) } ;
127+
128+ this . resolvedVariableTable_ = util . _extend ( [ ] , this . messageTable_ ) ;
129+ this . rawVariableTable_ = this . messageTable_ . map ( function ( ) { return null ; } ) ;
133130}
134131
135132
@@ -167,7 +164,7 @@ StateResolver.prototype.capture_ = function() {
167164 var frames = that . resolveFrames_ ( ) ;
168165
169166 // Now resolve the variables
170- var index = MESSAGE_TABLE . length ; // skip the sentinel values
167+ var index = this . messageTable_ . length ; // skip the sentinel values
171168 var noLimit = that . config_ . capture . maxDataSize === 0 ;
172169 while ( index < that . rawVariableTable_ . length && // NOTE: length changes in loop
173170 ( that . totalSize_ < that . config_ . capture . maxDataSize || noLimit ) ) {
@@ -201,12 +198,13 @@ StateResolver.prototype.capture_ = function() {
201198StateResolver . prototype . trimVariableTable_ = function ( fromIndex , frames ) {
202199 this . resolvedVariableTable_ . splice ( fromIndex ) ; // remove the remaining entries
203200
201+ var that = this ;
204202 var processBufferFull = function ( variables ) {
205203 variables . forEach ( function ( variable ) {
206204 if ( variable . varTableIndex && variable . varTableIndex >= fromIndex ) {
207205 // make it point to the sentinel 'buffer full' value
208206 variable . varTableIndex = BUFFER_FULL_MESSAGE_INDEX ;
209- variable . status = MESSAGE_TABLE [ BUFFER_FULL_MESSAGE_INDEX ] . status ;
207+ variable . status = that . messageTable_ [ BUFFER_FULL_MESSAGE_INDEX ] . status ;
210208 }
211209 if ( variable . members ) {
212210 processBufferFull ( variable . members ) ;
@@ -463,7 +461,7 @@ StateResolver.prototype.resolveVariable_ = function(name, value) {
463461 var maxLength = this . config_ . capture . maxStringLength ;
464462 if ( maxLength && maxLength < data . value . length ) {
465463 data . value = data . value . substring ( 0 , maxLength ) + '...' ;
466- data . status = MESSAGE_TABLE [ STRING_LIMIT_MESSAGE_INDEX ] . status ;
464+ data . status = this . messageTable_ [ STRING_LIMIT_MESSAGE_INDEX ] . status ;
467465 }
468466
469467 } else if ( value . isFunction ( ) ) {
@@ -533,8 +531,9 @@ StateResolver.prototype.resolveMirrorSlow_ = function(mirror) {
533531 return that . resolveMirrorProperty_ ( mirror . property ( prop ) ) ;
534532 } ) ;
535533 if ( truncate ) {
536- members . push ( { name : 'Only first `config.capture.maxProperties` ' +
537- 'properties were captured' } ) ;
534+ members . push ( { name : 'Only first `config.capture.maxProperties=' +
535+ this . config_ . capture . maxProperties +
536+ '` properties were captured' } ) ;
538537 }
539538
540539 var mirrorVal = mirror . value ( ) ;
@@ -558,7 +557,9 @@ StateResolver.prototype.resolveMirrorFast_ = function(mirror) {
558557 }
559558 var members = properties . map ( this . resolveMirrorProperty_ . bind ( this ) ) ;
560559 if ( truncate ) {
561- members . push ( { name : 'Only first maxProperties properties were captured' } ) ;
560+ members . push ( { name : 'Only first `config.capture.maxProperties=' +
561+ this . config_ . capture . maxProperties +
562+ '` properties were captured' } ) ;
562563 }
563564 return {
564565 value : mirror . toText ( ) ,
0 commit comments