3 Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
7 <link rel="import" href="/base.html">
12 * @fileoverview Base class for linux perf event parsers.
14 * The linux perf trace event importer depends on subclasses of
15 * Parser to parse event data. Each subclass corresponds
16 * to a group of trace events; e.g. SchedParser implements
17 * parsing of sched:* kernel trace events. Parser subclasses must
18 * call Parser.registerSubtype to arrange to be instantiated
19 * and their constructor must register their event handlers with the
20 * importer. For example,
22 * var Parser = tracing.importer.linux_perf.Parser;
24 * function WorkqueueParser(importer) {
25 * Parser.call(this, importer);
27 * importer.registerEventHandler('workqueue_execute_start',
28 * WorkqueueParser.prototype.executeStartEvent.bind(this));
29 * importer.registerEventHandler('workqueue_execute_end',
30 * WorkqueueParser.prototype.executeEndEvent.bind(this));
33 * Parser.registerSubtype(WorkqueueParser);
35 * When a registered event name is found in the data stream the associated
36 * event handler is invoked:
38 * executeStartEvent: function(eventName, cpuNumber, ts, eventBase)
40 * If the routine returns false the caller will generate an import error
41 * saying there was a problem parsing it. Handlers can also emit import
42 * messages using this.importer.model.importWarning. If this is done in lieu of
43 * the generic import error it may be desirable for the handler to return
46 * Trace events generated by writing to the trace_marker file are expected
47 * to have a leading text marker followed by a ':'; e.g. the trace clock
48 * synchronization event is:
50 * tracing_mark_write: trace_event_clock_sync: parent_ts=0
52 * To register an event handler for these events, prepend the marker with
53 * 'tracing_mark_write:'; e.g.
55 * this.registerEventHandler('tracing_mark_write:trace_event_clock_sync',
57 * All subclasses should depend on importer.linux_perf.parser, e.g.
59 * tv.defineModule('importer.linux_perf.workqueue_parser')
60 * .dependsOn('importer.linux_perf.parser')
61 * .exportsTo('tracing', function()
63 * and be listed in the dependsOn of LinuxPerfImporter. Beware that after
64 * adding a new subclass you must run build/generate_about_tracing_contents.py
65 * to regenerate about_tracing.*.
67 tv.exportTo('tracing.importer.linux_perf', function() {
68 var subtypeConstructors = [];
71 * Registers a subclass that will help parse linux perf events.
72 * The importer will call createParsers (below) before importing
73 * data so each subclass can register its handlers.
75 * @param {Function} subtypeConstructor The subtype's constructor function.
77 Parser.registerSubtype = function(subtypeConstructor) {
78 subtypeConstructors.push(subtypeConstructor);
81 Parser.getSubtypeConstructors = function() {
82 return subtypeConstructors;
86 * Parses linux perf events.
89 function Parser(importer) {
90 this.importer = importer;
91 this.model = importer.model;
95 __proto__: Object.prototype