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