1<!DOCTYPE html> 2<!-- 3Copyright (c) 2012 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7<link rel="import" href="/tracing/base/base.html"> 8<link rel="import" href="/tracing/base/extension_registry.html"> 9<script> 10'use strict'; 11 12/** 13 * @fileoverview Base class for linux perf event parsers. 14 * 15 * The linux perf trace event importer depends on subclasses of 16 * Parser to parse event data. Each subclass corresponds 17 * to a group of trace events; e.g. SchedParser implements 18 * parsing of sched:* kernel trace events. Parser subclasses must 19 * call Parser.register to arrange to be instantiated 20 * and their constructor must register their event handlers with the 21 * importer. For example, 22 * 23 * var Parser = tr.e.importer.linux_perf.Parser; 24 * 25 * function WorkqueueParser(importer) { 26 * Parser.call(this, importer); 27 * 28 * importer.registerEventHandler('workqueue_execute_start', 29 * WorkqueueParser.prototype.executeStartEvent.bind(this)); 30 * importer.registerEventHandler('workqueue_execute_end', 31 * WorkqueueParser.prototype.executeEndEvent.bind(this)); 32 * } 33 * 34 * Parser.register(WorkqueueParser); 35 * 36 * When a registered event name is found in the data stream the associated 37 * event handler is invoked: 38 * 39 * executeStartEvent: function(eventName, cpuNumber, ts, eventBase) 40 * 41 * If the routine returns false the caller will generate an import error 42 * saying there was a problem parsing it. Handlers can also emit import 43 * messages using this.importer.model.importWarning. If this is done in lieu of 44 * the generic import error it may be desirable for the handler to return 45 * true. 46 * 47 * Trace events generated by writing to the trace_marker file are expected 48 * to have a leading text marker followed by a ':'; e.g. the trace clock 49 * synchronization event is: 50 * 51 * tracing_mark_write: trace_event_clock_sync: parent_ts=0 52 * 53 * To register an event handler for these events, prepend the marker with 54 * 'tracing_mark_write:'; e.g. 55 * 56 * this.registerEventHandler('tracing_mark_write:trace_event_clock_sync', 57 * 58 * All subclasses should depend on importer.linux_perf.parser, e.g. 59 * 60 * tr.defineModule('importer.linux_perf.workqueue_parser') 61 * .dependsOn('importer.linux_perf.parser') 62 * .exportsTo('tracing', function() 63 * 64 * and be listed in the dependsOn of LinuxPerfImporter. Beware that after 65 * adding a new subclass you must run build/generate_about_tracing_contents.py 66 * to regenerate tr.ui.e.about_tracing.*. 67 */ 68tr.exportTo('tr.e.importer.linux_perf', function() { 69 /** 70 * Parses linux perf events. 71 * @constructor 72 */ 73 function Parser(importer) { 74 this.importer = importer; 75 this.model = importer.model; 76 } 77 78 Parser.prototype = { 79 __proto__: Object.prototype 80 }; 81 82 var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); 83 options.mandatoryBaseClass = Parser; 84 tr.b.decorateExtensionRegistry(Parser, options); 85 86 return { 87 Parser: Parser 88 }; 89}); 90</script> 91