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 <!DOCTYPE types SYSTEM "trace.dtd">
  26 
  27 <!--
  28 
  29 Content types (complex) should create constant pool data
  30 in the recording.
  31 Currently at least, there is _NO_ verification that whatever
  32 writer you have is actually writing correctly. So BE CAREFUL!
  33 
  34 Declared with the 'content_type' tag.
  35 
  36 <type> is the ID type, i.e the integer type that resolves this. Most often
  37 U4 or U8, but for example really small number constants, like GCTYPE uses U1.
  38 
  39 <content-type> is where it gets interesting. 'builtin_type' means we're
  40 defining how we resolve one of the trace built-in types (Class, Thread etc),
  41 jvm_type means defining a new one for our own use.
  42 
  43 Example: (GcMode)
  44 
  45 <content_type id="GCMode" hr_name="GC mode" type="U1" jvm_type="GCMODE">
  46   <value type="UTF8" field="desc" description="Description"/>
  47 </content_type>
  48 
  49 This creates a content type CONTENT_TYPE_GCMODE
  50 The field type referencing it is u1 (U1), and the constant pool struct has one field, the name.
  51 
  52 Before we can use it we need also define a primary field data type:
  53 
  54 <primary_type symbol="GCMODE" datatype="U1" contenttype="NONE"
  55               type="u8" sizeop="sizeof(u1)"/>
  56 
  57 Now we can use the content + data type in declaring event fields.
  58 Remember however, that for us to be able to resolve the value later we must also add
  59 creating the constant pool data in  VM_JFRCheckpoint::write_checkpoint
  60 
  61    ...
  62    //CGMODE
  63    w->be_uint(CONTENT_TYPE_GCMODE);
  64    w->be_uint(MM_GC_MODE_UNINITIALIZED);
  65    for (i = 0; i < MM_GC_MODE_UNINITIALIZED; i++) {
  66       w->uchar(i);
  67       w->write_utf8(gcModeGetName(i));
  68    }
  69 
  70  -->
  71 
  72  <types>
  73   <content_types>
  74     <content_type id="Thread" hr_name="Thread"
  75                   type="U4" builtin_type="OSTHREAD">
  76       <value type="UTF8" field="name" label="Thread name"/>
  77     </content_type>
  78 
  79     <content_type id="VMThread" hr_name="VM Thread"
  80                   type="U8" jvm_type="VMTHREAD">
  81       <value type="OSTHREAD" field="thread" label="VM Thread"/>
  82     </content_type>
  83 
  84     <!-- The first argument ("JavaThread") is misleading, it's really a
  85          java.lang.Thread id (long), but Mission Control depends on the name
  86          being "JavaThread" so it shouldn't be changed.
  87     -->
  88     <content_type id="JavaThread" hr_name="Java thread"
  89                   type="U8" builtin_type="JAVALANGTHREAD">
  90       <value type="OSTHREAD" field="thread" label="OS Thread ID"/>
  91       <value type="BYTES64" field="allocInsideTla"
  92              label="Allocated bytes inside TLAs"/>
  93       <value type="BYTES64" field="allocOutsideTla"
  94              label="Allocated bytes outside TLAs"/>
  95       <value type="THREADGROUP" field="group" label="Java Thread Group"/>
  96     </content_type>
  97 
  98     <content_type id="ThreadGroup" hr_name="Thread group"
  99                   type="U4" jvm_type="THREADGROUP">
 100       <value type="THREADGROUP" field="parent" label="Parent"/>
 101       <value type="UTF8" field="name" label="Name"/>
 102     </content_type>
 103 
 104     <content_type id="StackTrace" hr_name="Stacktrace"
 105                   type="U8" builtin_type="STACKTRACE">
 106       <value type="BOOLEAN" field="truncated" label="Truncated"/>
 107       <structarray type="StackFrame" field="frames" label="Stack frames"/>
 108     </content_type>
 109 
 110     <content_type id="Class" hr_name="Java class"
 111                   type="U8" builtin_type="CLASS">
 112       <value type="CLASS" field="loaderClass" label="ClassLoader"/>
 113       <value type="SYMBOL" field="name" label="Name"/>
 114       <value type="SHORT" field="modifiers" label="Access modifiers"/>
 115     </content_type>
 116 
 117     <content_type id="Method" hr_name="Java method"
 118                   type="U8" jvm_type="METHOD">
 119       <value type="CLASS" field="class" label="Class"/>
 120       <value type="SYMBOL" field="name" label="Name"/>
 121       <value type="SYMBOL" field="signature" label="Signature"/>
 122       <value type="SHORT" field="modifiers" label="Access modifiers"/>
 123     </content_type>
 124 
 125     <content_type id="UTFConstant" hr_name="UTF constant"
 126                   type="U8" jvm_type="SYMBOL">
 127       <value type="UTF8" field="utf8" label="UTF8 data"/>
 128     </content_type>
 129 
 130     <content_type id="ThreadState" hr_name="Java Thread State"
 131                   type="U2" jvm_type="THREADSTATE">
 132       <value type="UTF8" field="name" label="Name"/>
 133     </content_type>
 134 
 135     <content_type id="FrameType" hr_name="Frame type"
 136                   type="U1" jvm_type="FRAMETYPE">
 137       <value type="UTF8" field="desc" label="Description"/>
 138     </content_type>
 139 
 140     <struct_type id="StackFrame">
 141       <value type="METHOD" field="method" label="Java Method"/>
 142       <value type="INTEGER" field="line" label="Line number"/>
 143       <value type="FRAMETYPE" field="type" label="Frame type"/>
 144     </struct_type>
 145 
 146     <content_type id="GCName" hr_name="GC Name"
 147                   type="U1" jvm_type="GCNAME">
 148       <value type="UTF8" field="name" label="name" />
 149     </content_type>
 150 
 151     <content_type id="GCCause" hr_name="GC Cause"
 152                   type="U2" jvm_type="GCCAUSE">
 153       <value type="UTF8" field="cause" label="cause" />
 154     </content_type>
 155 
 156     <content_type id="GCWhen" hr_name="GC When"
 157                   type="U1" jvm_type="GCWHEN">
 158       <value type="UTF8" field="when" label="when" />
 159     </content_type>
 160 
 161     <content_type id="G1YCType" hr_name="G1 YC Type"
 162                   type="U1" jvm_type="G1YCTYPE">
 163       <value type="UTF8" field="type" label="type" />
 164     </content_type>
 165 
 166     <content_type id="ReferenceType" hr_name="Reference Type"
 167                   type="U1" jvm_type="REFERENCETYPE">
 168       <value type="UTF8" field="type" label="type" />
 169     </content_type>
 170 
 171     <content_type id="NARROW_OOP_MODE" hr_name="Narrow Oop Mode"
 172                   type="U1" jvm_type="NARROWOOPMODE">
 173       <value type="UTF8" field="mode" label="mode" />
 174     </content_type>
 175 
 176     <content_type id="VMOperationType" hr_name="VM Operation Type"
 177                   type="U2" jvm_type="VMOPERATIONTYPE">
 178       <value type="UTF8" field="type" label="type" />
 179     </content_type>
 180 
 181     <content_type id="CompilerPhaseType" hr_name="Compiler Phase Type"
 182                   type="U1" jvm_type="COMPILERPHASETYPE">
 183       <value type="UTF8" field="phase" label="phase" />
 184     </content_type>
 185 
 186   </content_types>
 187 
 188 
 189   <primary_types>
 190     <!--
 191       - primary_type takes these attributes:
 192       -   symbol      INTEGER, LONG etc
 193       -   datatype    The trace datatype, see enum DataType
 194       -   contenttype Either resolved content type or the semantic meaning
 195       -   type        The actual type as used in structures etc
 196       -   sizeop      A function/macro that can be applied on a single
 197       -               struct value of type "type" and yield the factual byte
 198       -               size we need to write.  The % is replaced by the value
 199       -->
 200 
 201     <!-- SIGNED 64bit -->
 202     <primary_type symbol="LONG" datatype="LONG" contenttype="NONE"
 203                   type="s8" sizeop="sizeof(s8)"/>
 204 
 205     <!-- UNSIGNED 64bit -->
 206     <primary_type symbol="ULONG" datatype="U8" contenttype="NONE"
 207                   type="u8" sizeop="sizeof(u8)"/>
 208 
 209     <!-- SIGNED 32bit -->
 210     <primary_type symbol="INTEGER" datatype="INT" contenttype="NONE"
 211                   type="s4" sizeop="sizeof(s4)"/>
 212 
 213     <!-- UNSIGNED 32bit -->
 214     <primary_type symbol="UINT" datatype="U4" contenttype="NONE"
 215                   type="unsigned" sizeop="sizeof(unsigned)"/>
 216 
 217     <!-- UNSIGNED 16bit -->
 218     <primary_type symbol="USHORT" datatype="U2" contenttype="NONE"
 219                   type="u2" sizeop="sizeof(u2)"/>
 220 
 221     <!--  SIGNED 16bit -->
 222     <primary_type symbol="SHORT" datatype="SHORT" contenttype="NONE"
 223                   type="s2" sizeop="sizeof(s2)"/>
 224 
 225     <!--  SIGNED 8bit -->
 226     <primary_type symbol="BYTE" datatype="BYTE" contenttype="NONE"
 227                   type="s1" sizeop="sizeof(s1)"/>
 228 
 229     <!--  UNSIGNED 8bit -->
 230     <primary_type symbol="UBYTE" datatype="U1" contenttype="NONE"
 231                   type="u1" sizeop="sizeof(u1)"/>
 232 
 233     <!--  float 32bit -->
 234     <primary_type symbol="FLOAT" datatype="FLOAT" contenttype="NONE"
 235                   type="float" sizeop="sizeof(float)"/>
 236 
 237     <!--  float 64bit -->
 238     <primary_type symbol="DOUBLE" datatype="DOUBLE" contenttype="NONE"
 239                   type="double" sizeop="sizeof(double)"/>
 240 
 241     <!-- boolean type (1-byte) -->
 242     <primary_type symbol="BOOLEAN" datatype="BOOLEAN" contenttype="NONE"
 243                   type="bool" sizeop="1"/>
 244 
 245     <!-- 32-bit unsigned integer, SEMANTIC value BYTES -->
 246     <primary_type symbol="BYTES" datatype="U4" contenttype="BYTES"
 247                   type="u4" sizeop="sizeof(u4)"/>
 248 
 249     <primary_type symbol="IOBYTES" datatype="U4" contenttype="BYTES"
 250                   type="u4" sizeop="sizeof(u4)"/>
 251 
 252     <!-- 64-bit unsigned integer, SEMANTIC value BYTES -->
 253     <primary_type symbol="BYTES64" datatype="U8" contenttype="BYTES"
 254                   type="u8" sizeop="sizeof(u8)"/>
 255 
 256     <!-- 64-bit unsigned integer, SEMANTIC value ABSOLUTE MILLISECONDS -->
 257     <primary_type symbol="EPOCHMILLIS" datatype="LONG" contenttype="EPOCHMILLIS"
 258                   type="s8" sizeop="sizeof(s8)"/>
 259 
 260     <!-- 64-bit unsigned integer, SEMANTIC value RELATIVE MILLISECONDS -->
 261     <primary_type symbol="MILLIS" datatype="LONG" contenttype="MILLIS"
 262                   type="s8" sizeop="sizeof(s8)"/>
 263 
 264     <!-- 64-bit unsigned integer, SEMANTIC value RELATIVE NANOSECONDS -->
 265     <primary_type symbol="NANOS" datatype="LONG" contenttype="NANOS"
 266                   type="s8" sizeop="sizeof(s8)"/>
 267 
 268     <!-- 64-bit signed integer, SEMANTIC value ABSOLUTE TICKS -->
 269     <primary_type symbol="TICKS" datatype="LONG" contenttype="TICKS"
 270                   type="s8" sizeop="sizeof(s8)"/>
 271 
 272     <!-- 64-bit signed integer, SEMANTIC value RELATIVE TICKS -->
 273     <primary_type symbol="RELATIVE_TICKS" datatype="LONG" contenttype="TICKS"
 274                   type="s8" sizeop="sizeof(s8)"/>
 275 
 276     <!-- 64-bit unsigned integer, SEMANTIC value ADDRESS (mem loc) -->
 277     <primary_type symbol="ADDRESS" datatype="U8" contenttype="ADDRESS"
 278                   type="u8" sizeop="sizeof(u8)"/>
 279 
 280     <!-- 32-bit float, SEMANTIC value PERCENTAGE (0.0-1.0) -->
 281     <primary_type symbol="PERCENT" datatype="FLOAT" contenttype="PERCENTAGE"
 282                   type="float" sizeop="sizeof(float)"/>
 283 
 284     <!-- UTF-encoded string, max length 64k -->
 285     <primary_type symbol="UTF8" datatype="UTF8" contenttype="NONE"
 286                   type="const char *" sizeop="sizeof_utf(%)"/>
 287 
 288     <!-- Symbol* constant. Note that this may currently ONLY be used by
 289           classes, methods fields.  This restriction might be lifted. -->
 290     <primary_type symbol="SYMBOL" datatype="U8" contenttype="SYMBOL"
 291                   type="Symbol *" sizeop="sizeof(u8)"/>
 292 
 293     <!-- A Klass *. The actual class is marked as "used" and will
 294          eventually be written into the recording constant pool -->
 295     <primary_type symbol="CLASS" datatype="U8" contenttype="CLASS"
 296                   type="Klass *" sizeop="sizeof(u8)"/>
 297 
 298     <!-- A Method *. The method is marked as "used" and will eventually be
 299          written into the recording constant pool. -->
 300     <primary_type symbol="METHOD" datatype="U8" contenttype="METHOD"
 301                   type="Method *" sizeop="sizeof(u8)"/>
 302 
 303     <!--  The type for stacktraces in the recording. Shoudl not be used by
 304           events explicitly -->
 305     <primary_type symbol="STACKTRACE" datatype="U8" contenttype="STACKTRACE"
 306                   type="u8" sizeop="sizeof(u8)"/>
 307 
 308     <!-- OS Thread ID -->
 309     <primary_type symbol="OSTHREAD" datatype="U4" contenttype="OSTHREAD"
 310                   type="u4" sizeop="sizeof(u4)"/>
 311 
 312     <!-- VM Thread ID Note: changed from U2 to U8 for hotspot -->
 313     <primary_type symbol="VMTHREAD" datatype="U8" contenttype="VMTHREAD"
 314                   type="u8"  sizeop="sizeof(u8)"/>
 315 
 316     <!-- Java Thread ID -->
 317     <primary_type symbol="JAVALANGTHREAD" datatype="LONG"
 318                   contenttype="JAVALANGTHREAD" type="s8"
 319                   sizeop="sizeof(s8)"/>
 320 
 321     <!-- Threadgroup THIS TYPE MAY NOT BE USED IN NORMAL EVENTS (ATM). Only
 322           for thread constant pool // KK TODO: u8 should be ObjectP -->
 323     <primary_type symbol="THREADGROUP" datatype="U4" contenttype="THREADGROUP"
 324                   type="u8"
 325                   sizeop="sizeof(u4)"/>
 326 
 327     <!-- FRAMETYPE enum -->
 328     <primary_type symbol="FRAMETYPE" datatype="U1" contenttype="FRAMETYPE"
 329                   type="u1" sizeop="sizeof(u1)"/>
 330 
 331     <!-- THREADSTATE enum -->
 332     <primary_type symbol="THREADSTATE" datatype="U2" contenttype="THREADSTATE"
 333                   type="u2" sizeop="sizeof(u2)"/>
 334 
 335     <!-- GCName -->
 336     <primary_type symbol="GCNAME" datatype="U1" contenttype="GCNAME"
 337                   type="u1" sizeop="sizeof(u1)" />
 338 
 339     <!-- GCCAUSE -->
 340     <primary_type symbol="GCCAUSE" datatype="U2" contenttype="GCCAUSE"
 341                   type="u2" sizeop="sizeof(u2)" />
 342 
 343     <!-- GCWHEN -->
 344     <primary_type symbol="GCWHEN" datatype="U1" contenttype="GCWHEN"
 345                   type="u1" sizeop="sizeof(u1)" />
 346 
 347     <!-- G1YCType -->
 348     <primary_type symbol="G1YCTYPE" datatype="U1" contenttype="G1YCTYPE"
 349                   type="u1" sizeop="sizeof(u1)" />
 350 
 351     <!-- REFERENCETYPE -->
 352     <primary_type symbol="REFERENCETYPE" datatype="U1"
 353                   contenttype="REFERENCETYPE" type="u1" sizeop="sizeof(u1)" />
 354 
 355     <!-- NARROWOOPMODE -->
 356     <primary_type symbol="NARROWOOPMODE" datatype="U1"
 357                   contenttype="NARROWOOPMODE" type="u1" sizeop="sizeof(u1)" />
 358 
 359     <!-- COMPILERPHASETYPE -->
 360     <primary_type symbol="COMPILERPHASETYPE" datatype="U1"
 361                   contenttype="COMPILERPHASETYPE" type="u1" sizeop="sizeof(u1)" />
 362 
 363     <!-- VMOPERATIONTYPE -->
 364     <primary_type symbol="VMOPERATIONTYPE" datatype="U2" contenttype="VMOPERATIONTYPE"
 365                   type="u2" sizeop="sizeof(u2)" />
 366 
 367   </primary_types>
 368 </types>