Initial commit to prioritize capturing expressions#162
Initial commit to prioritize capturing expressions#162DominicKramer merged 16 commits intogoogleapis:masterfrom
Conversation
In particular, now if a captured value has a `length` attribute, the value of that attribute is shown in the status field. Also, the length of a watched expression is now bounded by `config.maxDataSize` instead of `config.maxProperties`. Unit tests still need to be addressed, and more fine grained control of the total length of the data captured needs to be added.
|
@GoogleCloudPlatform/node-team I'm still working on this, but I opened this pull request to get early feedback so that if my changes will have a negative impact that I am not aware of, I can fix it sooner rather than later. |
In particular, if an evaluated expression has more than `config.capture.maxDataSize` elements, then only the first `config.capture.maxDataSize` elements will be listed and the new message will be set as the status of the data in the debugger.
| }; | ||
| } else { | ||
| evaluated = that.resolveVariable_(expression, result.mirror); | ||
| evaluated = that.resolveVariable_(expression, result.mirror, true); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Now the `mirror` object returned from V8 no longer has an `isEvaluated` attribute attached to it. Instead, whether or not a variable is evaluated is passed to the `resolveMirror_` method and all associated methods.
Updated the unit tests so that they verify that evaluated objects and arrays do not have their lengths limited.
Now evaluated expressions are processed before stack frames.
Unit tests were added to verify that the length of evaluated expressions are limited by the `maxDataSize` configuration option.
An array 'var A = [1, 2, 3]' has members for the attributes '1', '2', and '3' in version 0.12 but has members for the attributes '1', '2', and '3' as well as 'length' for the other versions of Node.
An array 'var A = [1, 2, 3]' has members for the attributes '1', '2', and '3' in version 0.12 but has members for the attributes '1', '2', and '3' as well as 'length' for the other versions of Node.
The test needed to be updated because the addition of the new data limit message in `state.js` caused the local variable in the test to have its variable table index be increased from 6 to 7 since the variable table now includes the new data limit message.
…amer/cloud-debug-nodejs into feature/prioritize-capture-exp
|
PTAL |
| * @param {Object} value A v8 debugger representation of a variable value. | ||
| */ | ||
| StateResolver.prototype.resolveVariable_ = function(name, value) { | ||
| StateResolver.prototype.resolveVariable_ = function(name, value, isEvaluated) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
lib/state.js
Outdated
| that.resolveMirror_(that.rawVariableTable_[index], isEvaluated); | ||
| index++; | ||
|
|
||
| if (!noLimit && that.totalSize_ >= that.config_.capture.maxDataSize) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
lib/state.js
Outdated
| data.status = MESSAGE_TABLE[OBJECT_LIMIT_MESSAGE_INDEX].status; | ||
| } | ||
|
|
||
| else if (isEvaluated && maxBuffer > 0 && maxBuffer < numKeys) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This makes the logic more clear.
The value of `maxDataSize` is not used to determine if an object or array should have its contents truncated. Instead, an evaluated expression is either entirely displayed or not entirely displayed dependent on whether or not all collected data is beyond `maxDataSize`.
cristiancavalli
left a comment
There was a problem hiding this comment.
Generally looks good to me - a few questions though:
| data.varTableIndex = this.getVariableIndex_(value); | ||
| var maxProps = this.config_.capture.maxProperties; | ||
| if (maxProps && maxProps < Object.keys(value.value()).length) { | ||
| var numKeys = Object.keys(value.value()).length; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if (maxProps && maxProps < Object.keys(value.value()).length) { | ||
| var numKeys = Object.keys(value.value()).length; | ||
|
|
||
| if (!isEvaluated && maxProps && maxProps < numKeys) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // I'm going with the former as that's what util.inspect does. | ||
| var that = this; | ||
|
|
||
| var keys = Object.keys(mirror.value()); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| var members = this.getMirrorProperties_(mirror).map( | ||
| this.resolveMirrorProperty_.bind(this)); | ||
| StateResolver.prototype.resolveMirrorFast_ = function(mirror, isEvaluated) { | ||
| var resMirrorProp = this.resolveMirrorProperty_.bind(this); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| config.capture.maxProperties = oldMaxProps; | ||
| done(); | ||
| }); | ||
| process.nextTick(function() {foo(2);}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| config.capture.maxProperties = oldMaxProps; | ||
| done(); | ||
| }); | ||
| process.nextTick(function() {foo(2);}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| config.capture.maxProperties = oldMaxProps; | ||
| done(); | ||
| }); | ||
| process.nextTick(function() {foo(2);}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| config.capture.maxProperties = oldMaxProps; | ||
| done(); | ||
| }); | ||
| process.nextTick(function() {foo(2);}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -349,7 +364,7 @@ StateResolver.prototype.extractArgumentsList_ = function (frame) { | |||
| StateResolver.prototype.resolveArgumentList_ = function(args) { | |||
| var resolveVariable = this.resolveVariable_.bind(this); | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
In particular, now if a captured value has a
lengthattribute,the value of that attribute is shown in the status field.
Also, the length of a watched expression is now bounded by
config.maxDataSizeinstead ofconfig.maxProperties.Unit tests still need to be addressed, and more fine grained
control of the total length of the data captured needs to be
added.