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