src/share/vm/trace/traceEventClasses.xsl

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
equal deleted inserted replaced
-1:000000000000 0:f90c822e73f8
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License version 2 only, as
8 published by the Free Software Foundation.
9
10 This code is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 version 2 for more details (a copy is included in the LICENSE file that
14 accompanied this code).
15
16 You should have received a copy of the GNU General Public License version
17 2 along with this work; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 or visit www.oracle.com if you need additional information or have any
22 questions.
23 -->
24
25 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
26 <xsl:import href="xsl_util.xsl"/>
27 <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
28
29 <xsl:template match="/">
30 <xsl:call-template name="file-header"/>
31
32 #ifndef TRACEFILES_TRACEEVENTCLASSES_HPP
33 #define TRACEFILES_TRACEEVENTCLASSES_HPP
34
35 // On purpose outside the INCLUDE_TRACE
36 // Some parts of traceEvent.hpp are used outside of
37 // INCLUDE_TRACE
38
39 #include "memory/resourceArea.hpp"
40 #include "tracefiles/traceTypes.hpp"
41 #include "trace/traceEvent.hpp"
42 #include "utilities/macros.hpp"
43 #include "utilities/ticks.hpp"
44
45 #if INCLUDE_TRACE
46
47
48 #include "trace/traceStream.hpp"
49 #include "utilities/ostream.hpp"
50
51 <xsl:apply-templates select="trace/events/struct" mode="trace"/>
52 <xsl:apply-templates select="trace/events/event" mode="trace"/>
53
54 #else
55
56 class TraceEvent {
57 public:
58 TraceEvent() {}
59 void set_starttime(const Ticks&amp; time) {}
60 void set_endtime(const Ticks&amp; time) {}
61 bool should_commit() const { return false; }
62 void commit() const {}
63 };
64
65 <xsl:apply-templates select="trace/events/struct" mode="empty"/>
66 <xsl:apply-templates select="trace/events/event" mode="empty"/>
67
68 #endif
69
70 #endif
71 </xsl:template>
72
73 <xsl:template match="struct" mode="trace">
74 struct TraceStruct<xsl:value-of select="@id"/>
75 {
76 private:
77 <xsl:apply-templates select="value" mode="write-fields"/>
78 public:
79 <xsl:apply-templates select="value" mode="write-setters"/>
80
81 void writeStruct(TraceStream&amp; ts) {
82 <xsl:apply-templates select="value" mode="write-data"/>
83 }
84 };
85
86 </xsl:template>
87
88 <xsl:template match="struct" mode="empty">
89 struct TraceStruct<xsl:value-of select="@id"/>
90 {
91 public:
92 <xsl:apply-templates select="value" mode="write-empty-setters"/>
93 };
94 </xsl:template>
95
96
97 <xsl:template match="event" mode="empty">
98 <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent')"/>
99 {
100 public:
101 <xsl:value-of select="concat(' Event', @id, '(bool ignore=true) {}')"/>
102 <xsl:text>
103 </xsl:text>
104
105 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-empty-setters"/>
106 };
107
108 </xsl:template>
109
110
111 <xsl:template match="event" mode="trace">
112 <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent&lt;Event', @id, '&gt;')"/>
113 {
114 public:
115 static const bool hasThread = <xsl:value-of select="@has_thread"/>;
116 static const bool hasStackTrace = <xsl:value-of select="@has_stacktrace"/>;
117 static const bool isInstant = <xsl:value-of select="@is_instant"/>;
118 static const bool isRequestable = <xsl:value-of select="@is_requestable"/>;
119 static const TraceEventId eventId = <xsl:value-of select="concat('Trace', @id, 'Event')"/>;
120
121 private:
122 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/>
123
124 void writeEventContent(void) {
125 TraceStream ts(*tty);
126 ts.print("<xsl:value-of select="@label"/>: [");
127 <xsl:apply-templates select="value|structvalue" mode="write-data"/>
128 ts.print("]\n");
129 }
130
131 public:
132 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/>
133
134 bool should_write(void) {
135 return true;
136 }
137 <xsl:text>
138
139 </xsl:text>
140 <xsl:value-of select="concat(' Event', @id, '(EventStartTime timing=TIMED) : TraceEvent&lt;Event', @id, '&gt;(timing) {}', $newline)"/>
141 void writeEvent(void) {
142 ResourceMark rm;
143 if (UseLockedTracing) {
144 ttyLocker lock;
145 writeEventContent();
146 } else {
147 writeEventContent();
148 }
149 }
150 };
151
152 </xsl:template>
153
154 <xsl:template match="value|transition_value|relation" mode="write-empty-setters">
155 <xsl:param name="cls"/>
156 <xsl:variable name="type" select="@type"/>
157 <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
158 <xsl:value-of select="concat(' void set_', @field, '(', $wt, ' value) { }')"/>
159 <xsl:if test="position() != last()">
160 <xsl:text>
161 </xsl:text>
162 </xsl:if>
163 </xsl:template>
164
165 <xsl:template match="structvalue" mode="write-empty-setters">
166 <xsl:param name="cls"/>
167 <xsl:value-of select="concat(' void set_', @field, '(const TraceStruct', @type, '&amp; value) { }')"/>
168 <xsl:if test="position() != last()">
169 <xsl:text>
170 </xsl:text>
171 </xsl:if>
172 </xsl:template>
173
174 <xsl:template match="value[@type='TICKS']" mode="write-setters">
175 #if INCLUDE_TRACE
176 <xsl:value-of select="concat(' void set_', @field, '(const Ticks&amp; time) { _', @field, ' = time; }')"/>
177 #else
178 <xsl:value-of select="concat(' void set_', @field, '(const Ticks&amp; ignore) {}')"/>
179 #endif
180 </xsl:template>
181
182 <xsl:template match="value[@type='TICKSPAN']" mode="write-setters">
183 #if INCLUDE_TRACE
184 <xsl:value-of select="concat(' void set_', @field, '(const Tickspan&amp; time) { _', @field, ' = time; }')"/>
185 #else
186 <xsl:value-of select="concat(' void set_', @field, '(const Tickspan&amp; ignore) {}')"/>
187 #endif
188 </xsl:template>
189
190
191 <xsl:template match="value" mode="write-fields">
192 <xsl:variable name="type" select="@type"/>
193 <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
194 <xsl:value-of select="concat(' ', $wt, ' _', @field, ';')"/>
195 <xsl:if test="position() != last()">
196 <xsl:text>
197 </xsl:text>
198 </xsl:if>
199 </xsl:template>
200
201 <xsl:template match="structvalue" mode="write-fields">
202 <xsl:value-of select="concat(' TraceStruct', @type, ' _', @field, ';')"/>
203 <xsl:text>
204 </xsl:text>
205 </xsl:template>
206
207 <xsl:template match="value|transition_value|relation" mode="write-setters">
208 <xsl:param name="cls"/>
209 <xsl:variable name="type" select="@type"/>
210 <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
211 <xsl:value-of select="concat(' void set_', @field, '(', $wt, ' value) { this->_', @field, ' = value; }')"/>
212 <xsl:if test="position() != last()">
213 <xsl:text>
214 </xsl:text>
215 </xsl:if>
216 </xsl:template>
217
218 <xsl:template match="structvalue" mode="write-setters">
219 <xsl:param name="cls"/>
220 <xsl:value-of select="concat(' void set_', @field, '(const TraceStruct', @type, '&amp; value) { this->_', @field, ' = value; }')"/>
221 <xsl:if test="position() != last()">
222 <xsl:text>
223 </xsl:text>
224 </xsl:if>
225 </xsl:template>
226
227 <xsl:template match="value" mode="write-data">
228 <xsl:variable name="type" select="@type"/>
229 <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@writetype"/>
230 <xsl:choose>
231 <xsl:when test="@type='TICKSPAN'">
232 <xsl:value-of select="concat(' ts.print_val(&quot;', @label, '&quot;, _', @field, '.value());')"/>
233 </xsl:when>
234 <xsl:when test="@type='TICKS'">
235 <xsl:value-of select="concat(' ts.print_val(&quot;', @label, '&quot;, _', @field, '.value());')"/>
236 </xsl:when>
237 <xsl:otherwise>
238 <xsl:value-of select="concat(' ts.print_val(&quot;', @label, '&quot;, _', @field, ');')"/>
239 </xsl:otherwise>
240 </xsl:choose>
241 <xsl:if test="position() != last()">
242 <xsl:text>
243 ts.print(", ");
244 </xsl:text>
245 </xsl:if>
246 </xsl:template>
247
248 <xsl:template match="structvalue" mode="write-data">
249 <xsl:value-of select="concat(' _', @field, '.writeStruct(ts);')"/>
250 <xsl:if test="position() != last()">
251 <xsl:text>
252 ts.print(", ");
253 </xsl:text>
254 </xsl:if>
255 </xsl:template>
256
257 </xsl:stylesheet>

mercurial