18025
|
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:output method="text" indent="no" omit-xml-declaration="yes"/>
|
|
27 |
<xsl:import href="xsl_util.xsl"/>
|
|
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 |
|
|
44 |
#if INCLUDE_TRACE
|
|
45 |
|
|
46 |
|
|
47 |
#include "trace/traceStream.hpp"
|
|
48 |
#include "utilities/ostream.hpp"
|
|
49 |
|
|
50 |
<xsl:apply-templates select="trace/events/struct" mode="trace"/>
|
|
51 |
<xsl:apply-templates select="trace/events/event" mode="trace"/>
|
|
52 |
|
|
53 |
#else
|
|
54 |
|
|
55 |
class TraceEvent {
|
|
56 |
public:
|
|
57 |
TraceEvent() {}
|
|
58 |
void set_starttime(jlong time) const {}
|
|
59 |
void set_endtime(jlong time) const {}
|
|
60 |
bool should_commit() const { return false; }
|
|
61 |
void commit() const {}
|
|
62 |
};
|
|
63 |
|
|
64 |
<xsl:apply-templates select="trace/events/struct" mode="empty"/>
|
|
65 |
<xsl:apply-templates select="trace/events/event" mode="empty"/>
|
|
66 |
|
|
67 |
#endif
|
|
68 |
|
|
69 |
#endif
|
|
70 |
</xsl:template>
|
|
71 |
|
|
72 |
<xsl:template match="struct" mode="trace">
|
|
73 |
struct TraceStruct<xsl:value-of select="@id"/>
|
|
74 |
{
|
|
75 |
private:
|
|
76 |
<xsl:apply-templates select="value" mode="write-fields"/>
|
|
77 |
public:
|
|
78 |
<xsl:apply-templates select="value" mode="write-setters"/>
|
|
79 |
|
|
80 |
void writeStruct(TraceStream& ts) {
|
|
81 |
<xsl:apply-templates select="value" mode="write-data"/>
|
|
82 |
}
|
|
83 |
};
|
|
84 |
|
|
85 |
</xsl:template>
|
|
86 |
|
|
87 |
<xsl:template match="struct" mode="empty">
|
|
88 |
struct TraceStruct<xsl:value-of select="@id"/>
|
|
89 |
{
|
|
90 |
public:
|
|
91 |
<xsl:apply-templates select="value" mode="write-empty-setters"/>
|
|
92 |
};
|
|
93 |
</xsl:template>
|
|
94 |
|
|
95 |
|
|
96 |
<xsl:template match="event" mode="empty">
|
|
97 |
<xsl:value-of select="concat('class Event', @id, ' : public TraceEvent')"/>
|
|
98 |
{
|
|
99 |
public:
|
|
100 |
<xsl:value-of select="concat(' Event', @id, '(bool ignore=true) {}')"/>
|
|
101 |
<xsl:text>
|
|
102 |
</xsl:text>
|
|
103 |
|
|
104 |
<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-empty-setters"/>
|
|
105 |
};
|
|
106 |
|
|
107 |
</xsl:template>
|
|
108 |
|
|
109 |
|
|
110 |
<xsl:template match="event" mode="trace">
|
|
111 |
<xsl:value-of select="concat('class Event', @id, ' : public TraceEvent<Event', @id, '>')"/>
|
|
112 |
{
|
|
113 |
public:
|
|
114 |
static const bool hasThread = <xsl:value-of select="@has_thread"/>;
|
|
115 |
static const bool hasStackTrace = <xsl:value-of select="@has_stacktrace"/>;
|
|
116 |
static const bool isInstant = <xsl:value-of select="@is_instant"/>;
|
|
117 |
static const bool isRequestable = <xsl:value-of select="@is_requestable"/>;
|
|
118 |
static const TraceEventId eventId = <xsl:value-of select="concat('Trace', @id, 'Event')"/>;
|
|
119 |
|
|
120 |
private:
|
|
121 |
<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/>
|
|
122 |
|
|
123 |
void writeEventContent(void) {
|
|
124 |
TraceStream ts(*tty);
|
|
125 |
ts.print("<xsl:value-of select="@label"/>: [");
|
|
126 |
<xsl:apply-templates select="value|structvalue" mode="write-data"/>
|
|
127 |
ts.print("]\n");
|
|
128 |
}
|
|
129 |
|
|
130 |
public:
|
|
131 |
<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/>
|
|
132 |
|
|
133 |
bool should_write(void) {
|
|
134 |
return true;
|
|
135 |
}
|
|
136 |
<xsl:text>
|
|
137 |
|
|
138 |
</xsl:text>
|
|
139 |
<xsl:value-of select="concat(' Event', @id, '(EventStartTime timing=TIMED) : TraceEvent<Event', @id, '>(timing) {}', $newline)"/>
|
|
140 |
void writeEvent(void) {
|
|
141 |
ResourceMark rm;
|
|
142 |
if (UseLockedTracing) {
|
|
143 |
ttyLocker lock;
|
|
144 |
writeEventContent();
|
|
145 |
} else {
|
|
146 |
writeEventContent();
|
|
147 |
}
|
|
148 |
}
|
|
149 |
};
|
|
150 |
|
|
151 |
</xsl:template>
|
|
152 |
|
|
153 |
<xsl:template match="value|transition_value|relation" mode="write-empty-setters">
|
|
154 |
<xsl:param name="cls"/>
|
|
155 |
<xsl:variable name="type" select="@type"/>
|
|
156 |
<xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
|
|
157 |
<xsl:value-of select="concat(' void set_', @field, '(', $wt, ' value) { }')"/>
|
|
158 |
<xsl:if test="position() != last()">
|
|
159 |
<xsl:text>
|
|
160 |
</xsl:text>
|
|
161 |
</xsl:if>
|
|
162 |
</xsl:template>
|
|
163 |
|
|
164 |
<xsl:template match="structvalue" mode="write-empty-setters">
|
|
165 |
<xsl:param name="cls"/>
|
|
166 |
<xsl:value-of select="concat(' void set_', @field, '(const TraceStruct', @type, '& value) { }')"/>
|
|
167 |
<xsl:if test="position() != last()">
|
|
168 |
<xsl:text>
|
|
169 |
</xsl:text>
|
|
170 |
</xsl:if>
|
|
171 |
</xsl:template>
|
|
172 |
|
|
173 |
|
|
174 |
<xsl:template match="value[@type='TICKS']" mode="write-setters">
|
|
175 |
#if INCLUDE_TRACE
|
|
176 |
<xsl:value-of select="concat('void set_', @field, '(jlong time) { _', @field, ' = time; }')"/>
|
|
177 |
#else
|
|
178 |
<xsl:value-of select="concat('void set_', @field, '(jlong ignore) {}')"/>
|
|
179 |
#endif
|
|
180 |
</xsl:template>
|
|
181 |
|
|
182 |
<xsl:template match="value[@type='RELATIVE_TICKS']" mode="write-setters">
|
|
183 |
#if INCLUDE_TRACE
|
|
184 |
<xsl:value-of select="concat('void set_', @field, '(jlong time) { _', @field, ' = time; }')"/>
|
|
185 |
#else
|
|
186 |
<xsl:value-of select="concat('void set_', @field, '(jlong ignore) {}')"/>
|
|
187 |
#endif
|
|
188 |
</xsl:template>
|
|
189 |
|
|
190 |
<xsl:template match="value" mode="write-fields">
|
|
191 |
<xsl:variable name="type" select="@type"/>
|
|
192 |
<xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
|
|
193 |
<xsl:value-of select="concat(' ', $wt, ' _', @field, ';')"/>
|
|
194 |
<xsl:if test="position() != last()">
|
|
195 |
<xsl:text>
|
|
196 |
</xsl:text>
|
|
197 |
</xsl:if>
|
|
198 |
</xsl:template>
|
|
199 |
|
|
200 |
<xsl:template match="structvalue" mode="write-fields">
|
|
201 |
<xsl:value-of select="concat(' TraceStruct', @type, ' _', @field, ';')"/>
|
|
202 |
<xsl:text>
|
|
203 |
</xsl:text>
|
|
204 |
</xsl:template>
|
|
205 |
|
|
206 |
<xsl:template match="value|transition_value|relation" mode="write-setters">
|
|
207 |
<xsl:param name="cls"/>
|
|
208 |
<xsl:variable name="type" select="@type"/>
|
|
209 |
<xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
|
|
210 |
<xsl:value-of select="concat(' void set_', @field, '(', $wt, ' value) { this->_', @field, ' = value; }')"/>
|
|
211 |
<xsl:if test="position() != last()">
|
|
212 |
<xsl:text>
|
|
213 |
</xsl:text>
|
|
214 |
</xsl:if>
|
|
215 |
</xsl:template>
|
|
216 |
|
|
217 |
<xsl:template match="structvalue" mode="write-setters">
|
|
218 |
<xsl:param name="cls"/>
|
|
219 |
<xsl:value-of select="concat(' void set_', @field, '(const TraceStruct', @type, '& value) { this->_', @field, ' = value; }')"/>
|
|
220 |
<xsl:if test="position() != last()">
|
|
221 |
<xsl:text>
|
|
222 |
</xsl:text>
|
|
223 |
</xsl:if>
|
|
224 |
</xsl:template>
|
|
225 |
|
|
226 |
<xsl:template match="value" mode="write-data">
|
|
227 |
<xsl:variable name="type" select="@type"/>
|
|
228 |
<xsl:variable name="wt" select="//primary_type[@symbol=$type]/@writetype"/>
|
|
229 |
<xsl:value-of select="concat(' ts.print_val("', @label, '", _', @field, ');')"/>
|
|
230 |
<xsl:if test="position() != last()">
|
|
231 |
<xsl:text>
|
|
232 |
ts.print(", ");
|
|
233 |
</xsl:text>
|
|
234 |
</xsl:if>
|
|
235 |
</xsl:template>
|
|
236 |
|
|
237 |
<xsl:template match="structvalue" mode="write-data">
|
|
238 |
<xsl:value-of select="concat(' _', @field, '.writeStruct(ts);')"/>
|
|
239 |
<xsl:if test="position() != last()">
|
|
240 |
<xsl:text>
|
|
241 |
ts.print(", ");
|
|
242 |
</xsl:text>
|
|
243 |
</xsl:if>
|
|
244 |
</xsl:template>
|
|
245 |
|
|
246 |
</xsl:stylesheet>
|