systrace: pull the latest trace-viewer

This pulls a fix for userland tracing on older kernels.

Change-Id: I748bfe4573bf0f2648b18a703421ab7578fb103a
diff --git a/UPSTREAM_REVISION b/UPSTREAM_REVISION
index 2cd1cfa..b34c321 100644
--- a/UPSTREAM_REVISION
+++ b/UPSTREAM_REVISION
@@ -1 +1 @@
-170
+171
diff --git a/script.js b/script.js
index 4c331be..063918f 100644
--- a/script.js
+++ b/script.js
@@ -32,8 +32,8 @@
 this.viewport_.dispatchChangeEvent()},set selected(a){this.selected_=a;this.viewport_.dispatchChangeEvent()},get selected(){return this.selected_},get color(){return this.selected?"rgb(255,0,0)":"rgb(0,0,0)"},drawTriangle_:function(a,b,c,f,g,d){a.beginPath();var h=this.positionWorld_;h>=b&&h<c&&(b=d.xWorldToView(h),a.moveTo(b,g),a.lineTo(b-3,g/2),a.lineTo(b+3,g/2),a.lineTo(b,g),a.closePath(),a.fillStyle=this.color,a.fill(),g!=f&&(a.beginPath(),a.moveTo(b,g),a.lineTo(b,f),a.closePath(),a.strokeStyle=
 this.color,a.stroke()))},drawLine:function(a,b,c,f,g){a.beginPath();var d=this.positionWorld_;d>=b&&d<c&&(b=g.xWorldToView(d),a.moveTo(b,0),a.lineTo(b,f));a.strokeStyle=this.color;a.stroke()}};return{TimelineViewport:e,TimelineViewportMarker:d}});
 base.exportTo("base.ui",function(){function e(d,a){return(a&&a.ownerDocument?a.ownerDocument:base.doc).createElement(d)}return{decorate:function(d,a){var b;b="string"==typeof d?base.doc.querySelectorAll(d):[d];for(var c=0,f;f=b[c];c++)f instanceof a||a.decorate(f)},define:function(d){function a(f){var g=b(c,f);a.decorate(g);for(var d in f)g[d]=f[d];return g}var b,c;"function"==typeof d?(b=d,c=""):(b=e,c=d);a.decorate=function(b){b.__proto__=a.prototype;b.decorate()};return a},limitInputWidth:function(d,
-a,b){function c(){if(d.scrollWidth>e)d.style.width=e+"px";else{d.style.width=0;var a=d.scrollWidth;d.style.width=a<b?b+"px":a+"px"}}d.style.width="10px";var f=d.ownerDocument.defaultView,g=f.getComputedStyle(d),f=f.getComputedStyle(a),l="rtl"==g.direction,h=d.getBoundingClientRect(),j=a.getBoundingClientRect(),h=l?j.right-h.right:h.left-j.left,g=parseInt(g.borderLeftWidth,10)+parseInt(g.paddingLeft,10)+parseInt(g.paddingRight,10)+parseInt(g.borderRightWidth,10),f=l?parseInt(f.paddingLeft,10):parseInt(f.paddingRight,
-10),e=a.clientWidth-h-g-f;d.addEventListener("input",c);c()},toCssPx:function(d){window.isFinite(d)||console.error("Pixel value is not a number: "+d);return Math.round(d)+"px"}}});base.requireStylesheet("tracks.timeline_track");base.require("ui");
+a,b){function c(){if(d.scrollWidth>k)d.style.width=k+"px";else{d.style.width=0;var a=d.scrollWidth;d.style.width=a<b?b+"px":a+"px"}}d.style.width="10px";var f=d.ownerDocument.defaultView,g=f.getComputedStyle(d),f=f.getComputedStyle(a),l="rtl"==g.direction,h=d.getBoundingClientRect(),e=a.getBoundingClientRect(),h=l?e.right-h.right:h.left-e.left,g=parseInt(g.borderLeftWidth,10)+parseInt(g.paddingLeft,10)+parseInt(g.paddingRight,10)+parseInt(g.borderRightWidth,10),f=l?parseInt(f.paddingLeft,10):parseInt(f.paddingRight,
+10),k=a.clientWidth-h-g-f;d.addEventListener("input",c);c()},toCssPx:function(d){window.isFinite(d)||console.error("Pixel value is not a number: "+d);return Math.round(d)+"px"}}});base.requireStylesheet("tracks.timeline_track");base.require("ui");
 base.exportTo("tracks",function(){var e=base.ui.define("div");e.prototype={__proto__:HTMLDivElement.prototype,decorate:function(){},get visible(){return"none"!==this.style.display},set visible(d){this.style.display=d?"":"none"},get numVisibleTracks(){return this.visible?1:0},addControlButtonElements_:function(d){var a=document.createElement("div");a.classList.add("timeline-track-button");a.classList.add("timeline-track-close-button");a.textContent=String.fromCharCode(215);var b=this;a.addEventListener("click",
 function(){b.style.display="None"});this.appendChild(a);var c=document.createElement("div");c.classList.add("timeline-track-button");c.classList.add("timeline-track-collapse-button");c.textContent="\u2212";var f=!1;c.addEventListener("click",function(){f=!f;this.collapsedDidChange(f);c.textContent=f?"+":"\u2212"});this.appendChild(c);d||(c.style.display="None")}};return{TimelineTrack:e}});"use strict";base.require("tracks.timeline_track");base.require("timeline_filter");base.require("ui");
 base.exportTo("tracks",function(){var e=base.ui.define(tracks.TimelineTrack);e.prototype={__proto__:tracks.TimelineTrack.prototype,decorate:function(){this.categoryFilter_=new tracing.TimelineFilter;this.headingWidth_=void 0;this.tracks_=[]},detach:function(){this.detachAllChildren()},detachAllChildren:function(){for(var d=0;d<this.tracks_.length;d++)this.tracks_[d].detach();this.tracks_=[];this.textContent=""},get viewport(){return this.viewport_},set viewport(d){this.viewport_=d;for(var a=0;a<this.tracks_.length;a++)this.tracks_[a].viewport=
@@ -225,10 +225,10 @@
 base.require("linux_perf_parser");
 base.exportTo("tracing",function(){function e(a){d.call(this,a);a.registerEventHandler("workqueue_execute_start",e.prototype.executeStartEvent.bind(this));a.registerEventHandler("workqueue_execute_end",e.prototype.executeEndEvent.bind(this))}var d=tracing.LinuxPerfParser,a=/work struct (.+): function (\S+)/,b=/work struct (.+)/;e.prototype={__proto__:d.prototype,executeStartEvent:function(b,d,e,l,h){b=a.exec(h[5]);if(!b)return!1;h=this.importer.getOrCreateKernelThread(h[1]);h.openSliceTS=l;h.openSlice=
 b[2];return!0},executeEndEvent:function(a,d,e,l,h){if(!b.exec(h[5]))return!1;a=this.importer.getOrCreateKernelThread(h[1]);a.openSlice&&(l=new tracing.TimelineSlice("",a.openSlice,tracing.getStringColorId(a.openSlice),a.openSliceTS,{},l-a.openSliceTS),a.thread.pushSlice(l));a.openSlice=void 0;return!0}};d.registerSubtype(e);return{LinuxPerfWorkqueueParser:e}});base.require("linux_perf_parser");
-base.exportTo("tracing",function(){function e(a){d.call(this,a);a.registerEventHandler("tracing_mark_write:android",e.prototype.traceMarkWriteAndroidEvent.bind(this));this.model_=a.model_;this.ppids_={}}var d=tracing.LinuxPerfParser;e.prototype={__proto__:d.prototype,traceMarkWriteAndroidEvent:function(a,b,c,d,e,l){b=e[2].split("|");switch(b[0]){case "B":var a=parseInt(b[1]),h=b[2],b=this.model_.getOrCreateProcess(a).getOrCreateThread(c);b.name=l;if(!b.isTimestampValidForBeginOrEnd(d))return this.model_.importErrors.push("Timestamps are moving backward."),
-!1;this.ppids_[c]=a;b.beginSlice(null,h,d,{});break;case "E":a=this.ppids_[c];if(void 0===a)break;b=this.model_.getOrCreateProcess(a).getOrCreateThread(c);if(!b.openSliceCount)break;d=b.endSlice(d);args={};for(h in args)void 0!==d.args[h]&&this.model_.importErrors.push("Both the B and E events of "+d.name+"provided values for argument "+h+". The value of the E event will be used."),d.args[h]=event.args[h];break;case "C":a=parseInt(b[1]);h=b[2];c=parseInt(b[3]);l=this.model_.getOrCreateProcess(a).getOrCreateCounter(null,
-h);0==l.numSeries&&(l.seriesNames.push("value"),l.seriesColors.push(tracing.getStringColorId(l.name+".value")));l.timestamps.push(d);l.samples.push(c);break;default:return!1}return!0}};d.registerSubtype(e);return{LinuxPerfAndroidParser:e}});base.require("timeline_model");base.require("timeline_color_scheme");base.require("linux_perf_cpufreq_parser");base.require("linux_perf_drm_parser");base.require("linux_perf_exynos_parser");base.require("linux_perf_gesture_parser");base.require("linux_perf_i915_parser");
-base.require("linux_perf_mali_parser");base.require("linux_perf_power_parser");base.require("linux_perf_sched_parser");base.require("linux_perf_workqueue_parser");base.require("linux_perf_android_parser");
+base.exportTo("tracing",function(){function e(a){d.call(this,a);a.registerEventHandler("tracing_mark_write:android",e.prototype.traceMarkWriteAndroidEvent.bind(this));a.registerEventHandler("0:android",e.prototype.traceMarkWriteAndroidEvent.bind(this));this.model_=a.model_;this.ppids_={}}var d=tracing.LinuxPerfParser;e.prototype={__proto__:d.prototype,traceMarkWriteAndroidEvent:function(a,b,c,d,e,l){b=e[2].split("|");switch(b[0]){case "B":var a=parseInt(b[1]),h=b[2],b=this.model_.getOrCreateProcess(a).getOrCreateThread(c);
+b.name=l;if(!b.isTimestampValidForBeginOrEnd(d))return this.model_.importErrors.push("Timestamps are moving backward."),!1;this.ppids_[c]=a;b.beginSlice(null,h,d,{});break;case "E":a=this.ppids_[c];if(void 0===a)break;b=this.model_.getOrCreateProcess(a).getOrCreateThread(c);if(!b.openSliceCount)break;d=b.endSlice(d);args={};for(h in args)void 0!==d.args[h]&&this.model_.importErrors.push("Both the B and E events of "+d.name+"provided values for argument "+h+". The value of the E event will be used."),
+d.args[h]=event.args[h];break;case "C":a=parseInt(b[1]);h=b[2];c=parseInt(b[3]);l=this.model_.getOrCreateProcess(a).getOrCreateCounter(null,h);0==l.numSeries&&(l.seriesNames.push("value"),l.seriesColors.push(tracing.getStringColorId(l.name+".value")));l.timestamps.push(d);l.samples.push(c);break;default:return!1}return!0}};d.registerSubtype(e);return{LinuxPerfAndroidParser:e}});base.require("timeline_model");base.require("timeline_color_scheme");base.require("linux_perf_cpufreq_parser");base.require("linux_perf_drm_parser");
+base.require("linux_perf_exynos_parser");base.require("linux_perf_gesture_parser");base.require("linux_perf_i915_parser");base.require("linux_perf_mali_parser");base.require("linux_perf_power_parser");base.require("linux_perf_sched_parser");base.require("linux_perf_workqueue_parser");base.require("linux_perf_android_parser");
 base.exportTo("tracing",function(){function e(a){this.cpu=a}function d(a,b){this.importPriority=2;this.model_=a;this.events_=b;this.clockSyncRecords_=[];this.cpuStates_={};this.kernelThreadStates_={};this.buildMapFromLinuxPidsToTimelineThreads();this.lineNumber=-1;this.pseudoThreadCounter=1;this.parsers_=[];this.eventHandlers_={}}function a(a){return b.test(a)?b:c.test(a)?c:null}e.prototype={__proto__:Object.prototype,switchRunningLinuxPid:function(a,b,c,d,e,k){if(void 0!==this.lastActivePid&&0!=
 this.lastActivePid){var p=c-this.lastActiveTs;name=(a=a.threadsByLinuxPid[this.lastActivePid])?a.userFriendlyName:this.lastActiveComm;b=new tracing.TimelineSlice("",name,tracing.getStringColorId(name),this.lastActiveTs,{comm:this.lastActiveComm,tid:this.lastActivePid,prio:this.lastActivePrio,stateWhenDescheduled:b},p);this.cpu.slices.push(b)}this.lastActiveTs=c;this.lastActivePid=d;this.lastActiveComm=e;this.lastActivePrio=k}};TestExports={};var b=/^\s*(.+?)\s+\[(\d+)\]\s+[dX.][N.][Hhs.][0-9a-f.]\s+(\d+\.\d+):\s+(\S+):\s(.*)$/;
 TestExports.lineREWithIRQInfo=b;var c=/^\s*(.+?)\s+\[(\d+)\]\s*(\d+\.\d+):\s+(\S+):\s(.*)$/;TestExports.lineRE=c;TestExports.traceEventClockSyncRE=/trace_event_clock_sync: parent_ts=(\d+\.?\d*)/;TestExports.autoDetectLineRE=a;d.canImport=function(b){if(!("string"===typeof b||b instanceof String))return!1;if(/^# tracer:/.test(b))return!0;var c=/^(.+)\n/.exec(b);c&&(b=c[1]);return a(b)?!0:!1};d.prototype={__proto__:Object.prototype,buildMapFromLinuxPidsToTimelineThreads:function(){this.threadsByLinuxPid=
diff --git a/trace-viewer/src/linux_perf_android_parser.js b/trace-viewer/src/linux_perf_android_parser.js
index ccbab86..a9e0140 100644
--- a/trace-viewer/src/linux_perf_android_parser.js
+++ b/trace-viewer/src/linux_perf_android_parser.js
@@ -20,6 +20,8 @@
 
     importer.registerEventHandler('tracing_mark_write:android',
         LinuxPerfAndroidParser.prototype.traceMarkWriteAndroidEvent.bind(this));
+    importer.registerEventHandler('0:android',
+        LinuxPerfAndroidParser.prototype.traceMarkWriteAndroidEvent.bind(this));
 
     this.model_ = importer.model_;
     this.ppids_ = {};
diff --git a/trace-viewer/src/linux_perf_android_parser_test.html b/trace-viewer/src/linux_perf_android_parser_test.html
index 3b09a4a..43ffbea 100644
--- a/trace-viewer/src/linux_perf_android_parser_test.html
+++ b/trace-viewer/src/linux_perf_android_parser_test.html
@@ -17,7 +17,7 @@
 base.require('test_utils');
 base.require('linux_perf_importer');
 
-function testMaliDDKImport() {
+function testAndroidUserlandImport() {
   var lines = [
     'SurfaceFlinger-4831  [001] ...1 80909.598554: tracing_mark_write: B|4829|onMessageReceived',
     'SurfaceFlinger-4831  [001] ...1 80909.598572: tracing_mark_write: B|4829|handleMessageInvalidate',
@@ -60,6 +60,49 @@
   assertEquals(11, thread.slices.length);
 }
 
+function testAndroidUserlandLegacyKernelImport() {
+  var lines = [
+    'SurfaceFlinger-4831  [001] ...1 80909.598554: 0: B|4829|onMessageReceived',
+    'SurfaceFlinger-4831  [001] ...1 80909.598572: 0: B|4829|handleMessageInvalidate',
+    'SurfaceFlinger-4831  [001] ...1 80909.598590: 0: B|4829|latchBuffer',
+    'SurfaceFlinger-4831  [001] ...1 80909.598604: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598627: 0: B|4829|latchBuffer',
+    'SurfaceFlinger-4831  [001] ...1 80909.598651: 0: B|4829|updateTexImage',
+    'SurfaceFlinger-4831  [001] ...1 80909.598675: 0: B|4829|acquireBuffer',
+    'SurfaceFlinger-4831  [001] ...1 80909.598695: 0: B|4829|' +
+      'com.android.launcher/com.android.launcher2.Launcher: 0',
+    'SurfaceFlinger-4831  [001] ...1 80909.598709: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598733: 0: C|4829|' +
+      'com.android.launcher/com.android.launcher2.Launcher|0',
+    'SurfaceFlinger-4831  [001] ...1 80909.598746: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598844: 0: B|4829|releaseBuffer',
+    'SurfaceFlinger-4831  [001] ...1 80909.598862: 0: B|4829|' +
+      'com.android.launcher/com.android.launcher2.Launcher: 2',
+    'SurfaceFlinger-4831  [001] ...1 80909.598876: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598892: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598925: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598955: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.598988: 0: B|4829|latchBuffer',
+    'SurfaceFlinger-4831  [001] ...1 80909.599001: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.599021: 0: B|4829|latchBuffer',
+    'SurfaceFlinger-4831  [001] ...1 80909.599036: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.599068: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.599087: 0: E',
+    'SurfaceFlinger-4831  [001] ...1 80909.599104: 0: E'
+  ];
+  var m = new tracing.TimelineModel(lines.join('\n'), false);
+  assertEquals(0, m.importErrors.length);
+
+  var threads = m.getAllThreads();
+  assertEquals(1, threads.length);
+
+  var thread = threads[0];
+  assertEquals(4829, thread.pid);
+  assertEquals(4831, thread.tid);
+  assertEquals('SurfaceFlinger', thread.name);
+  assertEquals(11, thread.slices.length);
+}
+
 </script>
 </body>
 </html>