systrace: update to trace-viewer rev 253
Change-Id: Ida1eb32bf621bcbc8a577adba7238f7f57e37cd5
diff --git a/UPSTREAM_REVISION b/UPSTREAM_REVISION
index 2197544..63fe24a 100644
--- a/UPSTREAM_REVISION
+++ b/UPSTREAM_REVISION
@@ -1 +1 @@
-252
+253
diff --git a/script.js b/script.js
index 0015edf..a25f8d2 100644
--- a/script.js
+++ b/script.js
@@ -295,16 +295,17 @@
v[w],x=e(x,"\\n\\");j.push(x)}else j=[v[v.length-1]];v=j[j.length-1];w=e(v,'\\n";');if(w==v)return d;j[j.length-1]=w;return{ok:!0,lines:b?j:void 0,events_begin_at_line:h}};c.prototype={__proto__:Object.prototype,get model(){return this.model_},buildMapFromLinuxPidsToThreads:function(){this.threadsByLinuxPid={};this.model_.getAllThreads().forEach(function(a){this.threadsByLinuxPid[a.tid]=a}.bind(this))},getOrCreateCpuState:function(a){if(!this.cpuStates_[a]){var b=this.model_.getOrCreateCpu(a);this.cpuStates_[a]=
new d(b)}return this.cpuStates_[a]},getOrCreateKernelThread:function(a,b,c){this.kernelThreadStates_[a]||(c=this.model_.getOrCreateProcess(b).getOrCreateThread(c),c.name=a,this.kernelThreadStates_[a]={pid:b,thread:c,openSlice:void 0,openSliceTS:void 0},this.threadsByLinuxPid[b]=c);return this.kernelThreadStates_[a]},getOrCreatePseudoThread:function(a){var b=this.kernelThreadStates_[a];b||(b=this.getOrCreateKernelThread(a,0,this.pseudoThreadCounter),this.pseudoThreadCounter++);return b},importEvents:function(a){this.createParsers();
this.importCpuData();this.alignClocks(a)&&(this.buildMapFromLinuxPidsToThreads(),this.buildPerThreadCpuSlicesFromCpuState())},finalizeImport:function(){},buildPerThreadCpuSlicesFromCpuState:function(){for(var a in this.cpuStates_)for(var b=this.cpuStates_[a].cpu,c=0;c<b.slices.length;c++){var e=b.slices[c],d=this.threadsByLinuxPid[e.args.tid];d&&(d.tempCpuSlices||(d.tempCpuSlices=[]),d.tempCpuSlices.push(e))}for(c in this.wakeups_)if(a=this.wakeups_[c],d=this.threadsByLinuxPid[a.tid])d.tempWakeups=
-d.tempWakeups||[],d.tempWakeups.push(a);var f=tracing.getColorIdByName("running"),g=tracing.getColorIdByName("runnable"),h=tracing.getColorIdByName("sleeping"),j=tracing.getColorIdByName("iowait");this.model_.getAllThreads().forEach(function(a){if(void 0!==a.tempCpuSlices){var b=a.tempCpuSlices;delete a.tempCpuSlices;b.sort(function(a,b){return a.start-b.start});var c=a.tempWakeups||[];delete a.tempWakeups;c.sort(function(a,b){return a.ts-b.ts});var d=[];if(b.length){var e=b[0];d.push(new tracing.model.Slice("",
-"Running",f,e.start,{},e.duration))}for(var k=void 0,e=1;e<b.length;e++){for(var l=b[e-1],m=b[e],q=m.start-l.end;c.length&&c[0].ts<m.start;)k=c.shift();var t=function(a,b){void 0!==k&&(q=k.ts-l.end);d.push(new tracing.model.Slice("",a,b,l.end,{},q));void 0!==k&&(d.push(new tracing.model.Slice("","Runnable",g,k.ts,{"wakeup from tid":k.fromTid},m.start-k.ts)),k=void 0)};if("S"==l.args.stateWhenDescheduled)t("Sleeping",h);else if("R"==l.args.stateWhenDescheduled||"R+"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("",
-"Runnable",g,l.end,{},q));else if("D"==l.args.stateWhenDescheduled)t("Uninterruptible Sleep",j);else if("T"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","__TASK_STOPPED",j,l.end,{},q));else if("t"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","debug",j,l.end,{},q));else if("Z"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Zombie",j,l.end,{},q));else if("X"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Exit Dead",j,l.end,{},q));
-else if("x"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Task Dead",j,l.end,{},q));else if("W"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","WakeKill",j,l.end,{},q));else if("D|W"==l.args.stateWhenDescheduled)t("Uninterruptable Sleep | WakeKill",j);else throw Error("Unrecognized state: ")+l.args.stateWhenDescheduled;d.push(new tracing.model.Slice("","Running",f,m.start,{},m.duration))}a.cpuSlices=d}})},alignClocks:function(a){if(0==this.clockSyncRecords_.length){if(!a)return!0;
-this.abortImport();return!1}a=this.clockSyncRecords_[0];if(0==a.parentTS||a.parentTS==a.perfTS)return!0;a=a.parentTS-a.perfTS;for(var b in this.cpuStates_){for(var c=this.cpuStates_[b].cpu,d=0;d<c.slices.length;d++){var e=c.slices[d];e.start+=a;e.duration=e.duration}for(var f in c.counters){d=c.counters[f];for(e=0;e<d.timestamps.length;e++)d.timestamps[e]+=a}}for(var g in this.kernelThreadStates_)this.kernelThreadStates_[g].thread.shiftTimestampsForward(a);return!0},abortImport:function(){if(this.pushedEventsToThreads)throw Error("Cannot abort, have alrady pushedCpuDataToThreads.");
-for(var a in this.cpuStates_)delete this.model_.cpus[a];for(var b in this.kernelThreadStates_){a=this.kernelThreadStates_[b].thread;var c=a.parent;delete c.threads[a.tid];delete this.model_.processes[c.pid]}this.model_.importErrors.push("Cannot import kernel trace without a clock sync.")},createParsers:function(){for(var a=tracing.importer.linux_perf.Parser.getSubtypeConstructors(),b=0;b<a.length;++b)this.parsers_.push(new a[b](this));this.registerEventHandler("tracing_mark_write:trace_event_clock_sync",
-c.prototype.traceClockSyncEvent.bind(this));this.registerEventHandler("tracing_mark_write",c.prototype.traceMarkingWriteEvent.bind(this));this.registerEventHandler("0:trace_event_clock_sync",c.prototype.traceClockSyncEvent.bind(this));this.registerEventHandler("0",c.prototype.traceMarkingWriteEvent.bind(this))},registerEventHandler:function(a,b){this.eventHandlers_[a]=b},markPidRunnable:function(a,b,c,d,e){this.wakeups_.push({ts:a,tid:b,fromTid:e})},importError:function(a){this.model_.importErrors.push("Line "+
-(this.lineNumberBase+this.lineNumber+1)+": "+a)},traceClockSyncEvent:function(a,b,c,d,e){a=/parent_ts=(\d+\.?\d*)/.exec(e.details);if(!a)return!1;this.clockSyncRecords_.push({perfTS:d,parentTS:1E3*a[1]});return!0},traceMarkingWriteEvent:function(a,b,c,d,e,f){var g=/^\s*(\w+):\s*(.*)$/.exec(e.details);if(g)e.subEventName=g[1],e.details=g[2];else if(g=e.details.substring(0,2),"B|"==g||"E"==g||"E|"==g||"C|"==g)e.subEventName="android";else return!1;a=a+":"+e.subEventName;g=this.eventHandlers_[a];return!g?
-(this.importError("Unknown trace_marking_write event "+a),!0):g(a,b,c,d,e,f)},importCpuData:function(){var b=c._extractEventsFromSystraceHTML(this.events_,!0);b.ok?(this.lineNumberBase=b.events_begin_at_line,this.lines_=b.lines):(this.lineNumberBase=0,this.lines_=this.events_.split("\n"));b=null;for(this.lineNumber=0;this.lineNumber<this.lines_.length;++this.lineNumber){var d=this.lines_[this.lineNumber];if(!(0==d.length||/^#/.test(d))){if(null==b&&(b=a(d),null==b)){this.importError("Cannot parse line: "+
-d);continue}var e=b(d);if(e){var f=parseInt(e.pid),g=parseInt(e.cpuNumber),h=1E3*parseFloat(e.timestamp),j=e.eventName,u=this.eventHandlers_[j];u?u(j,g,f,h,e)||this.importError("Malformed "+j+" event ("+d+")"):this.importError("Unknown event "+j+" ("+d+")")}else this.importError("Unrecognized line: "+d)}}}};tracing.Model.registerImporter(c);return{LinuxPerfImporter:c,_LinuxPerfImporterTestExports:TestExports}});
+d.tempWakeups||[],d.tempWakeups.push(a);var f=tracing.getColorIdByName("running"),g=tracing.getColorIdByName("runnable"),h=tracing.getColorIdByName("sleeping"),j=tracing.getColorIdByName("iowait");this.model_.getAllThreads().forEach(function(a){if(void 0!==a.tempCpuSlices){var b=a.tempCpuSlices;delete a.tempCpuSlices;b.sort(function(a,b){return a.start-b.start});var c=a.tempWakeups||[];delete a.tempWakeups;c.sort(function(a,b){return a.ts-b.ts});var d=[];if(b.length){var e=b[0];if(c.length&&c[0].ts<
+e.start){var k=c.shift();d.push(new tracing.model.Slice("","Runnable",g,k.ts,{"wakeup from tid":k.fromTid},e.start-k.ts))}d.push(new tracing.model.Slice("","Running",f,e.start,{},e.duration))}k=void 0;for(e=1;e<b.length;e++){for(var l=b[e-1],m=b[e],q=m.start-l.end;c.length&&c[0].ts<m.start;){var t=c.shift();void 0===k&&t.ts>l.end&&(k=t)}t=function(a,b){void 0!==k&&(q=k.ts-l.end);d.push(new tracing.model.Slice("",a,b,l.end,{},q));void 0!==k&&(d.push(new tracing.model.Slice("","Runnable",g,k.ts,{"wakeup from tid":k.fromTid},
+m.start-k.ts)),k=void 0)};if("S"==l.args.stateWhenDescheduled)t("Sleeping",h);else if("R"==l.args.stateWhenDescheduled||"R+"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Runnable",g,l.end,{},q));else if("D"==l.args.stateWhenDescheduled)t("Uninterruptible Sleep",j);else if("T"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","__TASK_STOPPED",j,l.end,{},q));else if("t"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","debug",j,l.end,{},q));else if("Z"==
+l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Zombie",j,l.end,{},q));else if("X"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Exit Dead",j,l.end,{},q));else if("x"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","Task Dead",j,l.end,{},q));else if("W"==l.args.stateWhenDescheduled)d.push(new tracing.model.Slice("","WakeKill",j,l.end,{},q));else if("D|W"==l.args.stateWhenDescheduled)t("Uninterruptable Sleep | WakeKill",j);else throw Error("Unrecognized state: ")+
+l.args.stateWhenDescheduled;d.push(new tracing.model.Slice("","Running",f,m.start,{},m.duration))}a.cpuSlices=d}})},alignClocks:function(a){if(0==this.clockSyncRecords_.length){if(!a)return!0;this.abortImport();return!1}a=this.clockSyncRecords_[0];if(0==a.parentTS||a.parentTS==a.perfTS)return!0;a=a.parentTS-a.perfTS;for(var b in this.cpuStates_){for(var c=this.cpuStates_[b].cpu,d=0;d<c.slices.length;d++){var e=c.slices[d];e.start+=a;e.duration=e.duration}for(var f in c.counters){d=c.counters[f];for(e=
+0;e<d.timestamps.length;e++)d.timestamps[e]+=a}}for(var g in this.kernelThreadStates_)this.kernelThreadStates_[g].thread.shiftTimestampsForward(a);return!0},abortImport:function(){if(this.pushedEventsToThreads)throw Error("Cannot abort, have alrady pushedCpuDataToThreads.");for(var a in this.cpuStates_)delete this.model_.cpus[a];for(var b in this.kernelThreadStates_){a=this.kernelThreadStates_[b].thread;var c=a.parent;delete c.threads[a.tid];delete this.model_.processes[c.pid]}this.model_.importErrors.push("Cannot import kernel trace without a clock sync.")},
+createParsers:function(){for(var a=tracing.importer.linux_perf.Parser.getSubtypeConstructors(),b=0;b<a.length;++b)this.parsers_.push(new a[b](this));this.registerEventHandler("tracing_mark_write:trace_event_clock_sync",c.prototype.traceClockSyncEvent.bind(this));this.registerEventHandler("tracing_mark_write",c.prototype.traceMarkingWriteEvent.bind(this));this.registerEventHandler("0:trace_event_clock_sync",c.prototype.traceClockSyncEvent.bind(this));this.registerEventHandler("0",c.prototype.traceMarkingWriteEvent.bind(this))},
+registerEventHandler:function(a,b){this.eventHandlers_[a]=b},markPidRunnable:function(a,b,c,d,e){this.wakeups_.push({ts:a,tid:b,fromTid:e})},importError:function(a){this.model_.importErrors.push("Line "+(this.lineNumberBase+this.lineNumber+1)+": "+a)},traceClockSyncEvent:function(a,b,c,d,e){a=/parent_ts=(\d+\.?\d*)/.exec(e.details);if(!a)return!1;this.clockSyncRecords_.push({perfTS:d,parentTS:1E3*a[1]});return!0},traceMarkingWriteEvent:function(a,b,c,d,e,f){var g=/^\s*(\w+):\s*(.*)$/.exec(e.details);
+if(g)e.subEventName=g[1],e.details=g[2];else if(g=e.details.substring(0,2),"B|"==g||"E"==g||"E|"==g||"C|"==g)e.subEventName="android";else return!1;a=a+":"+e.subEventName;g=this.eventHandlers_[a];return!g?(this.importError("Unknown trace_marking_write event "+a),!0):g(a,b,c,d,e,f)},importCpuData:function(){var b=c._extractEventsFromSystraceHTML(this.events_,!0);b.ok?(this.lineNumberBase=b.events_begin_at_line,this.lines_=b.lines):(this.lineNumberBase=0,this.lines_=this.events_.split("\n"));b=null;
+for(this.lineNumber=0;this.lineNumber<this.lines_.length;++this.lineNumber){var d=this.lines_[this.lineNumber];if(!(0==d.length||/^#/.test(d))){if(null==b&&(b=a(d),null==b)){this.importError("Cannot parse line: "+d);continue}var e=b(d);if(e){var f=parseInt(e.pid),g=parseInt(e.cpuNumber),h=1E3*parseFloat(e.timestamp),j=e.eventName,u=this.eventHandlers_[j];u?u(j,g,f,h,e)||this.importError("Malformed "+j+" event ("+d+")"):this.importError("Unknown event "+j+" ("+d+")")}else this.importError("Unrecognized line: "+
+d)}}}};tracing.Model.registerImporter(c);return{LinuxPerfImporter:c,_LinuxPerfImporterTestExports:TestExports}});
base.exportTo("tracing.importer.v8",function(){function d(){}function c(a){this.dispatchTable_=a;this.lineNum_=0;this.csvParser_=new d}d.CSV_FIELD_RE_=/^"((?:[^"]|"")*)"|([^,]*)/;d.DOUBLE_QUOTE_RE_=/""/g;d.prototype.parseLine=function(a){var b=d.CSV_FIELD_RE_,c=d.DOUBLE_QUOTE_RE_,e=0,g=a.length,j=[];if(0<g){do{var h=b.exec(a.substr(e));"string"===typeof h[1]?(h=h[1],e+=h.length+3,j.push(h.replace(c,'"'))):(h=h[2],e+=h.length+1,j.push(h))}while(e<=g)}return j};c.prototype.printError=function(){};c.prototype.processLogChunk=
function(a){this.processLog_(a.split("\n"))};c.prototype.processLogLine=function(a){this.processLog_([a])};c.prototype.processStack=function(a,b,c){b=b?[a,b]:[a];for(var d=0,g=c.length;d<g;++d){var j=c[d],h=j.charAt(0);"+"==h||"-"==h?(a+=parseInt(j,16),b.push(a)):"o"!=h&&b.push(parseInt(j,16))}return b};c.prototype.skipDispatch=function(){return!1};c.prototype.dispatchLogRow_=function(a){var b=a[0];if(b in this.dispatchTable_&&(b=this.dispatchTable_[b],!(null===b||this.skipDispatch(b)))){for(var c=
[],d=0;d<b.parsers.length;++d){var g=b.parsers[d];if(null===g)c.push(a[1+d]);else if("function"==typeof g)c.push(g(a[1+d]));else{c.push(a.slice(1+d));break}}b.processor.apply(this,c)}};c.prototype.processLog_=function(a){for(var b=0,c=a.length;b<c;++b,++this.lineNum_){var d=a[b];if(d)try{var g=this.csvParser_.parseLine(d);this.dispatchLogRow_(g)}catch(j){this.printError("line "+(this.lineNum_+1)+": "+(j.message||j))}}};return{LogReader:c}});
diff --git a/trace-viewer/src/importer/linux_perf_importer.js b/trace-viewer/src/importer/linux_perf_importer.js
index 6a10d66..9d6ff7d 100644
--- a/trace-viewer/src/importer/linux_perf_importer.js
+++ b/trace-viewer/src/importer/linux_perf_importer.js
@@ -447,18 +447,32 @@
// Walk the slice list and put slices between each original slice
// to show when the thread isn't running
var slices = [];
+
if (origSlices.length) {
var slice = origSlices[0];
+
+ if (wakeups.length && wakeups[0].ts < slice.start) {
+ var wakeup = wakeups.shift();
+ var wakeupDuration = slice.start - wakeup.ts;
+ var args = {'wakeup from tid': wakeup.fromTid};
+ slices.push(new tracing.model.Slice('', 'Runnable', runnableId,
+ wakeup.ts, args, wakeupDuration));
+ }
+
slices.push(new tracing.model.Slice('', 'Running', runningId,
slice.start, {}, slice.duration));
}
+
var wakeup = undefined;
for (var i = 1; i < origSlices.length; i++) {
var prevSlice = origSlices[i - 1];
var nextSlice = origSlices[i];
var midDuration = nextSlice.start - prevSlice.end;
while (wakeups.length && wakeups[0].ts < nextSlice.start) {
- wakeup = wakeups.shift();
+ var w = wakeups.shift();
+ if (wakeup === undefined && w.ts > prevSlice.end) {
+ wakeup = w;
+ }
}
// Push a sleep slice onto the slices list, interrupting it with a