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