Fix issue 420: accept truncated log files.

http://code.google.com/p/v8/issues/detail?id=420

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2695 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a82bd050
......@@ -179,9 +179,13 @@ function assertInstanceof(obj, type) {
function assertDoesNotThrow(code) {
try {
eval(code);
if (typeof code == 'function') {
code();
} else {
eval(code);
}
} catch (e) {
assertTrue(false, "threw an exception");
assertTrue(false, "threw an exception: " + (e.message || e));
}
}
......
......@@ -80,3 +80,19 @@
assertEquals('bbbbaaaa', reader.expandBackRef_('bbbb#2:4'));
assertEquals('"#1:1"', reader.expandBackRef_('"#1:1"'));
})();
// See http://code.google.com/p/v8/issues/detail?id=420
(function testReadingTruncatedLog() {
// Having an incorrect event in the middle of a log should throw an exception.
var reader1 = new devtools.profiler.LogReader({});
assertThrows(function() {
reader1.processLogChunk('alias,a,b\nxxxx\nalias,c,d\n');
});
// But having it as the last record should not.
var reader2 = new devtools.profiler.LogReader({});
assertDoesNotThrow(function() {
reader2.processLogChunk('alias,a,b\nalias,c,d\nxxxx');
});
})();
......@@ -294,8 +294,11 @@ devtools.profiler.LogReader.prototype.processLog_ = function(lines) {
this.dispatchLogRow_(fields);
}
} catch (e) {
this.printError('line ' + (i + 1) + ': ' + (e.message || e));
throw e;
// An error on the last line is acceptable since log file can be truncated.
if (i < n - 1) {
this.printError('line ' + (i + 1) + ': ' + (e.message || e));
throw e;
}
}
};
......
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