From: joon.c.baek Date: Fri, 14 Jul 2017 06:26:03 +0000 (+0900) Subject: Implement dump mode in ttrace_tinyara.py X-Git-Tag: 1.1_Public_Release~391^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fb5b7ec5805c0fa7d9aab4eb7e5093e1452ecb0;p=rtos%2Ftinyara.git Implement dump mode in ttrace_tinyara.py 1. Add options '-d' for dump. 2. Support artik053 device 3. User can use ttrace_tinyara.py only to get HTML report. Signed-Off-by : Changjoon.Baek --- diff --git a/tools/ttrace_parser/README.txt b/tools/ttrace_parser/README.txt new file mode 100644 index 0000000..0af9ac3 --- /dev/null +++ b/tools/ttrace_parser/README.txt @@ -0,0 +1,47 @@ +ttrace parser +============= + + These are files for parsing T-trace logs to visualize T-trace result + +Usage +====== + +1. The text file contains T-trace logs + $ ./ttrace_tinyara.py [-i ] [-o ] + + After running it, You can get HTML file which show T-trace results in . + If you run it without '-i' options, + ttrace_tinyara.py returned immediately. + If you run it without '-o' options, + HTML file will saved at same folder with input_filename. + +2. Dump from artik053 device + $ ./ttrace_tinyara.py [-d ] + + After running it, You can get HTML file which show T-trace results in current folder. + ttrace_tinyara.py will connect target as GDB and set breakpoint at wait_ttrace_dump(). + You had traced on target($ ttrace -s ), then run dump mode($ ttrace -d), + GDB will catch it and dump ttrace buffer. + + Detail examples are below: + 1. HOST$ ./ttrace_tinyara.py -d artik053 + 2. artik053$ ttrace -s apps libs ipc lock task + 3. artik053$ ttrace -f + 4. artik053$ ttrace -d + + Dump feature needs tinyara binary, System.map, artik053.cfg and openocd executable, + They are located in tinyara/build/output/bin and + tinyara/build/configs/artik053/tools/openocd. + These paths are set by default. + However, You had changed location of them, + You can specified paths to ./scripts/ttrace_tinyaraDump.py with -b, -d options. + + for examples, + $ HOST$ ./scripts/ttrace_tinyaraDump.py -t artik053 -b -d + +Example +======= + + $ ./ttrace_tinyara.py -i sample/sample_log + + You can get results of parsing 'sample_log' in 'sample' folder. diff --git a/tools/ttrace_parser/scripts/parse_dump b/tools/ttrace_parser/scripts/parse_dump new file mode 100755 index 0000000..a58fe22 Binary files /dev/null and b/tools/ttrace_parser/scripts/parse_dump differ diff --git a/tools/ttrace_parser/scripts/parse_dump.c b/tools/ttrace_parser/scripts/parse_dump.c new file mode 100644 index 0000000..18b1585 --- /dev/null +++ b/tools/ttrace_parser/scripts/parse_dump.c @@ -0,0 +1,208 @@ +/**************************************************************************** + * + * Copyright 2017 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +#include +#include +#include +#include +#include + +#define CODE_VARIABLE 0 +#define CODE_UNIQUE (1 << 7) + +#define MSG_BYTES 32 +#define COMM_BYTES 12 +#define BYTE_ALIGN 4 + +#define INVALID -1 +#define VALID 0 + +#define packed_struct __attribute__ ((packed)) + +int param = 0; + +struct sched_message { + short prev_pid; + unsigned char prev_prio; + unsigned char prev_state; + char prev_comm[COMM_BYTES]; + short next_pid; + unsigned char next_prio; + char pad; + char next_comm[COMM_BYTES]; +}; + +union trace_message { + char message[MSG_BYTES]; // 24B, message(192b) + struct sched_message sched_msg; +}; + +struct trace_packet { // total 40 byte(message), 16byte(uid) + int tv_sec; + int tv_nsec; + short pid; // 2B, int16_t(16b) + char event_type; // 1B, char(8b) + unsigned char codelen; // 1B, code(1b) + variable length(7b) or uid(7b) + int pad; + union trace_message msg; +}; + +static int print_uid_packet(struct trace_packet *packet) +{ + unsigned char uid = packet->codelen & (unsigned char)(~CODE_UNIQUE); + printf("[%06d:%06d] %03u: %c|%u\r\n", packet->tv_sec, packet->tv_nsec / 1000, (unsigned int)packet->pid, (unsigned int)packet->event_type, uid); + return sizeof(struct trace_packet) - MSG_BYTES; +} + +static int print_message_packet(struct trace_packet *packet) +{ + printf("[%06d:%06d] %03u: %c|%s\r\n", packet->tv_sec, packet->tv_nsec / 1000, (unsigned int)packet->pid, packet->event_type, packet->msg.message); + return sizeof(struct trace_packet); +} + +static int print_sched_packet(struct trace_packet *packet) +{ + printf("[%06d:%06d] %03u: %c|prev_comm=%s prev_pid=%u prev_prio=%u prev_state=%u ==> next_comm=%s next_pid=%u next_prio=%u\r\n", packet->tv_sec, packet->tv_nsec / 1000, (unsigned int)packet->pid, packet->event_type, packet->msg.sched_msg.prev_comm, (unsigned int)packet->msg.sched_msg.prev_pid, (unsigned int)packet->msg.sched_msg.prev_prio, (unsigned int)packet->msg.sched_msg.prev_state, packet->msg.sched_msg.next_comm, (unsigned int)packet->msg.sched_msg.next_pid, (unsigned int)packet->msg.sched_msg.next_prio); + return sizeof(struct trace_packet); +} + +static int print_packet(struct trace_packet *packet) +{ + int isSched = (packet->event_type == 's') ? 1 : 0; + int isUnique = (packet->codelen & CODE_UNIQUE); + + if (isSched) { + return print_sched_packet(packet); + } else if (isUnique) { + return print_uid_packet(packet); + } else { + return print_message_packet(packet); + } +} + +static void show_help() +{ + printf("usage: parse_dump [dumpfile]\r\n"); + printf("example: ./parse_dump ramdump\r\n"); +} + +static int check_args_validation(int argc, char **args) +{ + int i = 0; + if (argc != 2) { + show_help(); + return INVALID; + } + + return VALID; +} + +static int get_dumpsize(FILE *file) +{ + int size = 0; + fseek(file, 0, SEEK_END); + size = ftell(file); + fseek(file, 0, SEEK_SET); + return size; +} + +static FILE *open_dump(char *path) +{ + FILE *file = fopen(path, "r+"); + if (file == NULL) { + printf("Failed to open : %s\r\n", path); + } + return file; +} + +static char *alloc_tracebuffer(int size) +{ + char *bp = (char *)malloc(size * sizeof(char)); + if (bp == NULL) { + printf("Failed to zalloc buffer in ttrace\r\n"); + } + return bp; +} + +static void close_dump(FILE *file) +{ + if (file == NULL) { + printf("file pointer doesn't opened\r\n"); + return; + } + fclose(file); + return; +} + +static void free_tracebuffer(char *buffer) +{ + if (buffer == NULL) { + printf("tracebuffer dosen't allocated\r\n"); + return; + } + free(buffer); + return; +} + +static int read_tracebuffer(FILE *file, int bufsize) +{ + char *buffer = NULL; + int read_len = 0, offset = 0; + + buffer = alloc_tracebuffer(bufsize); + if (buffer == NULL) { + return INVALID; + } + + read_len = fread(buffer, sizeof(char), bufsize, file); + if (read_len < 0) { + return INVALID; + } + + while (offset < read_len) { + offset += print_packet((struct trace_packet *)(buffer + offset)); + } + + free_tracebuffer(buffer); + return VALID; +} + +int main(int argc, char **args) +{ + FILE *file; + int filesize, ret; + + if (INVALID == check_args_validation(argc, args)) { + return INVALID; + } + + file = open_dump(args[1]); + if (file == NULL) { + return INVALID; + } + + filesize = get_dumpsize(file); + if (filesize <= 0) { + return INVALID; + } + + ret = read_tracebuffer(file, filesize); + + close_dump(file); + return ret; +} diff --git a/tools/ttrace_parser/scripts/prefix.html b/tools/ttrace_parser/scripts/prefix.html new file mode 100644 index 0000000..66f1f19 --- /dev/null +++ b/tools/ttrace_parser/scripts/prefix.html @@ -0,0 +1,38 @@ + + + + +Tizen System Trace +%s +%s + + + + +
%s
+
+
+ + + + + diff --git a/tools/ttrace_parser/scripts/tscript.js b/tools/ttrace_parser/scripts/tscript.js new file mode 100755 index 0000000..66511b2 --- /dev/null +++ b/tools/ttrace_parser/scripts/tscript.js @@ -0,0 +1,8 @@ +window.FLATTENED={},window.FLATTENED_RAW_SCRIPTS={},window.FLATTENED.base=!0,window.FLATTENED["tracing.color_scheme"]=!0,window.FLATTENED["tracing.importer.linux_perf.parser"]=!0,window.FLATTENED["base.guid"]=!0,window.FLATTENED["tracing.trace_model.counter_series"]=!0,window.FLATTENED["tracing.importer.linux_perf.android_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.bus_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.clock_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.cpufreq_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.disk_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.drm_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.exynos_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.gesture_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.i915_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.kfunc_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.mali_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.power_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.sched_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.sync_parser"]=!0,window.FLATTENED["tracing.importer.linux_perf.workqueue_parser"]=!0,window.FLATTENED["base.event_target"]=!0,window.FLATTENED["base.events"]=!0,window.FLATTENED["base.range"]=!0,window.FLATTENED["tracing.filter"]=!0,window.FLATTENED["tracing.trace_model.counter"]=!0,window.FLATTENED["tracing.trace_model.trace_model_event"]=!0,window.FLATTENED["tracing.trace_model.slice"]=!0,window.FLATTENED["tracing.trace_model.cpu"]=!0,window.FLATTENED["base.sorted_array_utils"]=!0,window.FLATTENED["base.iteration_helpers"]=!0,window.FLATTENED["base.utils"]=!0,window.FLATTENED["tracing.trace_model.object_snapshot"]=!0,window.FLATTENED["tracing.trace_model.object_instance"]=!0,window.FLATTENED["tracing.trace_model.time_to_object_instance_map"]=!0,window.FLATTENED["tracing.trace_model.object_collection"]=!0,window.FLATTENED["tracing.trace_model.async_slice"]=!0,window.FLATTENED["tracing.trace_model.async_slice_group"]=!0,window.FLATTENED["tracing.trace_model.sample"]=!0,window.FLATTENED["tracing.trace_model.slice_group"]=!0,window.FLATTENED["tracing.trace_model.thread"]=!0,window.FLATTENED["base.settings"]=!0,window.FLATTENED["tracing.trace_model_settings"]=!0,window.FLATTENED["tracing.trace_model.process_base"]=!0,window.FLATTENED["tracing.trace_model.kernel"]=!0,window.FLATTENED["tracing.trace_model.process"]=!0,window.FLATTENED["tracing.trace_model"]=!0,window.FLATTENED["tracing.importer.linux_perf_importer"]=!0,window.FLATTENED_RAW_SCRIPTS["../third_party/gl-matrix/src/gl-matrix/common.js"]=!0,window.FLATTENED_RAW_SCRIPTS["../third_party/gl-matrix/src/gl-matrix/mat2d.js"]=!0,window.FLATTENED_RAW_SCRIPTS["../third_party/gl-matrix/src/gl-matrix/mat4.js"]=!0,window.FLATTENED_RAW_SCRIPTS["../third_party/gl-matrix/src/gl-matrix/vec2.js"]=!0,window.FLATTENED_RAW_SCRIPTS["../third_party/gl-matrix/src/gl-matrix/vec3.js"]=!0,window.FLATTENED_RAW_SCRIPTS["../third_party/gl-matrix/src/gl-matrix/vec4.js"]=!0,window.FLATTENED["base.gl_matrix"]=!0,window.FLATTENED["base.quad"]=!0,window.FLATTENED["tracing.trace_model.instant_event"]=!0,window.FLATTENED["tracing.importer.trace_event_importer"]=!0,window.FLATTENED["tracing.importer.v8.splaytree"]=!0,window.FLATTENED["tracing.importer.v8.codemap"]=!0,window.FLATTENED["tracing.importer.v8.log_reader"]=!0,window.FLATTENED["tracing.importer.v8_log_importer"]=!0,window.FLATTENED["tracing.importer"]=!0,window.FLATTENED["tracing.analysis.util"]=!0,window.FLATTENED["tracing.selection"]=!0,window.FLATTENED.ui=!0,window.FLATTENED["tracing.analysis.analysis_link"]=!0,window.FLATTENED["tracing.analysis.generic_object_view"]=!0,window.FLATTENED["tracing.analysis.analysis_results"]=!0,window.FLATTENED["tracing.analysis.analyze_counters"]=!0,window.FLATTENED["tracing.analysis.analyze_slices"]=!0,window.FLATTENED["tracing.analysis.analyze_selection"]=!0,window.FLATTENED["tracing.analysis.object_instance_view"]=!0,window.FLATTENED["tracing.analysis.object_snapshot_view"]=!0,window.FLATTENED["tracing.analysis.default_object_view"]=!0,window.FLATTENED["tracing.analysis.slice_view"]=!0,window.FLATTENED["tracing.analysis.analysis_view"]=!0,window.FLATTENED["base.properties"]=!0,window.FLATTENED["ui.overlay"]=!0,window.FLATTENED["tracing.category_filter_dialog"]=!0,window.FLATTENED["tracing.mouse_mode_constants"]=!0,window.FLATTENED["tracing.timeline_viewport"]=!0,window.FLATTENED["base.raf"]=!0,window.FLATTENED["ui.container_that_decorates_its_children"]=!0,window.FLATTENED["tracing.tracks.track"]=!0,window.FLATTENED["tracing.tracks.drawing_container"]=!0,window.FLATTENED["tracing.constants"]=!0,window.FLATTENED["tracing.tracks.heading_track"]=!0,window.FLATTENED["tracing.tracks.ruler_track"]=!0,window.FLATTENED["base.measuring_stick"]=!0,window.FLATTENED["tracing.tracks.container_track"]=!0,window.FLATTENED["tracing.fast_rect_renderer"]=!0,window.FLATTENED["tracing.tracks.slice_track"]=!0,window.FLATTENED["tracing.tracks.cpu_track"]=!0,window.FLATTENED["tracing.tracks.object_instance_track"]=!0,window.FLATTENED["tcmalloc.heap_instance_track"]=!0,window.FLATTENED["tracing.tracks.counter_track"]=!0,window.FLATTENED["tracing.tracks.spacing_track"]=!0,window.FLATTENED["tracing.tracks.slice_group_track"]=!0,window.FLATTENED["tracing.tracks.async_slice_group_track"]=!0,window.FLATTENED["tracing.tracks.thread_track"]=!0,window.FLATTENED["ui.dom_helpers"]=!0,window.FLATTENED["tracing.tracks.process_track_base"]=!0,window.FLATTENED["tracing.tracks.kernel_track"]=!0,window.FLATTENED["tracing.tracks.process_track"]=!0,window.FLATTENED["tracing.tracks.trace_model_track"]=!0,window.FLATTENED["ui.mouse_mode_selector"]=!0,window.FLATTENED["tracing.timeline_track_view"]=!0,window.FLATTENED["tracing.find_control"]=!0,window.FLATTENED["ui.drag_handle"]=!0,window.FLATTENED["tracing.timeline_view"]=!0,window.FLATTENED["tracing.standalone_timeline_view"]=!0;var PIDCommMap=function(){this.map=new Object};PIDCommMap.prototype={put:function(e,t){this.map[e]=t},get:function(e){return this.map[e]},clear:function(){this.map=new Object}};var customPIDMap=new PIDCommMap,templateData_=window.atob("PCEtLQpDb3B5cmlnaHQgKGMpIDIwMTMgVGhlIENocm9taXVtIEF1dGhvcnMuIEFsbCByaWdodHMgcm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M9ImNhdGVnb3JpZXMiPgogICAgICA8L2Rpdj4KICAgIDwvZm9ybT4KICA8L2Rpdj4KPC90ZW1wbGF0ZT4K"),templateElem_=document.createElement("div");for(templateElem_.innerHTML=templateData_;templateElem_.hasChildNodes();)document.head.appendChild(templateElem_.removeChild(templateElem_.firstChild));var global=this;this.base=function(){function d(e){"/"==e[e.length-1]&&(e=e.substring(0,e.length-1)),l=e}function b(e,t){n[e]||(n[e]=[]);for(var i=n[e],r=!1,s=0;sn;n++){var r=e[n].split("=");t[r[0]]=parseInt(r[1])}return t}var i=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:i.prototype,cpufreqSlice:function(e,t,i,n){i=this.importer.getOrCreatePseudoThread("cpufreq"),i.openSlice=t,e=new tracing.trace_model.Slice("",i.openSlice,tracing.getStringColorId(i.openSlice),e,n,0),i.thread.sliceGroup.pushSlice(e)},cpufreqBoostSlice:function(e,t,i){var n=this.importer.getOrCreatePseudoThread("cpufreq_boost");n.openSlice=t,e=new tracing.trace_model.Slice("",n.openSlice,tracing.getStringColorId(n.openSlice),e,i,0),n.thread.sliceGroup.pushSlice(e)},cpufreqUpDownEvent:function(e,i,n,r,s){return i=t(s.details),this.cpufreqSlice(r,e,i.cpu,i),!0},cpufreqTargetEvent:function(e,i,n,r,s){return i=t(s.details),this.cpufreqSlice(r,e,i.cpu,i),!0},cpufreqBoostUnboostEvent:function(e,t,i,n,r){return this.cpufreqBoostSlice(n,e,{type:r.details}),!0}},i.registerSubtype(e),{CpufreqParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("ext4_sync_file_enter",e.prototype.ext4SyncFileEnterEvent.bind(this)),i.registerEventHandler("ext4_sync_file_exit",e.prototype.ext4SyncFileExitEvent.bind(this)),i.registerEventHandler("block_rq_issue",e.prototype.blockRqIssueEvent.bind(this)),i.registerEventHandler("block_rq_complete",e.prototype.blockRqCompleteEvent.bind(this))}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,openAsyncSlice:function(e,t,i,n,r,s){i=this.importer.getOrCreateKernelThread(t+":"+i,n),e=new tracing.trace_model.AsyncSlice(t,s,tracing.getStringColorId(s),e),e.startThread=i.thread,i.openAsyncSlices||(i.openAsyncSlices={}),i.openAsyncSlices[r]=e},closeAsyncSlice:function(e,t,i,n,r,s){i=this.importer.getOrCreateKernelThread(t+":"+i,n),i.openAsyncSlices&&(n=i.openAsyncSlices[r])&&(n.duration=e-n.start,n.args=s,n.endThread=i.thread,n.subSlices=[new tracing.trace_model.Slice(t,n.title,n.colorId,n.start,n.args,n.duration)],i.thread.asyncSliceGroup.push(n),delete i.openAsyncSlices[r])},ext4SyncFileEnterEvent:function(e,t,i,n,r){return(e=/dev (\d+,\d+) ino (\d+) parent (\d+) datasync (\d+)/.exec(r.details))?(t=e[1],i=parseInt(e[2]),this.openAsyncSlice(n,"ext4",r.threadName,r.pid,t+"-"+i,1==e[4]?"fdatasync":"fsync"),!0):!1},ext4SyncFileExitEvent:function(e,t,i,n,r){return(i=/dev (\d+,\d+) ino (\d+) ret (\d+)/.exec(r.details))?(e=i[1],t=parseInt(i[2]),i=parseInt(i[3]),this.closeAsyncSlice(n,"ext4",r.threadName,r.pid,e+"-"+t,{device:e,inode:t,error:i}),!0):!1},blockRqIssueEvent:function(e,t,i,n,r){var s=/(\d+,\d+) (F)?([DWRN])(F)?(A)?(S)?(M)? \d+ \(.*\) (\d+) \+ (\d+) \[.*\]/.exec(r.details);if(!s)return!1;switch(s[3]){case"D":e="discard";break;case"W":e="write";break;case"R":e="read";break;case"N":e="none";break;default:e="unknown"}return s[2]&&(e+=" flush"),"F"==s[4]&&(e+=" fua"),"A"==s[5]&&(e+=" ahead"),"S"==s[6]&&(e+=" sync"),"M"==s[7]&&(e+=" meta"),t=s[1],i=parseInt(s[8]),s=parseInt(s[9]),this.openAsyncSlice(n,"block",r.threadName,r.pid,t+"-"+i+"-"+s,e),!0},blockRqCompleteEvent:function(e,t,i,n,r){var s=/(\d+,\d+) (F)?([DWRN])(F)?(A)?(S)?(M)? \(.*\) (\d+) \+ (\d+) \[(.*)\]/.exec(r.details);return s?(e=s[1],t=parseInt(s[8]),i=parseInt(s[9]),s=parseInt(s[10]),this.closeAsyncSlice(n,"block",r.threadName,r.pid,e+"-"+t+"-"+i,{device:e,sector:t,numSectors:i,error:s}),!0):!1}},t.registerSubtype(e),{DiskParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("drm_vblank_event",e.prototype.vblankEvent.bind(this))}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,drmVblankSlice:function(e,t,i){var n=this.importer.getOrCreatePseudoThread("drm_vblank");n.openSlice=t,e=new tracing.trace_model.Slice("",n.openSlice,tracing.getStringColorId(n.openSlice),e,i,0),n.thread.sliceGroup.pushSlice(e)},vblankEvent:function(e,t,i,n,r){return(t=/crtc=(\d+), seq=(\d+)/.exec(r.details))?(e=parseInt(t[1]),t=parseInt(t[2]),this.drmVblankSlice(n,"vblank:"+e,{crtc:e,seq:t}),!0):!1}},t.registerSubtype(e),{DrmParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("exynos_flip_request",e.prototype.flipEvent.bind(this)),i.registerEventHandler("exynos_flip_complete",e.prototype.flipEvent.bind(this)),i.registerEventHandler("exynos_busfreq_target_int",e.prototype.busfreqTargetIntEvent.bind(this)),i.registerEventHandler("exynos_busfreq_target_mif",e.prototype.busfreqTargetMifEvent.bind(this))}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,exynosFlipOpenSlice:function(e,t){var i=this.importer.getOrCreatePseudoThread("exynos_flip");i.openSliceTS=e,i.openSlice="flip:"+t},exynosFlipCloseSlice:function(e,t){var i=this.importer.getOrCreatePseudoThread("exynos_flip");if(i.openSlice){var n=new tracing.trace_model.Slice("",i.openSlice,tracing.getStringColorId(i.openSlice),i.openSliceTS,t,e-i.openSliceTS);i.thread.sliceGroup.pushSlice(n)}i.openSlice=void 0},flipEvent:function(e,t,i,n,r){return(t=/pipe=(\d+)/.exec(r.details))?(t=parseInt(t[1]),"exynos_flip_request"==e?this.exynosFlipOpenSlice(n,t):this.exynosFlipCloseSlice(n,{pipe:t}),!0):!1},exynosBusfreqSample:function(e,t,i){e=this.importer.getOrCreateCpuState(0).cpu.getOrCreateCounter("",e),0===e.numSeries&&e.addSeries(new tracing.trace_model.CounterSeries("frequency",tracing.getStringColorId(e.name+".frequency"))),e.series.forEach(function(e){e.addSample(t,i)})},busfreqTargetIntEvent:function(e,t,i,n,r){return(e=/frequency=(\d+)/.exec(r.details))?(this.exynosBusfreqSample("INT Frequency",n,parseInt(e[1])),!0):!1},busfreqTargetMifEvent:function(e,t,i,n,r){return(e=/frequency=(\d+)/.exec(r.details))?(this.exynosBusfreqSample("MIF Frequency",n,parseInt(e[1])),!0):!1}},t.registerSubtype(e),{ExynosParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("tracing_mark_write:log",e.prototype.logEvent.bind(this)),i.registerEventHandler("tracing_mark_write:SyncInterpret",e.prototype.syncEvent.bind(this)),i.registerEventHandler("tracing_mark_write:HandleTimer",e.prototype.timerEvent.bind(this))}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,gestureOpenSlice:function(e,t,i){this.importer.getOrCreatePseudoThread("gesture").thread.sliceGroup.beginSlice("touchpad_gesture",e,t,i)},gestureCloseSlice:function(e,t){var i=this.importer.getOrCreatePseudoThread("gesture").thread;if(i.sliceGroup.openSliceCount){var n=i.sliceGroup.mostRecentlyOpenedPartialSlice;n.title!=e?this.importer.importError("Titles do not match. Title is "+n.title+" in openSlice, and is "+e+" in endSlice"):i.sliceGroup.endSlice(t)}},logEvent:function(e,t,i,n,r){switch(e=/^\s*(\w+):\s*(\w+)$/.exec(r.details),e[1]){case"start":this.gestureOpenSlice("GestureLog",n,{name:e[2]}); +break;case"end":this.gestureCloseSlice("GestureLog",n)}return!0},syncEvent:function(e,t,i,n,r){switch(e=/^\s*(\w+):\s*(\w+)$/.exec(r.details),e[1]){case"start":this.gestureOpenSlice("SyncInterpret",n,{interpreter:e[2]});break;case"end":this.gestureCloseSlice("SyncInterpret",n)}return!0},timerEvent:function(e,t,i,n,r){switch(e=/^\s*(\w+):\s*(\w+)$/.exec(r.details),e[1]){case"start":this.gestureOpenSlice("HandleTimer",n,{interpreter:e[2]});break;case"end":this.gestureCloseSlice("HandleTimer",n)}return!0}},t.registerSubtype(e),{GestureParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("i915_gem_object_create",e.prototype.gemObjectCreateEvent.bind(this)),i.registerEventHandler("i915_gem_object_bind",e.prototype.gemObjectBindEvent.bind(this)),i.registerEventHandler("i915_gem_object_unbind",e.prototype.gemObjectBindEvent.bind(this)),i.registerEventHandler("i915_gem_object_change_domain",e.prototype.gemObjectChangeDomainEvent.bind(this)),i.registerEventHandler("i915_gem_object_pread",e.prototype.gemObjectPreadWriteEvent.bind(this)),i.registerEventHandler("i915_gem_object_pwrite",e.prototype.gemObjectPreadWriteEvent.bind(this)),i.registerEventHandler("i915_gem_object_fault",e.prototype.gemObjectFaultEvent.bind(this)),i.registerEventHandler("i915_gem_object_clflush",e.prototype.gemObjectDestroyEvent.bind(this)),i.registerEventHandler("i915_gem_object_destroy",e.prototype.gemObjectDestroyEvent.bind(this)),i.registerEventHandler("i915_gem_ring_dispatch",e.prototype.gemRingDispatchEvent.bind(this)),i.registerEventHandler("i915_gem_ring_flush",e.prototype.gemRingFlushEvent.bind(this)),i.registerEventHandler("i915_gem_request",e.prototype.gemRequestEvent.bind(this)),i.registerEventHandler("i915_gem_request_add",e.prototype.gemRequestEvent.bind(this)),i.registerEventHandler("i915_gem_request_complete",e.prototype.gemRequestEvent.bind(this)),i.registerEventHandler("i915_gem_request_retire",e.prototype.gemRequestEvent.bind(this)),i.registerEventHandler("i915_gem_request_wait_begin",e.prototype.gemRequestEvent.bind(this)),i.registerEventHandler("i915_gem_request_wait_end",e.prototype.gemRequestEvent.bind(this)),i.registerEventHandler("i915_gem_ring_wait_begin",e.prototype.gemRingWaitEvent.bind(this)),i.registerEventHandler("i915_gem_ring_wait_end",e.prototype.gemRingWaitEvent.bind(this)),i.registerEventHandler("i915_reg_rw",e.prototype.regRWEvent.bind(this)),i.registerEventHandler("i915_flip_request",e.prototype.flipEvent.bind(this)),i.registerEventHandler("i915_flip_complete",e.prototype.flipEvent.bind(this))}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,i915FlipOpenSlice:function(e,t,i){var n=this.importer.getOrCreatePseudoThread("i915_flip");n.openSliceTS=e,n.openSlice="flip:"+t+"/"+i},i915FlipCloseSlice:function(e,t){var i=this.importer.getOrCreatePseudoThread("i915_flip");if(i.openSlice){var n=new tracing.trace_model.Slice("",i.openSlice,tracing.getStringColorId(i.openSlice),i.openSliceTS,t,e-i.openSliceTS);i.thread.sliceGroup.pushSlice(n)}i.openSlice=void 0},i915GemObjectSlice:function(e,t,i,n){var r=this.importer.getOrCreatePseudoThread("i915_gem");r.openSlice=t+":"+i,e=new tracing.trace_model.Slice("",r.openSlice,tracing.getStringColorId(r.openSlice),e,n,0),r.thread.sliceGroup.pushSlice(e)},i915GemRingSlice:function(e,t,i,n,r){var s=this.importer.getOrCreatePseudoThread("i915_gem_ring");s.openSlice=t+":"+i+"."+n,e=new tracing.trace_model.Slice("",s.openSlice,tracing.getStringColorId(s.openSlice),e,r,0),s.thread.sliceGroup.pushSlice(e)},i915RegSlice:function(e,t,i,n){var r=this.importer.getOrCreatePseudoThread("i915_reg");r.openSlice=t+":"+i,e=new tracing.trace_model.Slice("",r.openSlice,tracing.getStringColorId(r.openSlice),e,n,0),r.thread.sliceGroup.pushSlice(e)},gemObjectCreateEvent:function(e,t,i,n,r){return(i=/obj=(\w+), size=(\d+)/.exec(r.details))?(t=i[1],i=parseInt(i[2]),this.i915GemObjectSlice(n,e,t,{obj:t,size:i}),!0):!1},gemObjectBindEvent:function(e,t,i,n,r){return(r=/obj=(\w+), offset=(\w+), size=(\d+)/.exec(r.details))?(t=r[1],i=r[2],r=parseInt(r[3]),this.i915ObjectGemSlice(n,e+":"+t,{obj:t,offset:i,size:r}),!0):!1},gemObjectChangeDomainEvent:function(e,t,i,n,r){return(t=/obj=(\w+), read=(\w+=>\w+), write=(\w+=>\w+)/.exec(r.details))?(i=t[1],this.i915GemObjectSlice(n,e,i,{obj:i,read:t[2],write:t[3]}),!0):!1},gemObjectPreadWriteEvent:function(e,t,i,n,r){return(r=/obj=(\w+), offset=(\d+), len=(\d+)/.exec(r.details))?(t=r[1],i=parseInt(r[2]),r=parseInt(r[3]),this.i915GemObjectSlice(n,e,t,{obj:t,offset:i,len:r}),!0):!1},gemObjectFaultEvent:function(e,t,i,n,r){return(r=/obj=(\w+), (\w+) index=(\d+)/.exec(r.details))?(t=r[1],i=r[2],r=parseInt(r[3]),this.i915GemObjectSlice(n,e,t,{obj:t,type:i,index:r}),!0):!1},gemObjectDestroyEvent:function(e,t,i,n,r){return(t=/obj=(\w+)/.exec(r.details))?(t=t[1],this.i915GemObjectSlice(n,e,t,{obj:t}),!0):!1},gemRingDispatchEvent:function(e,t,i,n,r){return(r=/dev=(\d+), ring=(\d+), seqno=(\d+)/.exec(r.details))?(t=parseInt(r[1]),i=parseInt(r[2]),r=parseInt(r[3]),this.i915GemRingSlice(n,e,t,i,{dev:t,ring:i,seqno:r}),!0):!1},gemRingFlushEvent:function(e,t,i,n,r){return(t=/dev=(\d+), ring=(\w+), invalidate=(\w+), flush=(\w+)/.exec(r.details))?(i=parseInt(t[1]),r=parseInt(t[2]),this.i915GemRingSlice(n,e,i,r,{dev:i,ring:r,invalidate:t[3],flush:t[4]}),!0):!1},gemRequestEvent:function(e,t,i,n,r){return(r=/dev=(\d+), ring=(\d+), seqno=(\d+)/.exec(r.details))?(t=parseInt(r[1]),i=parseInt(r[2]),r=parseInt(r[3]),this.i915GemRingSlice(n,e,t,i,{dev:t,ring:i,seqno:r}),!0):!1},gemRingWaitEvent:function(e,t,i,n,r){return(i=/dev=(\d+), ring=(\d+)/.exec(r.details))?(t=parseInt(i[1]),i=parseInt(i[2]),this.i915GemRingSlice(n,e,t,i,{dev:t,ring:i}),!0):!1},regRWEvent:function(e,t,i,n,r){return(e=/(\w+) reg=(\w+), len=(\d+), val=(\(\w+, \w+\))/.exec(r.details))?(t=e[1],i=e[2],this.i915RegSlice(n,t,i,{rw:t,reg:i,len:e[3],data:e[3]}),!0):!1},flipEvent:function(e,t,i,n,r){return(i=/plane=(\d+), obj=(\w+)/.exec(r.details))?(t=parseInt(i[1]),i=i[2],"i915_flip_request"==e?this.i915FlipOpenSlice(n,i,t):this.i915FlipCloseSlice(n,{obj:i,plane:t}),!0):!1}},t.registerSubtype(e),{I915Parser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("graph_ent",e.prototype.traceKernelFuncEnterEvent.bind(this)),i.registerEventHandler("graph_ret",e.prototype.traceKernelFuncReturnEvent.bind(this)),this.model_=i.model_,this.ppids_={}}var t=tracing.importer.linux_perf.Parser,i=/func=(.+)/;return e.prototype={__proto__:t.prototype,traceKernelFuncEnterEvent:function(e,t,n,r,s){return e=i.exec(s.details),e&&void 0!==s.tgid?(t=parseInt(s.tgid),e=e[1],n=this.model_.getOrCreateProcess(t).getOrCreateThread(n),n.name=s.threadName,s=n.kernelSliceGroup,s.isTimestampValidForBeginOrEnd(r)?(s.beginSlice(null,e,r,{}),!0):(this.model_.importErrors.push("Timestamps are moving backward."),!1)):!1},traceKernelFuncReturnEvent:function(e,t,i,n,r){return void 0===r.tgid?!1:(e=parseInt(r.tgid),i=this.model_.getOrCreateProcess(e).getOrCreateThread(i),i.name=r.threadName,r=i.kernelSliceGroup,r.isTimestampValidForBeginOrEnd(n)?(0n;n++){var r="JS"+n,s="mali_hwc_"+r;this.addJMCounter(s+"_JOBS",r+" Jobs"),this.addJMCounter(s+"_TASKS",r+" Tasks"),this.addJMCycles(s+"_ACTIVE",r+" Active"),this.addJMCycles(s+"_WAIT_READ",r+" Wait Read"),this.addJMCycles(s+"_WAIT_ISSUE",r+" Wait Issue"),this.addJMCycles(s+"_WAIT_DEPEND",r+" Wait Depend"),this.addJMCycles(s+"_WAIT_FINISH",r+" Wait Finish")}this.addTilerCounter("mali_hwc_TRIANGLES","Triangles"),this.addTilerCounter("mali_hwc_QUADS","Quads"),this.addTilerCounter("mali_hwc_POLYGONS","Polygons"),this.addTilerCounter("mali_hwc_POINTS","Points"),this.addTilerCounter("mali_hwc_LINES","Lines"),this.addTilerCounter("mali_hwc_VCACHE_HIT","VCache Hit"),this.addTilerCounter("mali_hwc_VCACHE_MISS","VCache Miss"),this.addTilerCounter("mali_hwc_FRONT_FACING","Front Facing"),this.addTilerCounter("mali_hwc_BACK_FACING","Back Facing"),this.addTilerCounter("mali_hwc_PRIM_VISIBLE","Prim Visible"),this.addTilerCounter("mali_hwc_PRIM_CULLED","Prim Culled"),this.addTilerCounter("mali_hwc_PRIM_CLIPPED","Prim Clipped"),this.addTilerCounter("mali_hwc_WRBUF_HIT","Wrbuf Hit"),this.addTilerCounter("mali_hwc_WRBUF_MISS","Wrbuf Miss"),this.addTilerCounter("mali_hwc_WRBUF_LINE","Wrbuf Line"),this.addTilerCounter("mali_hwc_WRBUF_PARTIAL","Wrbuf Partial"),this.addTilerCounter("mali_hwc_WRBUF_STALL","Wrbuf Stall"),this.addTilerCycles("mali_hwc_ACTIVE","Tiler Active"),this.addTilerCycles("mali_hwc_INDEX_WAIT","Index Wait"),this.addTilerCycles("mali_hwc_INDEX_RANGE_WAIT","Index Range Wait"),this.addTilerCycles("mali_hwc_VERTEX_WAIT","Vertex Wait"),this.addTilerCycles("mali_hwc_PCACHE_WAIT","Pcache Wait"),this.addTilerCycles("mali_hwc_WRBUF_WAIT","Wrbuf Wait"),this.addTilerCycles("mali_hwc_BUS_READ","Bus Read"),this.addTilerCycles("mali_hwc_BUS_WRITE","Bus Write"),this.addTilerCycles("mali_hwc_TILER_UTLB_STALL","Tiler UTLB Stall"),this.addTilerCycles("mali_hwc_TILER_UTLB_HIT","Tiler UTLB Hit"),this.addFragCycles("mali_hwc_FRAG_ACTIVE","Active"),this.addFragCounter("mali_hwc_FRAG_PRIMATIVES","Primitives"),this.addFragCounter("mali_hwc_FRAG_PRIMATIVES_DROPPED","Primitives Dropped"),this.addFragCycles("mali_hwc_FRAG_CYCLE_DESC","Descriptor Processing"),this.addFragCycles("mali_hwc_FRAG_CYCLES_PLR","PLR Processing??"),this.addFragCycles("mali_hwc_FRAG_CYCLES_VERT","Vertex Processing"),this.addFragCycles("mali_hwc_FRAG_CYCLES_TRISETUP","Triangle Setup"),this.addFragCycles("mali_hwc_FRAG_CYCLES_RAST","Rasterization???"),this.addFragCounter("mali_hwc_FRAG_THREADS","Threads"),this.addFragCounter("mali_hwc_FRAG_DUMMY_THREADS","Dummy Threads"),this.addFragCounter("mali_hwc_FRAG_QUADS_RAST","Quads Rast"),this.addFragCounter("mali_hwc_FRAG_QUADS_EZS_TEST","Quads EZS Test"),this.addFragCounter("mali_hwc_FRAG_QUADS_EZS_KILLED","Quads EZS Killed"),this.addFragCounter("mali_hwc_FRAG_QUADS_LZS_TEST","Quads LZS Test"),this.addFragCounter("mali_hwc_FRAG_QUADS_LZS_KILLED","Quads LZS Killed"),this.addFragCycles("mali_hwc_FRAG_CYCLE_NO_TILE","No Tiles"),this.addFragCounter("mali_hwc_FRAG_NUM_TILES","Tiles"),this.addFragCounter("mali_hwc_FRAG_TRANS_ELIM","Transactions Eliminated"),this.addComputeCycles("mali_hwc_COMPUTE_ACTIVE","Active"),this.addComputeCounter("mali_hwc_COMPUTE_TASKS","Tasks"),this.addComputeCounter("mali_hwc_COMPUTE_THREADS","Threads Started"),this.addComputeCycles("mali_hwc_COMPUTE_CYCLES_DESC","Waiting for Descriptors"),this.addTripipeCycles("mali_hwc_TRIPIPE_ACTIVE","Active"),this.addArithCounter("mali_hwc_ARITH_WORDS","Instructions (/Pipes)"),this.addArithCycles("mali_hwc_ARITH_CYCLES_REG","Reg scheduling stalls (/Pipes)"),this.addArithCycles("mali_hwc_ARITH_CYCLES_L0","L0 cache miss stalls (/Pipes)"),this.addArithCounter("mali_hwc_ARITH_FRAG_DEPEND","Frag dep check failures (/Pipes)"),this.addLSCounter("mali_hwc_LS_WORDS","Instruction Words Completed"),this.addLSCounter("mali_hwc_LS_ISSUES","Full Pipeline Issues"),this.addLSCounter("mali_hwc_LS_RESTARTS","Restarts (unpairable insts)"),this.addLSCounter("mali_hwc_LS_REISSUES_MISS","Pipeline reissue (cache miss/uTLB)"),this.addLSCounter("mali_hwc_LS_REISSUES_VD","Pipeline reissue (varying data)"),this.addLSCounter("mali_hwc_LS_REISSUE_ATTRIB_MISS","Pipeline reissue (attribute cache miss)"),this.addLSCounter("mali_hwc_LS_REISSUE_NO_WB","Writeback not used"),this.addTexCounter("mali_hwc_TEX_WORDS","Words"),this.addTexCounter("mali_hwc_TEX_BUBBLES","Bubbles"),this.addTexCounter("mali_hwc_TEX_WORDS_L0","Words L0"),this.addTexCounter("mali_hwc_TEX_WORDS_DESC","Words Desc"),this.addTexCounter("mali_hwc_TEX_THREADS","Threads"),this.addTexCounter("mali_hwc_TEX_RECIRC_FMISS","Recirc due to Full Miss"),this.addTexCounter("mali_hwc_TEX_RECIRC_DESC","Recirc due to Desc Miss"),this.addTexCounter("mali_hwc_TEX_RECIRC_MULTI","Recirc due to Multipass"),this.addTexCounter("mali_hwc_TEX_RECIRC_PMISS","Recirc due to Partial Cache Miss"),this.addTexCounter("mali_hwc_TEX_RECIRC_CONF","Recirc due to Cache Conflict"),this.addLSCCounter("mali_hwc_LSC_READ_HITS","Read Hits"),this.addLSCCounter("mali_hwc_LSC_READ_MISSES","Read Misses"),this.addLSCCounter("mali_hwc_LSC_WRITE_HITS","Write Hits"),this.addLSCCounter("mali_hwc_LSC_WRITE_MISSES","Write Misses"),this.addLSCCounter("mali_hwc_LSC_ATOMIC_HITS","Atomic Hits"),this.addLSCCounter("mali_hwc_LSC_ATOMIC_MISSES","Atomic Misses"),this.addLSCCounter("mali_hwc_LSC_LINE_FETCHES","Line Fetches"),this.addLSCCounter("mali_hwc_LSC_DIRTY_LINE","Dirty Lines"),this.addLSCCounter("mali_hwc_LSC_SNOOPS","Snoops"),this.addAXICounter("mali_hwc_AXI_TLB_STALL","Address channel stall"),this.addAXICounter("mali_hwc_AXI_TLB_MISS","Cache Miss"),this.addAXICounter("mali_hwc_AXI_TLB_TRANSACTION","Transactions"),this.addAXICounter("mali_hwc_LS_TLB_MISS","LS Cache Miss"),this.addAXICounter("mali_hwc_LS_TLB_HIT","LS Cache Hit"),this.addAXICounter("mali_hwc_AXI_BEATS_READ","Read Beats"),this.addAXICounter("mali_hwc_AXI_BEATS_WRITE","Write Beats"),this.addMMUCounter("mali_hwc_MMU_TABLE_WALK","Page Table Walks"),this.addMMUCounter("mali_hwc_MMU_REPLAY_MISS","Cache Miss from Replay Buffer"),this.addMMUCounter("mali_hwc_MMU_REPLAY_FULL","Replay Buffer Full"),this.addMMUCounter("mali_hwc_MMU_NEW_MISS","Cache Miss on New Request"),this.addMMUCounter("mali_hwc_MMU_HIT","Cache Hit"),this.addMMUCycles("mali_hwc_UTLB_STALL","UTLB Stalled"),this.addMMUCycles("mali_hwc_UTLB_REPLAY_MISS","UTLB Replay Miss"),this.addMMUCycles("mali_hwc_UTLB_REPLAY_FULL","UTLB Replay Full"),this.addMMUCycles("mali_hwc_UTLB_NEW_MISS","UTLB New Miss"),this.addMMUCycles("mali_hwc_UTLB_HIT","UTLB Hit"),this.addL2Counter("mali_hwc_L2_READ_BEATS","Read Beats"),this.addL2Counter("mali_hwc_L2_WRITE_BEATS","Write Beats"),this.addL2Counter("mali_hwc_L2_ANY_LOOKUP","Any Lookup"),this.addL2Counter("mali_hwc_L2_READ_LOOKUP","Read Lookup"),this.addL2Counter("mali_hwc_L2_SREAD_LOOKUP","Shareable Read Lookup"),this.addL2Counter("mali_hwc_L2_READ_REPLAY","Read Replayed"),this.addL2Counter("mali_hwc_L2_READ_SNOOP","Read Snoop"),this.addL2Counter("mali_hwc_L2_READ_HIT","Read Cache Hit"),this.addL2Counter("mali_hwc_L2_CLEAN_MISS","CleanUnique Miss"),this.addL2Counter("mali_hwc_L2_WRITE_LOOKUP","Write Lookup"),this.addL2Counter("mali_hwc_L2_SWRITE_LOOKUP","Shareable Write Lookup"),this.addL2Counter("mali_hwc_L2_WRITE_REPLAY","Write Replayed"),this.addL2Counter("mali_hwc_L2_WRITE_SNOOP","Write Snoop"),this.addL2Counter("mali_hwc_L2_WRITE_HIT","Write Cache Hit"),this.addL2Counter("mali_hwc_L2_EXT_READ_FULL","ExtRD with BIU Full"),this.addL2Counter("mali_hwc_L2_EXT_READ_HALF","ExtRD with BIU >1/2 Full"),this.addL2Counter("mali_hwc_L2_EXT_WRITE_FULL","ExtWR with BIU Full"),this.addL2Counter("mali_hwc_L2_EXT_WRITE_HALF","ExtWR with BIU >1/2 Full"),this.addL2Counter("mali_hwc_L2_EXT_READ","External Read (ExtRD)"),this.addL2Counter("mali_hwc_L2_EXT_READ_LINE","ExtRD (linefill)"),this.addL2Counter("mali_hwc_L2_EXT_WRITE","External Write (ExtWR)"),this.addL2Counter("mali_hwc_L2_EXT_WRITE_LINE","ExtWR (linefill)"),this.addL2Counter("mali_hwc_L2_EXT_WRITE_SMALL","ExtWR (burst size <64B)"),this.addL2Counter("mali_hwc_L2_EXT_BARRIER","External Barrier"),this.addL2Counter("mali_hwc_L2_EXT_AR_STALL","Address Read stalls"),this.addL2Counter("mali_hwc_L2_EXT_R_BUF_FULL","Response Buffer full stalls"),this.addL2Counter("mali_hwc_L2_EXT_RD_BUF_FULL","Read Data Buffer full stalls"),this.addL2Counter("mali_hwc_L2_EXT_R_RAW","RAW hazard stalls"),this.addL2Counter("mali_hwc_L2_EXT_W_STALL","Write Data stalls"),this.addL2Counter("mali_hwc_L2_EXT_W_BUF_FULL","Write Data Buffer full"),this.addL2Counter("mali_hwc_L2_EXT_R_W_HAZARD","WAW or WAR hazard stalls"),this.addL2Counter("mali_hwc_L2_TAG_HAZARD","Tag hazard replays"),this.addL2Cycles("mali_hwc_L2_SNOOP_FULL","Snoop buffer full"),this.addL2Cycles("mali_hwc_L2_REPLAY_FULL","Replay buffer full"),i.registerEventHandler("tracing_mark_write:mali_driver",e.prototype.maliDDKEvent.bind(this)),this.model_=i.model_}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,maliDDKOpenSlice:function(e,t,i,n,r){e=this.importer.model_.getOrCreateProcess(e).getOrCreateThread(t),n=/^([\w\d_]*)(?:\(\))?:?\s*(.*)$/.exec(n),e.sliceGroup.beginSlice("gpu-driver",n[1],i,{args:n[2],blockinfo:r})},maliDDKCloseSlice:function(e,t,i){e=this.importer.model_.getOrCreateProcess(e).getOrCreateThread(t),e.sliceGroup.openSliceCount&&e.sliceGroup.endSlice(i)},autoDetectLineRE:function(e){var t=/^\s*\(([\w\-]*)\)\s*(\w+):\s*([\w\\\/\.\-]*@\d*):?\s*(.*)$/;return t.test(e)?t:(t=/^s*()(\w+):\s*([\w\\\/.\-]*):?\s*(.*)$/,t.test(e)?t:null)},lineRE:null,maliDDKEvent:function(e,t,i,n,r){if(null==this.lineRE&&(this.lineRE=this.autoDetectLineRE(r.details),null==this.lineRE))return!1;switch(e=this.lineRE.exec(r.details),t=""===e[1]?"mali":e[1],e[2]){case"cros_trace_print_enter":this.maliDDKOpenSlice(i,t,n,e[4],e[3]);break;case"cros_trace_print_exit":this.maliDDKCloseSlice(i,t,n,[],e[3])}return!0},dvfsSample:function(e,t,i,n){var r=parseInt(n);e=this.model_.getOrCreateProcess(0).getOrCreateCounter("DVFS",e),0===e.numSeries&&e.addSeries(new tracing.trace_model.CounterSeries(t,tracing.getStringColorId(e.name))),e.series.forEach(function(e){e.addSample(i,r)})},dvfsEventEvent:function(e,t,i,n,r){return(e=/utilization=(\d+)/.exec(r.details))?(this.dvfsSample("DVFS Utilization","utilization",n,e[1]),!0):!1},dvfsSetClockEvent:function(e,t,i,n,r){return(e=/frequency=(\d+)/.exec(r.details))?(this.dvfsSample("DVFS Frequency","frequency",n,e[1]),!0):!1},dvfsSetVoltageEvent:function(e,t,i,n,r){return(e=/voltage=(\d+)/.exec(r.details))?(this.dvfsSample("DVFS Voltage","voltage",n,e[1]),!0):!1},hwcSample:function(e,t,i,n,r){if(r=/val=(\d+)/.exec(r.details),!r)return!1;var s=parseInt(r[1]);return e=this.model_.getOrCreateProcess(0).getOrCreateCounter(e,t),0===e.numSeries&&e.addSeries(new tracing.trace_model.CounterSeries(i,tracing.getStringColorId(e.name))),e.series.forEach(function(e){e.addSample(n,s)}),!0},jmSample:function(e,t,i,n){return this.hwcSample("mali:jm","JM: "+e,t,i,n)},addJMCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.jmSample(t,"count",r,s)}.bind(this))},addJMCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.jmSample(t,"cycles",r,s)}.bind(this))},tilerSample:function(e,t,i,n){return this.hwcSample("mali:tiler","Tiler: "+e,t,i,n)},addTilerCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.tilerSample(t,"count",r,s)}.bind(this))},addTilerCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.tilerSample(t,"cycles",r,s)}.bind(this))},fragSample:function(e,t,i,n){return this.hwcSample("mali:fragment","Fragment: "+e,t,i,n)},addFragCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.fragSample(t,"count",r,s)}.bind(this))},addFragCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.fragSample(t,"cycles",r,s)}.bind(this))},computeSample:function(e,t,i,n){return this.hwcSample("mali:compute","Compute: "+e,t,i,n)},addComputeCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.computeSample(t,"count",r,s)}.bind(this))},addComputeCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.computeSample(t,"cycles",r,s)}.bind(this))},addTripipeCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.hwcSample("mali:shader","Tripipe: "+t,"cycles",r,s)}.bind(this))},arithSample:function(e,t,i,n){return this.hwcSample("mali:arith","Arith: "+e,t,i,n)},addArithCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.arithSample(t,"count",r,s)}.bind(this))},addArithCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.arithSample(t,"cycles",r,s)}.bind(this))},addLSCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.hwcSample("mali:ls","LS: "+t,"count",r,s)}.bind(this))},textureSample:function(e,t,i,n){return this.hwcSample("mali:texture","Texture: "+e,t,i,n)},addTexCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.textureSample(t,"count",r,s)}.bind(this))},addLSCCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.hwcSample("mali:lsc","LSC: "+t,"count",r,s)}.bind(this))},addAXICounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.hwcSample("mali:axi","AXI: "+t,"count",r,s)}.bind(this))},mmuSample:function(e,t,i,n){return this.hwcSample("mali:mmu","MMU: "+e,t,i,n)},addMMUCounter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.mmuSample(t,"count",r,s)}.bind(this))},addMMUCycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.mmuSample(t,"cycles",r,s)}.bind(this))},l2Sample:function(e,t,i,n){return this.hwcSample("mali:l2","L2: "+e,t,i,n)},addL2Counter:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.l2Sample(t,"count",r,s)}.bind(this))},addL2Cycles:function(e,t){this.importer.registerEventHandler(e,function(e,i,n,r,s){return this.l2Sample(t,"cycles",r,s)}.bind(this))}},t.registerSubtype(e),{MaliParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.require("tracing.trace_model.counter_series"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("power_start",e.prototype.powerStartEvent.bind(this)),i.registerEventHandler("power_frequency",e.prototype.powerFrequencyEvent.bind(this)),i.registerEventHandler("cpu_frequency",e.prototype.cpuFrequencyEvent.bind(this)),i.registerEventHandler("cpu_idle",e.prototype.cpuIdleEvent.bind(this))}var t=tracing.importer.linux_perf.Parser;return e.prototype={__proto__:t.prototype,cpuStateSlice:function(e,t,i,n){t=this.importer.getOrCreateCpuState(t),"1"!=i?this.importer.importError("Don't understand power_start events of type "+i):(i=t.cpu.getOrCreateCounter("","C-State"),0===i.numSeries&&i.addSeries(new tracing.trace_model.CounterSeries("state",tracing.getStringColorId(i.name+".state"))),i.series.forEach(function(t){t.addSample(e,n)}))},cpuIdleSlice:function(e,t,i){t=this.importer.getOrCreateCpuState(t).cpu.getOrCreateCounter("","C-State"),0===t.numSeries&&t.addSeries(new tracing.trace_model.CounterSeries("state",tracing.getStringColorId(t.name)));var n=4294967295!=i?i:0;t.series.forEach(function(t){t.addSample(e,n)})},cpuFrequencySlice:function(e,t,i){t=this.importer.getOrCreateCpuState(t).cpu.getOrCreateCounter("","Clock Frequency"),0===t.numSeries&&t.addSeries(new tracing.trace_model.CounterSeries("state",tracing.getStringColorId(t.name+".state"))),t.series.forEach(function(t){t.addSample(e,i)})},powerStartEvent:function(e,t,i,n,r){return(e=/type=(\d+) state=(\d) cpu_id=(\d)+/.exec(r.details))?(t=parseInt(e[3]),i=parseInt(e[2]),this.cpuStateSlice(n,t,e[1],i),!0):!1},powerFrequencyEvent:function(e,t,i,n,r){return(t=/type=(\d+) state=(\d+) cpu_id=(\d)+/.exec(r.details))?(e=parseInt(t[3]),t=parseInt(t[2]),this.cpuFrequencySlice(n,e,t),!0):!1},cpuFrequencyEvent:function(e,t,i,n,r){return(t=/state=(\d+) cpu_id=(\d)+/.exec(r.details))?(e=parseInt(t[2]),t=parseInt(t[1]),this.cpuFrequencySlice(n,e,t),!0):!1},cpuIdleEvent:function(e,t,i,n,r){return(t=/state=(\d+) cpu_id=(\d)+/.exec(r.details))?(e=parseInt(t[2]),t=parseInt(t[1]),this.cpuIdleSlice(n,e,t),!0):!1}},t.registerSubtype(e),{PowerParser:e}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("sched_switch",e.prototype.schedSwitchEvent.bind(this)),i.registerEventHandler("sched_wakeup",e.prototype.schedWakeupEvent.bind(this))}var t=tracing.importer.linux_perf.Parser,i={},n=RegExp("prev_comm=(.+) prev_pid=(\\d+) prev_prio=(\\d+) prev_state=(\\S\\+?|\\S\\|\\S) ==> next_comm=(.+) next_pid=(\\d+) next_prio=(\\d+)");i.schedSwitchRE=n;var r=/comm=(.+) pid=(\d+) prio=(\d+) success=(\d+) target_cpu=(\d+)/;return i.schedWakeupRE=r,e.prototype={__proto__:t.prototype,schedSwitchEvent:function(e,t,i,r,s){var a=n.exec(s.details);return a?(e=a[4],i=a[5],s=parseInt(a[6]),a=parseInt(a[7]),customPIDMap.put(s,i),this.importer.getOrCreateCpuState(t).switchRunningLinuxPid(this.importer,e,r,s,i,a),!0):!1},schedWakeupEvent:function(e,t,i,n,s){return(s=r.exec(s.details))?(e=i,t=s[1],i=parseInt(s[2]),s=parseInt(s[3]),this.importer.markPidRunnable(n,i,t,s,e),!0):!1}},t.registerSubtype(e),{SchedParser:e,_SchedParserTestExports:i}}),base.require("tracing.importer.linux_perf.parser"),base.exportTo("tracing.importer.linux_perf",function(){function e(i){t.call(this,i),i.registerEventHandler("sync_timeline",e.prototype.timelineEvent.bind(this)),i.registerEventHandler("sync_wait",e.prototype.syncWaitEvent.bind(this)),i.registerEventHandler("sync_pt",e.prototype.syncPtEvent.bind(this)),this.model_=i.model_}var t=tracing.importer.linux_perf.Parser,i=/name=(\S+) value=(\S*)/,n=/(\S+) name=(\S+) state=(\d+)/,r=/name=(\S+) value=(\S*)/;return e.prototype={__proto__:t.prototype,timelineEvent:function(e,t,n,r,s){return(e=i.exec(s.details))?(t=this.importer.getOrCreatePseudoThread(e[1]),void 0!==t.lastActiveTs&&(n=r-t.lastActiveTs,s=t.lastActiveValue,void 0==s&&(s=" "),n=new tracing.trace_model.Slice("",s,tracing.getStringColorId(s),t.lastActiveTs,{},n),t.thread.sliceGroup.pushSlice(n)),t.lastActiveTs=r,t.lastActiveValue=e[2],!0):!1},syncWaitEvent:function(e,t,i,r,s){if(e=n.exec(s.details),!e||void 0===s.tgid)return!1;if(t=parseInt(s.tgid),i=this.model_.getOrCreateProcess(t).getOrCreateThread(i),i.name=s.threadName,s=i.kernelSliceGroup,!s.isTimestampValidForBeginOrEnd(r))return this.model_.importErrors.push("Timestamps are moving backward."),!1;if(i='fence_wait("'+e[2]+'")',"begin"==e[1])s.beginSlice(null,i,r,{"Start state":e[3]});else{if("end"!=e[1])return!1;0i.indexOf(t)&&i.push(t)}else this.listeners_[e]=[t]},removeEventListener:function(e,t){if(this.listeners_&&e in this.listeners_){var i=this.listeners_[e],n=i.indexOf(t);n>=0&&(1==i.length?delete this.listeners_[e]:i.splice(n,1))}},dispatchEvent:function(e){if(!this.listeners_)return!0;var t=this;e.__defineGetter__("target",function(){return t}),e.preventDefault=function(){this.returnValue=!1};var i=e.type,n=0;if(i in this.listeners_)for(var r,i=this.listeners_[i].concat(),s=0;r=i[s];s++)n=r.handleEvent?n|!1===r.handleEvent.call(r,e):n|!1===r.call(this,e);return!n&&e.returnValue},hasEventListener:function(e){return void 0!==this.listeners_[e]}};var t={decorate:function(e){for(var i in t)if("decorate"!=i){var n=t[i];"function"==typeof n&&(e[i]=n)}e.listenerCounts_={}},addEventListener:function(e,t,i){this.__proto__.addEventListener.call(this,e,t,i),void 0===this.listenerCounts_[e]&&(this.listenerCounts_[e]=0),this.listenerCounts_[e]++},removeEventListener:function(e,t,i){this.__proto__.removeEventListener.call(this,e,t,i),this.listenerCounts_[e]--},hasEventListener:function(e){return 0=s;)n=Math.floor((s+a)/2),r=t(e[n])-i,0>r?s=n+1:(r>0||(o=n),a=n-1);return-1!=o?o:s}function t(t,i,n,r,s,a){if(0!=t.length&&!(r>s)){var o=e(t,i,r);if(-1!=o&&(o>0&&i(t[o-1])+n(t[o-1],o-1)>=r&&a(t[o-1]),o!=t.length))for(n=t.length;n>o&&!(i(t[o])>=s);o++)a(t[o])}}return{findLowIndexInSortedArray:e,findLowIndexInSortedIntervals:function(t,i,n,r){var s=e(t,i,r);return 0==s?r>=i(t[0])&&r=i(t[s])&&r=i(t[s-1])&&r=i(t[s-1])&&rr;r++){var s=i(e[r],t[r]);if(s)return s}return e.length==t.length?0:void 0===e[r]?-1:1},comparePossiblyUndefinedValues:function(e,t,i){return void 0!==e&&void 0!==t?i(e,t):void 0!==e?-1:void 0!==t?1:0},dictionaryKeys:function(e){var t,i=[];for(t in e)i.push(t);return i},dictionaryValues:function(e){var t,i=[];for(t in e)i.push(e[t]);return i},iterItems:function(e,t,i){i=i||this;for(var n in e)t.call(i,n,e[n])},iterObjectFieldsRecursively:e}}),base.require("base.iteration_helpers"),base.exportTo("base",function(){return{addSingletonGetter:function(e){e.getInstance=function(){return e.instance_||(e.instance_=new e)}},tracedFunction:function(e,t,i){return function(){console.time(t);try{e.apply(i,arguments)}finally{console.timeEnd(t)}}},normalizeException:function(e){return"string"==typeof e?{message:e,stack:[""]}:{message:e.message,stack:e.stack?e.stack:[""]}},instantiateTemplate:function(e){return document.querySelector(e).content.cloneNode(!0)},stackTrace:function(){var e=Error().stack+"",e=e.split("\n");return e.slice(2)}}}),base.exportTo("tracing.trace_model",function(){function e(e,t,i){this.objectInstance=e,this.ts=t,this.args=i,this.selected=!1}return e.prototype={__proto__:Object.prototype,preInitialize:function(){},initialize:function(){}},e.nameToConstructorMap_={},e.register=function(t,i){if(e.nameToConstructorMap_[t])throw Error("Constructor already registerd for "+t);e.nameToConstructorMap_[t]=i},e.unregister=function(t){delete e.nameToConstructorMap_[t]},e.getConstructor=function(t){return e.nameToConstructorMap_[t]?e.nameToConstructorMap_[t]:e},{ObjectSnapshot:e}}),base.require("base.range"),base.require("base.sorted_array_utils"),base.require("tracing.trace_model.object_snapshot"),base.exportTo("tracing.trace_model",function(){function e(e,t,i,n,r){this.parent=e,this.id=t,this.category=i,this.name=n,this.creationTs=r,this.creationTsWasExplicit=!1,this.deletionTs=Number.MAX_VALUE,this.selected=this.deletionTsWasExplicit=!1,this.colorId=0,this.bounds=new base.Range,this.snapshots=[],this.hasImplicitSnapshots=!1}return e.prototype={__proto__:Object.prototype,get typeName(){return this.name},addSnapshot:function(e,t){if(e= instance.creationTs");if(e>=this.deletionTs)throw Error("Snapshots cannot be added after an objects deletion timestamp.");var i;if(0e))throw Error("Instance cannot be deleted at ts="+e+". A snapshot exists that is older.");this.deletionTs=e,this.deletionTsWasExplicit=!0},preInitialize:function(){for(var e=0;ethis.deletionTs)throw Error("ts must be within lifetime of this instance");var t=this.snapshots;return e=base.findLowIndexInSortedIntervals(t,function(e){return e.ts},function(e,i){return i==t.length-1?t[i].objectInstance.deletionTs:t[i+1].ts-t[i].ts},e),0>e?this.snapshots[0]:e>=this.snapshots.length?this.snapshots[this.snapshots.length-1]:this.snapshots[e]},updateBounds:function(){this.bounds.reset(),this.bounds.addValue(this.creationTs),this.deletionTs!=Number.MAX_VALUE?this.bounds.addValue(this.deletionTs):0r){if(r=this.instances[0],i>r.deletionTs||r.creationTsWasExplicit)throw Error("At the provided timestamp, no instance was still alive");if(0!=r.snapshots.length)throw Error("Cannot shift creationTs forward, snapshots have been added. First snap was at ts="+r.snapshots[0].ts+" and creationTs was "+r.creationTs);r.creationTs=i}else if(r>=this.instances.length)if(r=this.instances[this.instances.length-1],i>=r.deletionTs)r=this.createObjectInstanceFunction_(this.parent,this.id,e,t,i),this.instances.push(r);else{for(var s,r=this.instances.length-1;r>=0&&(e=this.instances[r],!(i>=e.deletionTs));r--)0==e.creationTsWasExplicit&&0==e.snapshots.length&&(s=r);if(void 0===s)throw Error("Cannot add snapshot. No instance was alive that was mutable.");r=this.instances[s],r.creationTs=i}else r=this.instances[r];return r.addSnapshot(i,n)},get lastInstance(){return 0==this.instances.length?void 0:this.instances[this.instances.length-1]},idWasDeleted:function(e,t,i){0==this.instances.length&&this.instances.push(this.createObjectInstanceFunction_(this.parent,this.id,e,t,i));var n=this.instances[this.instances.length-1];if(ie?this.instances[0].creationTsWasExplicit?void 0:this.instances[0]:e>=this.instances.length?void 0:this.instances[e]}},{TimeToObjectInstanceMap:e}}),base.require("base.utils"),base.require("base.range"),base.require("base.sorted_array_utils"),base.require("tracing.trace_model.object_instance"),base.require("tracing.trace_model.time_to_object_instance_map"),base.exportTo("tracing.trace_model",function(){function e(e){this.parent=e,this.bounds=new base.Range,this.instanceMapsById_={},this.instancesByTypeName_={},this.createObjectInstance_=this.createObjectInstance_.bind(this)}return e.prototype={__proto__:Object.prototype,createObjectInstance_:function(e,t,i,n,r){return e=new(tracing.trace_model.ObjectInstance.getConstructor(n))(e,t,i,n,r),t=e.typeName,i=this.instancesByTypeName_[t],i||(i=[],this.instancesByTypeName_[t]=i),i.push(e),e},getOrCreateInstanceMap_:function(e){var t=this.instanceMapsById_[e];return t?t:(t=new tracing.trace_model.TimeToObjectInstanceMap(this.createObjectInstance_,this.parent,e),this.instanceMapsById_[e]=t)},idWasCreated:function(e,t,i,n){return this.getOrCreateInstanceMap_(e).idWasCreated(t,i,n)},addSnapshot:function(e,t,i,n,r){if(e=this.getOrCreateInstanceMap_(e,t,i,n).addSnapshot(t,i,n,r),e.objectInstance.category!=t)throw Error("Added snapshot with different category than when it was created");if(e.objectInstance.name!=i)throw Error("Added snapshot with different name than when it was created");return e},idWasDeleted:function(e,t,i,n){if(e=this.getOrCreateInstanceMap_(e,t,i,n).idWasDeleted(t,i,n)){if(e.category!=t)throw Error("Deleting an object with a different category than when it was created");if(e.name!=i)throw Error("Deleting an object with a different name than when it was created")}},autoDeleteObjects:function(e){base.iterItems(this.instanceMapsById_,function(t,i){var n=i.lastInstance;n.deletionTs==Number.MAX_VALUE&&(i.idWasDeleted(n.category,n.name,e),n.deletionTsWasExplicit=!1)})},getObjectInstanceAt:function(e,t){var i=this.instanceMapsById_[e];return i?i.getInstanceAt(t):void 0},getSnapshotAt:function(e,t){var i=this.getObjectInstanceAt(e,t);return i?i.getSnapshotAt(t):void 0},iterObjectInstances:function(e,t){t=t||this,base.iterItems(this.instanceMapsById_,function(i,n){n.instances.forEach(e,t)})},getAllObjectInstances:function(){var e=[];return this.iterObjectInstances(function(t){e.push(t)}),e},getAllInstancesNamed:function(e){return this.instancesByTypeName_[e]},getAllInstancesByTypeName:function(){return this.instancesByTypeName_},preInitializeAllObjects:function(){this.iterObjectInstances(function(e){e.preInitialize()})},initializeAllObjects:function(){this.iterObjectInstances(function(e){e.initialize()})},initializeInstances:function(){this.iterObjectInstances(function(e){e.initialize()})},updateBounds:function(){this.bounds.reset(),this.iterObjectInstances(function(e){e.updateBounds(),this.bounds.addRange(e.bounds)},this)},shiftTimestampsForward:function(e){this.iterObjectInstances(function(t){t.shiftTimestampsForward(e)})},addCategoriesToDict:function(e){this.iterObjectInstances(function(t){e[t.category]=!0})},toJSON:function(){return{}}},{ObjectCollection:e}}),base.require("tracing.trace_model.slice"),base.exportTo("tracing.trace_model",function(){function e(){tracing.trace_model.Slice.apply(this,arguments)}return e.prototype={__proto__:tracing.trace_model.Slice.prototype,toJSON:function(){for(var e={},t=Object.keys(this),i=0;i=this.openPartialSlices_[this.openPartialSlices_.length-1].start:!0},get openSliceCount(){return this.openPartialSlices_.length},get mostRecentlyOpenedPartialSlice(){return this.openPartialSlices_.length?this.openPartialSlices_[this.openPartialSlices_.length-1]:void 0},endSlice:function(e){if(!this.openSliceCount)throw Error("endSlice called without an open slice");var t=this.openPartialSlices_[this.openSliceCount-1];if(this.openPartialSlices_.splice(this.openSliceCount-1,1),er)throw Error("slice should not be split");var s=n.copySlice(i);i.start=e,i.duration=r-e,i.title+=" (cont.)",s.duration=e-s.start,l[t]=s,n.pushSlice(s)}},d=function(e){for(;0t)&&(void 0===i||e>i))break;void 0===i||t>i?(h(t),c.pop()):l.pop()}};a>=0||o>=0;){var u=r[a],p=s[o];void 0===u||void 0!==p&&u.end0);this.updateBounds(),this.kernel.autoCloseOpenSlices(this.bounds.max);for(var a in this.processes)this.processes[a].autoCloseOpenSlices(this.bounds.max);for(r=0;r/.test(e))return r;var s=e.split("\n"),a=1;if(!i(/^ \n' % js_flattenizer + js += '\n'.join(linked_js_tag % (os.path.join(src_dir, f)) for f in js_files) + + else: + css_filename = os.path.join(script_dir, flattened_css_file) + js_filename = os.path.join(script_dir, flattened_js_file) + css = compiled_css_tag % (open(css_filename).read()) + js = compiled_js_tag % (open(js_filename).read()) + templates = '' + + html_filename = options.output_file + + if options.trace_bootup: + print "Trace for bootup" + atrace_args.extend(['--async_start']) + trace_bootup(string.join(atrace_args)) + + print "Please pull out the usb cable on target" + os.system('sleep ' + '40') + print "Please plug the usb cable to target" + os.system('sleep ' + '20') + + atrace_args.remove('--async_start') + atrace_args.remove('\'echo') + atrace_args.extend(['-z', '--async_stop']) + expect_trace = True + if options.from_text_file: + compose_html(script_dir, options, css, js, templates) + return + elif options.from_file_win: + compose_html_win(script_dir, options, css, js, templates) + return + elif options.from_file: + print "From file" + + if options.async_start: + atrace_args.extend(['--async_start']) + if options.async_dump: + atrace_args.extend(['--async_dump']) + if options.async_stop: + atrace_args.extend(['--async_stop']) + if options.append: + atrace_args.extend(['--append']) + if options.backup: + atrace_args.extend(['--backup']) + backup_trace = True + + sdb = subprocess.Popen(atrace_args, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + if options.async_start: + return + + result = None + data = [] + + # Read the text portion of the output and watch for the 'TRACE:' marker that + # indicates the start of the trace data. + while result is None: + ready = select.select([sdb.stdout, sdb.stderr], [], [sdb.stdout, sdb.stderr]) + if sdb.stderr in ready[0]: + err = os.read(sdb.stderr.fileno(), 4096) + sys.stderr.write(err) + sys.stderr.flush() + if sdb.stdout in ready[0]: + out = os.read(sdb.stdout.fileno(), 4096) + parts = out.split('\nTRACE:', 1) + + txt = parts[0].replace('\r', '') + if len(parts) == 2: + # The '\nTRACE:' match stole the last newline from the text, so add it + # back here. + txt += '\n' + sys.stdout.write(txt) + sys.stdout.flush() + + if len(parts) == 2: + data.append(parts[1]) + sys.stdout.write("downloading trace...") + sys.stdout.flush() + break + + result = sdb.poll() + + # Read and buffer the data portion of the output. + while True: + ready = select.select([sdb.stdout, sdb.stderr], [], [sdb.stdout, sdb.stderr]) + keepReading = False + if sdb.stderr in ready[0]: + err = os.read(sdb.stderr.fileno(), 4096) + if len(err) > 0: + keepReading = True + sys.stderr.write(err) + sys.stderr.flush() + if sdb.stdout in ready[0]: + out = os.read(sdb.stdout.fileno(), 4096) + if len(out) > 0: + keepReading = True + data.append(out) + + if result is not None and not keepReading: + break + + result = sdb.poll() + + if result == 0: + if expect_trace: + if not data: + print >> sys.stderr, ('No data was captured. Output file was not ' + + 'written.') + sys.exit(1) + else: + # Indicate to the user that the data download is complete. + print " done\n" + + data = ''.join(data) + + # Collapse CRLFs that are added by sdb shell. + if data.startswith('\r\n'): + data = data.replace('\r\n', '\n') + + # Skip the initial newline. + data = data[1:] + + html_prefix = read_asset(script_dir, 'prefix.html') + html_suffix = read_asset(script_dir, 'suffix.html') + + html_file = open(html_filename, 'w') + trace_filename = html_filename + '.trace.raw' + trace_file = open(trace_filename, 'w') + html_file.write(html_prefix % (css, js, templates)) + + size = 4096 + dec = zlib.decompressobj() + for chunk in (data[i:i + size] for i in xrange(0, len(data), size)): + decoded_chunk = dec.decompress(chunk) + html_chunk = decoded_chunk.replace('\n', '\\n\\\n') + html_file.write(html_chunk) + trace_file.write(html_chunk) + + html_out = dec.flush().replace('\n', '\\n\\\n') + html_file.write(html_out) + + # Write suffix + html_file.write(html_suffix) + html_file.close() + trace_file.close() + pid_parser.parse(trace_filename) + os.remove(trace_filename) + print "\nwrote file://%s\n" % os.path.abspath(options.output_file) + + else: # i.e. result != 0 + print >> sys.stderr, 'sdb returned error code %d' % result + sys.exit(1) + + +def read_asset(src_dir, filename): + return open(os.path.join(src_dir, filename)).read() + + +def get_assets(src_dir, build_dir): + sys.path.append(build_dir) + gen = __import__('generate_standalone_timeline_view', {}, {}) + parse_deps = __import__('parse_deps', {}, {}) + gen_templates = __import__('generate_template_contents', {}, {}) + filenames = gen._get_input_filenames() + load_sequence = parse_deps.calc_load_sequence(filenames, src_dir) + + js_files = [] + js_flattenizer = "window.FLATTENED = {};\n" + js_flattenizer += "window.FLATTENED_RAW_SCRIPTS = {};\n" + css_files = [] + + for module in load_sequence: + js_files.append(os.path.relpath(module.filename, src_dir)) + js_flattenizer += "window.FLATTENED['%s'] = true;\n" % module.name + for dependent_raw_script_name in module.dependent_raw_script_names: + js_flattenizer += ( + "window.FLATTENED_RAW_SCRIPTS['%s'] = true;\n" + % dependent_raw_script_name) + for style_sheet in module.style_sheets: + css_files.append(os.path.relpath(style_sheet.filename, src_dir)) + + templates = gen_templates.generate_templates() + + sys.path.pop() + + return (js_files, js_flattenizer, css_files, templates) + + +compiled_css_tag = """""" +compiled_js_tag = """""" + +linked_css_tag = """""" +linked_js_tag = """""" + + +if __name__ == '__main__': + main() diff --git a/tools/ttrace_parser/scripts/ttrace_tinyaraDump.py b/tools/ttrace_parser/scripts/ttrace_tinyaraDump.py new file mode 100755 index 0000000..cc9afc0 --- /dev/null +++ b/tools/ttrace_parser/scripts/ttrace_tinyaraDump.py @@ -0,0 +1,294 @@ +#!/usr/bin/python +########################################################################### +# +# Copyright (c) 2017 The Chromium Authors. All rights reserved. +# Copyright 2017 Samsung Electronics All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +########################################################################### + +from operator import itemgetter +from distutils import util +import os +import sys +import time +import glob +import select +import optparse +import subprocess + + +def get_os_cmd(cmdARGS): + fd_popen = subprocess.Popen(cmdARGS.split(), + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + ready = select.select([fd_popen.stdout, fd_popen.stderr], + [], [fd_popen.stdout, fd_popen.stderr]) + if fd_popen.stdout in ready[0]: + out = os.read(fd_popen.stdout.fileno(), 4096) + return out + else: + return False + + +class GdbManager: + def __init__(self): + self.targetName = None + self.openocdPath = None + self.gdbCommandsPath = None + self.binaryPath = None + self.addrBegin = None + self.addrEnd = None + self.addrDump = None + self.dumpFile = None + self.traceFile = None + return None + + def setTargetName(self, name): + self.targetName = name + + def setopenocdPath(self, path): + self.openocdPath = path + + def setBinaryPath(self, path): + self.binaryPath = path + + def setDumpFile(self, name): + self.dumpFile = name + + def setTraceFile(self, name): + self.traceFile = name + + def checkopenocdPath(self): + if self.openocdPath == None: + print "You should set openocd path" + return False + print "openocdPath: " + self.openocdPath + return True + + def checkBinaryPath(self): + if self.binaryPath == None: + print "You should set binary path that contains tinyara,\ + System.map files" + return False + print "binaryPath: " + self.binaryPath + return True + + def checkRamdump(self): + if os.access("ramdump", os.F_OK): + print "Ramdump generated" + return True + print "Failed to generate ramdump" + return False + + def connectTarget_artik053(self): + if self.checkopenocdPath() == False: + return False + print("%s -f %s &" + % (os.path.join(self.openocdPath, 'linux64/openocd'), + os.path.join(self.openocdPath, "artik053.cfg"))) + print os.system("%s -f %s &" + % (os.path.join(self.openocdPath, 'linux64/openocd'), + os.path.join(self.openocdPath, "artik053.cfg"))) + time.sleep(3) + print os.system("telnet localhost 4444 &") + time.sleep(3) + return True + + def connectTarget(self): + if (self.targetName == "artik053"): + return self.connectTarget_artik053() + else: + print "Could not found target name: " + self.targetName + return False + + def checkELF(self): + if os.access("%s/tinyara" % self.binaryPath, os.F_OK): + return True + print "ELF file(tinyara) doesn't exist" + return False + + def checkSystemMap(self): + if os.access("%s/System.map" % self.binaryPath, os.F_OK) == False: + print "Symbol table file(System.map) doesn't exist" + return False + return True + + def generateGdbCommands_artik051(self): + self.gdbCommandsPath = os.path.join(self.openocdPath, "gdbCommands") + gdbCmdFile = open(self.gdbCommandsPath, 'w') + gdbCmdFile.write("target remote:3333\n") + gdbCmdFile.write("set confirm off\n") + gdbCmdFile.write("file %s\n" + % (os.path.join(self.binaryPath, "tinyara"))) + gdbCmdFile.write("break wait_ttrace_dump\n") + gdbCmdFile.write("continue\n") + gdbCmdFile.write("delete 1\n") + gdbCmdFile.write("dump binary memory ramdump %s %s\n" + % (self.addrBegin, self.addrEnd)) + gdbCmdFile.write("quit\n") + gdbCmdFile.close() + return True + + def generateGdbCommands_artik053(self): + self.gdbCommandsPath = os.path.join(self.openocdPath, "gdbCommands") + gdbCmdFile = open(self.gdbCommandsPath, 'w') + gdbCmdFile.write("target remote:3333\n") + gdbCmdFile.write("monitor reset halt\n") + gdbCmdFile.write("monitor cortex_r4 maskisr on\n") + gdbCmdFile.write("set confirm off\n") + gdbCmdFile.write("file %s\n" + % (os.path.join(self.binaryPath, "tinyara"))) + gdbCmdFile.write("break wait_ttrace_dump\n") + gdbCmdFile.write("continue\n") + gdbCmdFile.write("delete 1\n") + gdbCmdFile.write("dump binary memory ramdump %s %s\n" + % (self.addrBegin, self.addrEnd)) + gdbCmdFile.write("quit\n") + gdbCmdFile.close() + return True + + def generateGdbCommands(self): + self.gdbCommandsPath = os.path.join(self.openocdPath, "gdbCommands") + if (self.targetName == "artik051"): + return self.generateGdbCommands_artik051() + elif (self.targetName == "artik053"): + return self.generateGdbCommands_artik053() + else: + print "Could not found target name: " + self.targetName + return False + + def runGdbCommands(self): + out = os.system("arm-none-eabi-gdb %s --command=%s\n" \ + % (os.path.join(self.openocdPath, "binary/tinyara"), \ + self.gdbCommandsPath)) + print "-----------------------------------------\n" + if self.checkRamdump() == False: + return False + os.system("mv ramdump %s" % (self.dumpFile)) + return out + + def setAddrBegin(self): + self.addrBegin = self.findAddr( + os.path.join(self.binaryPath, "System.map"), "packets") + if self.addrBegin == False: + return False + self.addrBegin = "0x" + self.addrBegin + print "addrBegin: " + self.addrBegin + return True + + def setAddrEnd(self): + self.addrEnd = self.findEndAddr( + os.path.join(self.binaryPath, "System.map"), "packets") + if self.addrEnd == False: + return False + self.addrEnd = "0x" + self.addrEnd + print "addrEnd: " + self.addrEnd + return True + + def setAddrDump(self): + self.addrDump = self.findAddr( + os.path.join(self.binaryPath, "System.map"), + "wait_ttrace_dump") + if self.addrDump == False: + return False + self.addrDump = "0x" + self.addrDump + print "addrDump: " + self.addrDump + return True + + def findAddr(self, filename, target): + with open(filename, "r") as sysmap: + for line in sysmap: + if line.isspace(): + continue + if target in line: + return line.strip().split()[0] + return False + + def findEndAddr(self, filename, target): + flag = False + with open(filename, "r") as sysmap: + for line in sysmap: + if line.isspace(): + continue + if flag == True: + return line.strip().split()[0] + if target in line: + flag = True + return False + + def extractDump(self, options): + out = subprocess.check_output(["./scripts/parse_dump", self.dumpFile]) + if options.verbose == True: + print out + with open(self.traceFile, "w") as dump: + dump.write(out) + return True + + +def main(): + usage = "Usage: %prog -t [targetname] -o [filename]" + desc = "Example: %prog -t artik053 -o dump.trace" + parser = optparse.OptionParser(usage=usage, description=desc) + parser.add_option('-t', '--target', dest='targetName', + default='artik053', + metavar='TARGETNAME', + help="Specify target device name, " + "[default:%default]") + parser.add_option('-o', '--output', dest='dumpFile', + default='dump', + metavar='FILENAME', + help="Specify dumpped file name, " + "[default:%default]") + parser.add_option('-b', '--binary', dest='binaryPath', + default='../../build/output/bin', + metavar='PATH', + help="Specify tinyara binary path, " + "[default:%default]") + parser.add_option('-d', '--openocd', dest='openocdPath', + default='../../build/configs/artik053/tools/openocd', + metavar='PATH', + help="Specify openocd path, " + "[default:%default]") + parser.add_option('-v', '--verbose', dest='verbose', + action='store_true', + default=False, + help="Generate verbose output, " + "[default:%default]") + options, arg = parser.parse_args() + options.curDir = os.path.dirname(os.path.abspath(sys.argv[0])) + + gdbman = GdbManager() + gdbman.setTargetName(options.targetName) + gdbman.setBinaryPath(options.binaryPath) + gdbman.setopenocdPath(options.openocdPath) + gdbman.setDumpFile(options.dumpFile) + + traceFile = os.path.splitext(options.dumpFile)[0] + '.trace' + gdbman.setTraceFile(traceFile) + + gdbman.checkELF() + gdbman.checkSystemMap() + + gdbman.setAddrBegin() + gdbman.setAddrEnd() + gdbman.setAddrDump() + + gdbman.generateGdbCommands() + gdbman.connectTarget() + time.sleep(3) + gdbman.runGdbCommands() + gdbman.extractDump(options) + +if __name__ == '__main__': + main() diff --git a/tools/ttrace_parser/ttrace_tinyara.py b/tools/ttrace_parser/ttrace_tinyara.py new file mode 100755 index 0000000..34f012b --- /dev/null +++ b/tools/ttrace_parser/ttrace_tinyara.py @@ -0,0 +1,236 @@ +#!/usr/bin/python +########################################################################### +# +# Copyright (c) 2017 The Chromium Authors. All rights reserved. +# Copyright 2017 Samsung Electronics All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +########################################################################### + +from operator import itemgetter +import os +import sys +import time +import glob +import optparse + +cycleIdDict = dict() +workIdDict = dict() +beginDict = dict() +endDict = dict() +cycleGap = 0 +temporalId = 1000 +parserDirPath = "scripts" + +ftraceLogs = [] + + +class TraceItem: + def __init__(self): + self.taskname = "null" + self.pid = "0" + self.tgid = "0" + self.core = "[000]" + self.flags = "...1" + self.timestamp = "0" + self.function_type = "null" + self.pair_type = "B" + self.message = "0" + + def extractTime(self, line): + self.timestamp = line.strip('[]').replace(':', '.') + return self.timestamp + + def extractPid(self, line): + self.pid = line.strip(':') + return self.pid + + def extractPairType(self, line): + self.pair_type = line.split('|')[0].upper() + return self.pair_type + + def extractMsg(self, line): + self.message = (line.split('|'))[1] + return self.message + + def composeSchedLine(self): + self.function_type = "sched_switch" + line = "%s-%s %s %s %s: %s: %s" % ( + self.taskname, self.pid, self.core, self.flags, self.timestamp, + self.function_type, self.message) + return line + + def composeNormalLine(self): + self.function_type = "tracing_mark_write" + line = "%s-%s %s %s %s: %s: %s|%s|%s" % (self.taskname, self.pid, + self.core, self.flags, self.timestamp, + self.function_type, self.pair_type, self.pid, self.message) + return line + + def composeLine(self): + if self.pair_type == 'S': + line = self.composeSchedLine() + else: + line = self.composeNormalLine() + return line + + def addLineToFtraceLogs(self, line): + ftraceLogs.append(line) + return + + +def writeFtraceLogs(options): + with open(options.outputFile, "wb") as output: + for line in ftraceLogs: + if (options.verbose == True): + print line + output.write(line + "\n") + return True + + +def translateTinyaraLogs(options): + item = TraceItem() + filename = os.path.join(options.inputFile) + with open(filename, "r") as rawLogs: + for line in rawLogs: + if (line.isspace()): + continue + lineList = line.strip().split(None, 2) + time = item.extractTime(lineList[0]) + pid = item.extractPid(lineList[1]) + pair_type = item.extractPairType(lineList[2]) + msg = item.extractMsg(lineList[2]) + translatedLine = item.composeLine() + if (options.verbose == True): + print translatedLine + item.addLineToFtraceLogs(translatedLine) + return True + + +def get_os_cmd(cmdARGS): + fd_popen = subprocess.Popen(cmdARGS.split(), + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + ready = select.select([fd_popen.stdout, fd_popen.stderr], + [], [fd_popen.stdout, fd_popen.stderr]) + if fd_popen.stdout in ready[0]: + out = os.read(fd_popen.stdout.fileno(), 4096) + return out + else: + return False + + +def makeHtml(options): + htmlfile = options.outputFile.replace(options.outputExt, '.html') + if os.name == 'nt': + os.system("%s/ttrace.py --from-text-file=%s -o %s\n" + % (parserDirPath, options.outputFile, htmlfile)) + else: + os.system("./%s/ttrace.py --from-text-file=%s -o %s\n" + % (parserDirPath, options.outputFile, htmlfile)) + return True + + +def findAddr(filename, target): + with open(filename, "r") as sysmap: + for line in sysmap: + if line.isspace(): + continue + if target in line: + return line.strip().split()[0] + return False + + +def main(): + usage = "Usage: %prog [options]" + desc = "Example: %prog -i logs.txt -o ttrace_dump" + parser = optparse.OptionParser(usage=usage, description=desc) + parser.add_option('-i', '--input', dest='inputFile', + default=None, + metavar='FILENAME', + help="Parsed text file only, Not support dumpped file, " + "[default:%default]") + parser.add_option('-d', '--dump', dest='dump', + default=None, + metavar='MODELNAME', + help="Dump trace buffer and generate html report, " + "[default:%default]") + parser.add_option('-o', '--output', dest='outputFile', + default=None, + metavar='FILENAME', + help="Output file that html report saved, " + "[default:%default]") + parser.add_option('-v', '--verbose', dest='verbose', + action="store_true", + default=False, + help="Generate verbose output, " + "[default:%default]") + + options, arg = parser.parse_args() + options.curDir = os.path.dirname(os.path.abspath(sys.argv[0])) + + if (options.inputFile == None and options.dump == None): + print "Please specify reading from file or dump" + exit() + + if (options.inputFile != None and options.dump != None): + print "Please choose just one option for reading logs" + exit() + + if (options.dump != None): + if (options.dump != "artik051" and options.dump != "artik053"): + print "%s is not supported" % (options.dump) + print "T-trace dump supports artik051, artik053" + exit() + os.system("./%s/ttrace_tinyaraDump.py -t %s -o %s\n" \ + % (parserDirPath, options.dump, "dump.bin")) + options.inputFile = "%s/dump.trace" % (options.curDir) + + if (options.inputFile != None): + # Check inputFile existance, + if not os.access(options.inputFile, os.F_OK | os.R_OK): + print "ERROR: " + "Can not read " + options.inputFile + return + print "Input file: " + options.inputFile + + options.inputFolder = os.path.split(options.inputFile)[0] + options.inputFilenameExt = os.path.split(options.inputFile)[1] + options.inputFileName = \ + os.path.splitext(options.inputFilenameExt)[0] + + if (options.outputFile != None): + options.outputFolder = os.path.split(options.outputFile)[0] + options.outputFileName = os.path.split(options.outputFile)[1] + if not os.access(options.outputFolder, os.F_OK | os.W_OK): + os.mkdir(options.outputFolder) + else: + if (options.inputFile != None): + options.outputFolder = options.inputFolder + options.outputFileName = options.inputFileName + else: + options.outputFolder = options.curDir + options.outputFileName = "report" + options.outputExt = ".ftrace" + options.outputFilenameExt = options.outputFileName + options.outputExt + options.outputFile = \ + os.path.join(options.outputFolder, options.outputFilenameExt) + + print "output file will be saved at %s" % (options.outputFile) + + translateTinyaraLogs(options) + writeFtraceLogs(options) + makeHtml(options) + + +if __name__ == '__main__': + main()