Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / importer / linux_perf / parser.html
1 <!DOCTYPE html>
2 <!--
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.
6 -->
7 <link rel="import" href="/base.html">
8 <script>
9 'use strict';
10
11 /**
12  * @fileoverview Base class for linux perf event parsers.
13  *
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,
21  *
22  * var Parser = tracing.importer.linux_perf.Parser;
23  *
24  * function WorkqueueParser(importer) {
25  *   Parser.call(this, importer);
26  *
27  *   importer.registerEventHandler('workqueue_execute_start',
28  *       WorkqueueParser.prototype.executeStartEvent.bind(this));
29  *   importer.registerEventHandler('workqueue_execute_end',
30  *       WorkqueueParser.prototype.executeEndEvent.bind(this));
31  * }
32  *
33  * Parser.registerSubtype(WorkqueueParser);
34  *
35  * When a registered event name is found in the data stream the associated
36  * event handler is invoked:
37  *
38  *   executeStartEvent: function(eventName, cpuNumber, ts, eventBase)
39  *
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
44  * true.
45  *
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:
49  *
50  *  tracing_mark_write: trace_event_clock_sync: parent_ts=0
51  *
52  * To register an event handler for these events, prepend the marker with
53  * 'tracing_mark_write:'; e.g.
54  *
55  *    this.registerEventHandler('tracing_mark_write:trace_event_clock_sync',
56  *
57  * All subclasses should depend on importer.linux_perf.parser, e.g.
58  *
59  * tv.defineModule('importer.linux_perf.workqueue_parser')
60  *   .dependsOn('importer.linux_perf.parser')
61  *   .exportsTo('tracing', function()
62  *
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.*.
66  */
67 tv.exportTo('tracing.importer.linux_perf', function() {
68   var subtypeConstructors = [];
69
70   /**
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.
74    *
75    * @param {Function} subtypeConstructor The subtype's constructor function.
76    */
77   Parser.registerSubtype = function(subtypeConstructor) {
78     subtypeConstructors.push(subtypeConstructor);
79   };
80
81   Parser.getSubtypeConstructors = function() {
82     return subtypeConstructors;
83   };
84
85   /**
86    * Parses linux perf events.
87    * @constructor
88    */
89   function Parser(importer) {
90     this.importer = importer;
91     this.model = importer.model;
92   }
93
94   Parser.prototype = {
95     __proto__: Object.prototype
96   };
97
98   return {
99     Parser: Parser
100   };
101 });
102 </script>