Commit a76ce4f8 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[log] Improve log parsing

- Add parseString and parseVarArgs helper constants
- Fix number formatting in parser-processor.js
- Rename time to duration in parse-processor
- Fix eval handling in parse-processor

Bug: chromium:757467, chromium:850038

Change-Id: Ibce57b46d22e03ddaa5baa22f45d8df4c93af2cd
Reviewed-on: https://chromium-review.googlesource.com/1102435Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53887}
parent f86365dc
...@@ -39,17 +39,17 @@ function parseState(s) { ...@@ -39,17 +39,17 @@ function parseState(s) {
function LogProcessor() { function LogProcessor() {
LogReader.call(this, { LogReader.call(this, {
'code-creation': { 'code-creation': {
parsers: [null, parseInt, parseInt, parseInt, parseInt, parsers: [parseString, parseInt, parseInt, parseInt, parseInt,
null, 'var-args'], parseString, parseVarArgs],
processor: this.processCodeCreation }, processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt], 'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove }, processor: this.processCodeMove },
'code-delete': null, 'code-delete': parseString,
'sfi-move': { parsers: [parseInt, parseInt], 'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove }, processor: this.processFunctionMove },
'shared-library': null, 'shared-library': parseString,
'profiler': null, 'profiler': parseString,
'tick': null }); 'tick': parseString });
this.profile = new Profile(); this.profile = new Profile();
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) { function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) {
LogReader.call(this, { LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt, parseInt], 'shared-library': { parsers: [parseString, parseInt, parseInt, parseInt],
processor: this.processSharedLibrary } processor: this.processSharedLibrary }
}, timedRange, pairwiseTimedRange); }, timedRange, pairwiseTimedRange);
......
...@@ -32,11 +32,12 @@ function parseState(s) { ...@@ -32,11 +32,12 @@ function parseState(s) {
function IcProcessor() { function IcProcessor() {
var propertyICParser = [parseInt, parseInt, parseInt, null, null, parseInt, var propertyICParser = [parseInt, parseInt, parseInt, parseString,
null, null, null]; parseString, parseInt, parseString, parseString, parseString];
LogReader.call(this, { LogReader.call(this, {
'code-creation': { 'code-creation': {
parsers: [null, parseInt, parseInt, parseInt, parseInt, null, 'var-args'], parsers: [parseString, parseInt, parseInt, parseInt, parseInt,
parseString, parseVarArgs],
processor: this.processCodeCreation }, processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt], 'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove }, processor: this.processCodeMove },
......
...@@ -175,6 +175,9 @@ LogReader.prototype.skipDispatch = function(dispatch) { ...@@ -175,6 +175,9 @@ LogReader.prototype.skipDispatch = function(dispatch) {
return false; return false;
}; };
// Parses dummy variable for readability;
const parseString = 'parse-string';
const parseVarArgs = 'parse-var-args';
/** /**
* Does a dispatch of a log record. * Does a dispatch of a log record.
...@@ -196,14 +199,16 @@ LogReader.prototype.dispatchLogRow_ = function(fields) { ...@@ -196,14 +199,16 @@ LogReader.prototype.dispatchLogRow_ = function(fields) {
var parsedFields = []; var parsedFields = [];
for (var i = 0; i < dispatch.parsers.length; ++i) { for (var i = 0; i < dispatch.parsers.length; ++i) {
var parser = dispatch.parsers[i]; var parser = dispatch.parsers[i];
if (parser === null) { if (parser === parseString) {
parsedFields.push(fields[1 + i]); parsedFields.push(fields[1 + i]);
} else if (typeof parser == 'function') { } else if (typeof parser == 'function') {
parsedFields.push(parser(fields[1 + i])); parsedFields.push(parser(fields[1 + i]));
} else { } else if (parser === parseVarArgs) {
// var-args // var-args
parsedFields.push(fields.slice(1 + i)); parsedFields.push(fields.slice(1 + i));
break; break;
} else {
throw new Error("Invalid log field parser: " + parser);
} }
} }
......
...@@ -8,7 +8,8 @@ class MapProcessor extends LogReader { ...@@ -8,7 +8,8 @@ class MapProcessor extends LogReader {
super(); super();
this.dispatchTable_ = { this.dispatchTable_ = {
'code-creation': { 'code-creation': {
parsers: [null, parseInt, parseInt, parseInt, parseInt, null, 'var-args'], parsers: [parseString, parseInt, parseInt, parseInt, parseInt,
parseString, parseVarArgs],
processor: this.processCodeCreation processor: this.processCodeCreation
}, },
'code-move': { 'code-move': {
...@@ -24,17 +25,17 @@ class MapProcessor extends LogReader { ...@@ -24,17 +25,17 @@ class MapProcessor extends LogReader {
processor: this.processFunctionMove processor: this.processFunctionMove
}, },
'map-create': { 'map-create': {
parsers: [parseInt, parseInt, null], parsers: [parseInt, parseInt, parseString],
processor: this.processMapCreate processor: this.processMapCreate
}, },
'map': { 'map': {
parsers: [null, parseInt, parseInt, parseInt, parseInt, parseInt, parsers: [parseString, parseInt, parseInt, parseInt, parseInt, parseInt,
null, null, null parseString, parseString, parseString
], ],
processor: this.processMap processor: this.processMap
}, },
'map-details': { 'map-details': {
parsers: [parseInt, parseInt, null], parsers: [parseInt, parseInt, parseString],
processor: this.processMapDetails processor: this.processMapDetails
} }
}; };
......
This diff is collapsed.
...@@ -308,13 +308,14 @@ function PlotScriptComposer(kResX, kResY, error_output) { ...@@ -308,13 +308,14 @@ function PlotScriptComposer(kResX, kResY, error_output) {
}; };
// Collect data from log. // Collect data from log.
var logreader = new LogReader( var logreader = new LogReader(
{ 'timer-event-start': { parsers: [null, parseTimeStamp], { 'timer-event-start': { parsers: [parseString, parseTimeStamp],
processor: processTimerEventStart }, processor: processTimerEventStart },
'timer-event-end': { parsers: [null, parseTimeStamp], 'timer-event-end': { parsers: [parseString, parseTimeStamp],
processor: processTimerEventEnd }, processor: processTimerEventEnd },
'shared-library': { parsers: [null, parseInt, parseInt], 'shared-library': { parsers: [parseString, parseInt, parseInt],
processor: processSharedLibrary }, processor: processSharedLibrary },
'code-creation': { parsers: [null, parseInt, parseInt, parseInt, null], 'code-creation': { parsers: [parseString, parseInt, parseInt,
parseInt, parseString],
processor: processCodeCreateEvent }, processor: processCodeCreateEvent },
'code-move': { parsers: [parseInt, parseInt], 'code-move': { parsers: [parseInt, parseInt],
processor: processCodeMoveEvent }, processor: processCodeMoveEvent },
...@@ -324,8 +325,8 @@ function PlotScriptComposer(kResX, kResY, error_output) { ...@@ -324,8 +325,8 @@ function PlotScriptComposer(kResX, kResY, error_output) {
processor: processCodeDeoptEvent }, processor: processCodeDeoptEvent },
'current-time': { parsers: [parseTimeStamp], 'current-time': { parsers: [parseTimeStamp],
processor: processCurrentTimeEvent }, processor: processCurrentTimeEvent },
'tick': { parsers: [parseInt, parseTimeStamp, 'tick': { parsers: [parseInt, parseTimeStamp, parseString,
null, null, parseInt, 'var-args'], parseString, parseInt, parseVarArgs],
processor: processTickEvent } processor: processTickEvent }
}); });
......
...@@ -102,42 +102,43 @@ function TickProcessor( ...@@ -102,42 +102,43 @@ function TickProcessor(
preprocessJson) { preprocessJson) {
this.preprocessJson = preprocessJson; this.preprocessJson = preprocessJson;
LogReader.call(this, { LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt, parseInt], 'shared-library': { parsers: [parseString, parseInt, parseInt, parseInt],
processor: this.processSharedLibrary }, processor: this.processSharedLibrary },
'code-creation': { 'code-creation': {
parsers: [null, parseInt, parseInt, parseInt, parseInt, parsers: [parseString, parseInt, parseInt, parseInt, parseInt,
null, 'var-args'], parseString, parseVarArgs],
processor: this.processCodeCreation }, processor: this.processCodeCreation },
'code-deopt': { 'code-deopt': {
parsers: [parseInt, parseInt, parseInt, parseInt, parseInt, parsers: [parseInt, parseInt, parseInt, parseInt, parseInt,
null, null, null], parseString, parseString, parseString],
processor: this.processCodeDeopt }, processor: this.processCodeDeopt },
'code-move': { parsers: [parseInt, parseInt, ], 'code-move': { parsers: [parseInt, parseInt, ],
processor: this.processCodeMove }, processor: this.processCodeMove },
'code-delete': { parsers: [parseInt], 'code-delete': { parsers: [parseInt],
processor: this.processCodeDelete }, processor: this.processCodeDelete },
'code-source-info': { 'code-source-info': {
parsers: [parseInt, parseInt, parseInt, parseInt, null, null, null], parsers: [parseInt, parseInt, parseInt, parseInt, parseString,
parseString, parseString],
processor: this.processCodeSourceInfo }, processor: this.processCodeSourceInfo },
'script': { 'script': {
parsers: [parseInt, null, null], parsers: [parseInt, parseString, parseString],
processor: this.processCodeScript }, processor: this.processCodeScript },
'sfi-move': { parsers: [parseInt, parseInt], 'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove }, processor: this.processFunctionMove },
'active-runtime-timer': { 'active-runtime-timer': {
parsers: [null], parsers: [parseString],
processor: this.processRuntimeTimerEvent }, processor: this.processRuntimeTimerEvent },
'tick': { 'tick': {
parsers: [parseInt, parseInt, parseInt, parsers: [parseInt, parseInt, parseInt,
parseInt, parseInt, 'var-args'], parseInt, parseInt, parseVarArgs],
processor: this.processTick }, processor: this.processTick },
'heap-sample-begin': { parsers: [null, null, parseInt], 'heap-sample-begin': { parsers: [parseString, parseString, parseInt],
processor: this.processHeapSampleBegin }, processor: this.processHeapSampleBegin },
'heap-sample-end': { parsers: [null, null], 'heap-sample-end': { parsers: [parseString, parseString],
processor: this.processHeapSampleEnd }, processor: this.processHeapSampleEnd },
'timer-event-start' : { parsers: [null, null, null], 'timer-event-start' : { parsers: [parseString, parseString, parseString],
processor: this.advanceDistortion }, processor: this.advanceDistortion },
'timer-event-end' : { parsers: [null, null, null], 'timer-event-end' : { parsers: [parseString, parseString, parseString],
processor: this.advanceDistortion }, processor: this.advanceDistortion },
// Ignored events. // Ignored events.
'profiler': null, 'profiler': null,
......
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