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

Initial commit to prioritize capturing expressions#162

Merged
DominicKramer merged 16 commits intogoogleapis:masterfrom
DominicKramer:feature/prioritize-capture-exp
Nov 10, 2016
Merged

Initial commit to prioritize capturing expressions#162
DominicKramer merged 16 commits intogoogleapis:masterfrom
DominicKramer:feature/prioritize-capture-exp

Conversation

@DominicKramer
Copy link
Copy Markdown
Contributor

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.

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.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 20, 2016
@DominicKramer
Copy link
Copy Markdown
Contributor Author

@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.

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
@DominicKramer
Copy link
Copy Markdown
Contributor Author

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.

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.

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.

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`.
Copy link
Copy Markdown
Contributor

@cristiancavalli cristiancavalli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

// 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.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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.

config.capture.maxProperties = oldMaxProps;
done();
});
process.nextTick(function() {foo(2);});

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

config.capture.maxProperties = oldMaxProps;
done();
});
process.nextTick(function() {foo(2);});

This comment was marked as spam.

This comment was marked as spam.

config.capture.maxProperties = oldMaxProps;
done();
});
process.nextTick(function() {foo(2);});

This comment was marked as spam.

This comment was marked as spam.

config.capture.maxProperties = oldMaxProps;
done();
});
process.nextTick(function() {foo(2);});

This comment was marked as spam.

This comment was marked as spam.

@@ -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.

This comment was marked as spam.

This comment was marked as spam.

Copy link
Copy Markdown
Contributor

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@DominicKramer DominicKramer merged commit d370e20 into googleapis:master Nov 10, 2016
@DominicKramer DominicKramer deleted the feature/prioritize-capture-exp branch November 10, 2016 22:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants