Commit a47746d2 authored by yurys@chromium.org's avatar yurys@chromium.org

Add maxStrinLength argument to debugger requests

Review URL: http://codereview.chromium.org/647022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3919 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 27eaf973
...@@ -1202,11 +1202,16 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) ...@@ -1202,11 +1202,16 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request)
throw new Error('Command not specified'); throw new Error('Command not specified');
} }
// TODO(yurys): remove request.arguments.compactFormat check once if (request.arguments) {
// ChromeDevTools are switched to 'inlineRefs' var args = request.arguments;
if (request.arguments && (request.arguments.inlineRefs || // TODO(yurys): remove request.arguments.compactFormat check once
request.arguments.compactFormat)) { // ChromeDevTools are switched to 'inlineRefs'
response.setOption('inlineRefs', true); if (args.inlineRefs || args.compactFormat) {
response.setOption('inlineRefs', true);
}
if (!IS_UNDEFINED(args.maxStringLength)) {
response.setOption('maxStringLength', args.maxStringLength);
}
} }
if (request.command == 'continue') { if (request.command == 'continue') {
......
...@@ -553,14 +553,16 @@ StringMirror.prototype.length = function() { ...@@ -553,14 +553,16 @@ StringMirror.prototype.length = function() {
return this.value_.length; return this.value_.length;
}; };
StringMirror.prototype.getTruncatedValue = function(maxLength) {
StringMirror.prototype.toText = function() { if (maxLength != -1 && this.length() > maxLength) {
if (this.length() > kMaxProtocolStringLength) { return this.value_.substring(0, maxLength) +
return this.value_.substring(0, kMaxProtocolStringLength) +
'... (length: ' + this.length() + ')'; '... (length: ' + this.length() + ')';
} else {
return this.value_;
} }
return this.value_;
}
StringMirror.prototype.toText = function() {
return this.getTruncatedValue(kMaxProtocolStringLength);
} }
...@@ -1955,6 +1957,15 @@ JSONProtocolSerializer.prototype.inlineRefs_ = function() { ...@@ -1955,6 +1957,15 @@ JSONProtocolSerializer.prototype.inlineRefs_ = function() {
} }
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) { JSONProtocolSerializer.prototype.add_ = function(mirror) {
// If this mirror is already in the list just return. // If this mirror is already in the list just return.
for (var i = 0; i < this.mirrors_.length; i++) { for (var i = 0; i < this.mirrors_.length; i++) {
...@@ -1987,8 +1998,7 @@ JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ = ...@@ -1987,8 +1998,7 @@ JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ =
o.value = mirror.value(); o.value = mirror.value();
break; break;
case STRING_TYPE: case STRING_TYPE:
// Limit string length. o.value = mirror.getTruncatedValue(this.maxStringLength_());
o.value = mirror.toText();
break; break;
case FUNCTION_TYPE: case FUNCTION_TYPE:
o.name = mirror.name(); o.name = mirror.name();
...@@ -2052,11 +2062,12 @@ JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference, ...@@ -2052,11 +2062,12 @@ JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference,
case STRING_TYPE: case STRING_TYPE:
// String values might have their value cropped to keep down size. // String values might have their value cropped to keep down size.
if (mirror.length() > kMaxProtocolStringLength) { if (this.maxStringLength_() != -1 &&
var str = mirror.value().substring(0, kMaxProtocolStringLength); mirror.length() > this.maxStringLength_()) {
var str = mirror.getTruncatedValue(this.maxStringLength_());
content.value = str; content.value = str;
content.fromIndex = 0; content.fromIndex = 0;
content.toIndex = kMaxProtocolStringLength; content.toIndex = this.maxStringLength_();
} else { } else {
content.value = mirror.value(); content.value = mirror.value();
} }
......
...@@ -87,6 +87,37 @@ function listener(event, exec_state, event_data, data) { ...@@ -87,6 +87,37 @@ function listener(event, exec_state, event_data, data) {
testRequest(dcp, '{"expression":"a","global":true}', true, 1); testRequest(dcp, '{"expression":"a","global":true}', true, 1);
testRequest(dcp, '{"expression":"this.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. // Indicate that all was processed.
listenerComplete = true; listenerComplete = true;
} }
...@@ -109,6 +140,12 @@ function g() { ...@@ -109,6 +140,12 @@ function g() {
a = 1; 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. // Set a break point at return in f and invoke g to hit the breakpoint.
Debug.setBreakPoint(f, 2, 0); Debug.setBreakPoint(f, 2, 0);
g(); g();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment