Revision: 3919
Author: [email protected]
Date: Fri Feb 19 06:33:08 2010
Log: Add maxStrinLength argument to debugger requests
Review URL: http://codereview.chromium.org/647022
http://code.google.com/p/v8/source/detail?r=3919
Modified:
/branches/bleeding_edge/src/debug-delay.js
/branches/bleeding_edge/src/mirror-delay.js
/branches/bleeding_edge/test/mjsunit/debug-evaluate.js
=======================================
--- /branches/bleeding_edge/src/debug-delay.js Wed Feb 17 05:23:46 2010
+++ /branches/bleeding_edge/src/debug-delay.js Fri Feb 19 06:33:08 2010
@@ -1202,11 +1202,16 @@
throw new Error('Command not specified');
}
- // TODO(yurys): remove request.arguments.compactFormat check once
- // ChromeDevTools are switched to 'inlineRefs'
- if (request.arguments && (request.arguments.inlineRefs ||
- request.arguments.compactFormat)) {
- response.setOption('inlineRefs', true);
+ if (request.arguments) {
+ var args = request.arguments;
+ // TODO(yurys): remove request.arguments.compactFormat check once
+ // ChromeDevTools are switched to 'inlineRefs'
+ if (args.inlineRefs || args.compactFormat) {
+ response.setOption('inlineRefs', true);
+ }
+ if (!IS_UNDEFINED(args.maxStringLength)) {
+ response.setOption('maxStringLength', args.maxStringLength);
+ }
}
if (request.command == 'continue') {
=======================================
--- /branches/bleeding_edge/src/mirror-delay.js Fri Feb 12 09:17:13 2010
+++ /branches/bleeding_edge/src/mirror-delay.js Fri Feb 19 06:33:08 2010
@@ -553,16 +553,18 @@
return this.value_.length;
};
-
-StringMirror.prototype.toText = function() {
- if (this.length() > kMaxProtocolStringLength) {
- return this.value_.substring(0, kMaxProtocolStringLength) +
+StringMirror.prototype.getTruncatedValue = function(maxLength) {
+ if (maxLength != -1 && this.length() > maxLength) {
+ return this.value_.substring(0, maxLength) +
'... (length: ' + this.length() + ')';
- } else {
- return this.value_;
- }
+ }
+ return this.value_;
}
+StringMirror.prototype.toText = function() {
+ return this.getTruncatedValue(kMaxProtocolStringLength);
+}
+
/**
* Mirror object for objects.
@@ -1953,6 +1955,15 @@
JSONProtocolSerializer.prototype.inlineRefs_ = function() {
return this.options_ && this.options_.inlineRefs;
}
+
+
+JSONProtocolSerializer.prototype.maxStringLength_ = function() {
+ if (IS_UNDEFINED(this.options_) ||
+ IS_UNDEFINED(this.options_.maxStringLength)) {
+ return kMaxProtocolStringLength;
+ }
+ return this.options_.maxStringLength;
+}
JSONProtocolSerializer.prototype.add_ = function(mirror) {
@@ -1987,8 +1998,7 @@
o.value = mirror.value();
break;
case STRING_TYPE:
- // Limit string length.
- o.value = mirror.toText();
+ o.value = mirror.getTruncatedValue(this.maxStringLength_());
break;
case FUNCTION_TYPE:
o.name = mirror.name();
@@ -2052,11 +2062,12 @@
case STRING_TYPE:
// String values might have their value cropped to keep down size.
- if (mirror.length() > kMaxProtocolStringLength) {
- var str = mirror.value().substring(0, kMaxProtocolStringLength);
+ if (this.maxStringLength_() != -1 &&
+ mirror.length() > this.maxStringLength_()) {
+ var str = mirror.getTruncatedValue(this.maxStringLength_());
content.value = str;
content.fromIndex = 0;
- content.toIndex = kMaxProtocolStringLength;
+ content.toIndex = this.maxStringLength_();
} else {
content.value = mirror.value();
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-evaluate.js Thu Oct 15
13:06:08 2009
+++ /branches/bleeding_edge/test/mjsunit/debug-evaluate.js Fri Feb 19
06:33:08 2010
@@ -87,6 +87,37 @@
testRequest(dcp, '{"expression":"a","global":true}', true, 1);
testRequest(dcp, '{"expression":"this.a","global":true}', true, 1);
+ // Test that the whole string text is returned if maxStringLength
+ // parameter is passed.
+ testRequest(
+ dcp,
+ '{"expression":"this.longString","global":true,maxStringLength:-1}',
+ true,
+ longString);
+ testRequest(
+ dcp,
+ '{"expression":"this.longString","global":true,maxStringLength:'
+
+ longString.length + '}',
+ true,
+ longString);
+ var truncatedStringSuffix = '... (length: ' + longString.length
+ ')';
+ testRequest(
+ dcp,
+ '{"expression":"this.longString","global":true,maxStringLength:0}',
+ true,
+ truncatedStringSuffix);
+ testRequest(
+ dcp,
+ '{"expression":"this.longString","global":true,maxStringLength:1}',
+ true,
+ longString.charAt(0) + truncatedStringSuffix);
+ // Test that by default string is truncated to first 80 chars.
+ testRequest(
+ dcp,
+ '{"expression":"this.longString","global":true}',
+ true,
+ longString.substring(0, 80) + truncatedStringSuffix);
+
// Indicate that all was processed.
listenerComplete = true;
}
@@ -108,6 +139,12 @@
};
a = 1;
+
+// String which is longer than 80 chars.
+var longString = "1234567890_";
+for (var i = 0; i < 4; i++) {
+ longString += longString;
+}
// Set a break point at return in f and invoke g to hit the breakpoint.
Debug.setBreakPoint(f, 2, 0);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev