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