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