1 <?xml version="1.0"?> 
   2 <!--
   3  Copyright (c) 2002, 2015, 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 
  26 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  27 
  28 <xsl:import href="jvmtiLib.xsl"/>
  29 
  30 <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
  31 
  32 <xsl:param name="trace"></xsl:param>
  33 <xsl:param name="interface"></xsl:param>
  34 
  35 
  36 <xsl:template match="specification">
  37   <xsl:call-template name="sourceHeader"/>
  38   <xsl:text>
  39 # include "precompiled.hpp"
  40 # include "memory/resourceArea.hpp"
  41 # include "utilities/macros.hpp"
  42 #if INCLUDE_JVMTI
  43 # include "oops/oop.inline.hpp"
  44 # include "prims/jvmtiEnter.hpp"
  45 # include "prims/jvmtiRawMonitor.hpp"
  46 # include "prims/jvmtiUtil.hpp"
  47 
  48 </xsl:text>
  49 
  50   <xsl:if test="$trace = 'Trace'">
  51    <xsl:text>
  52 #ifdef JVMTI_TRACE
  53 </xsl:text>
  54   </xsl:if>
  55 
  56  <xsl:if test="$trace != 'Trace'">
  57     <xsl:text>
  58 
  59 // Error names
  60 const char* JvmtiUtil::_error_names[] = {
  61 </xsl:text>
  62     <xsl:call-template name="fillEntityName"> 
  63       <xsl:with-param name="entities" select="errorsection/errorcategory/errorid"/>
  64     </xsl:call-template>
  65     <xsl:text>
  66 };
  67 
  68 
  69 // Event threaded
  70 const bool JvmtiUtil::_event_threaded[] = {
  71 </xsl:text>
  72     <xsl:call-template name="fillEventThreaded"> 
  73       <xsl:with-param name="entities" select="eventsection/event"/>
  74     </xsl:call-template>
  75     <xsl:text>
  76 };
  77 
  78 </xsl:text>
  79     <xsl:call-template name="eventCapabilitiesTest"/>
  80  </xsl:if>
  81 
  82  <xsl:if test="$trace = 'Trace'">
  83 
  84 <!--  all this just to return the highest event number -->
  85   <xsl:variable name="maxEvent">
  86     <xsl:for-each select="eventsection/event">
  87       <xsl:variable name="mynum" select="@num"/>
  88       <xsl:if test="count(../../eventsection/event[@num &gt; $mynum]) = 0">
  89         <xsl:value-of select="@num"/>
  90       </xsl:if>
  91     </xsl:for-each>    
  92   </xsl:variable>
  93 
  94   <xsl:text>jbyte JvmtiTrace::_event_trace_flags[</xsl:text>
  95   <xsl:value-of select="1+$maxEvent"/>
  96   <xsl:text>];
  97 
  98 jint JvmtiTrace::_max_event_index = </xsl:text>
  99   <xsl:value-of select="$maxEvent"/>
 100   <xsl:text>;
 101 
 102 // Event names
 103 const char* JvmtiTrace::_event_names[] = {
 104 </xsl:text>
 105     <xsl:call-template name="fillEntityName"> 
 106       <xsl:with-param name="entities" select="eventsection/event"/>
 107     </xsl:call-template>
 108     <xsl:text>
 109 };
 110 </xsl:text>
 111     <xsl:apply-templates select="//constants[@kind='enum']"/>
 112   </xsl:if>
 113   <xsl:apply-templates select="functionsection"/>
 114 
 115   <xsl:if test="$trace='Trace'">
 116    <xsl:text>
 117 #endif /*JVMTI_TRACE */
 118 </xsl:text>
 119   </xsl:if>
 120 
 121 </xsl:template>
 122 
 123 <xsl:template match="constants">
 124   <xsl:text>
 125 
 126 // </xsl:text>
 127   <xsl:value-of select="@label"/>
 128   <xsl:text> names
 129 const char* </xsl:text>
 130   <xsl:value-of select="@id"/>
 131   <xsl:text>ConstantNames[] = {
 132 </xsl:text>
 133   <xsl:apply-templates select="constant" mode="constname"/>
 134   <xsl:text>  NULL
 135 };
 136 
 137 // </xsl:text>
 138   <xsl:value-of select="@label"/>
 139   <xsl:text> value
 140 jint </xsl:text>
 141   <xsl:value-of select="@id"/>
 142   <xsl:text>ConstantValues[] = {
 143 </xsl:text>
 144   <xsl:apply-templates select="constant" mode="constvalue"/>
 145   <xsl:text>  0
 146 };
 147 
 148 </xsl:text>
 149 </xsl:template>
 150 
 151 <xsl:template match="constant" mode="constname">
 152   <xsl:text>  "</xsl:text>
 153   <xsl:value-of select="@id"/>
 154   <xsl:text>",
 155 </xsl:text>
 156 </xsl:template>
 157 
 158 <xsl:template match="constant" mode="constvalue">
 159   <xsl:text>  </xsl:text>
 160   <xsl:value-of select="@num"/>
 161   <xsl:text>,
 162 </xsl:text>
 163 </xsl:template>
 164 
 165 <xsl:template name="eventCapabilitiesTest">
 166   <xsl:text>
 167 
 168 // Check Event Capabilities
 169 const bool JvmtiUtil::has_event_capability(jvmtiEvent event_type, const jvmtiCapabilities* capabilities_ptr) {
 170   switch (event_type) {
 171 </xsl:text>
 172   <xsl:for-each select="//eventsection/event">
 173     <xsl:variable name="capa" select="capabilities/required"/>
 174     <xsl:if test="count($capa)">
 175         <xsl:text>    case </xsl:text>
 176         <xsl:value-of select="@const"/>
 177         <xsl:text>:
 178       return capabilities_ptr-&gt;</xsl:text>
 179         <xsl:value-of select="$capa/@id"/>
 180         <xsl:text> != 0;
 181 </xsl:text>
 182     </xsl:if>
 183   </xsl:for-each>
 184   <xsl:text>  }
 185   // if it does not have a capability it is required
 186   return JNI_TRUE;
 187 }
 188 
 189 </xsl:text>
 190 </xsl:template>
 191 
 192 <xsl:template match="functionsection">
 193   <xsl:if test="$trace='Trace'">
 194 
 195 <!--  all this just to return the highest function number -->
 196   <xsl:variable name="maxFunction">
 197     <xsl:for-each select="category/function">
 198       <xsl:variable name="mynum" select="@num"/>
 199       <xsl:if test="count(../../category/function[@num &gt; $mynum]) = 0">
 200         <xsl:value-of select="@num"/>
 201       </xsl:if>
 202     </xsl:for-each>    
 203   </xsl:variable>
 204 
 205   <xsl:text>jbyte JvmtiTrace::_trace_flags[</xsl:text>
 206   <xsl:value-of select="1+$maxFunction"/>
 207   <xsl:text>];
 208 
 209 jint JvmtiTrace::_max_function_index = </xsl:text>
 210   <xsl:value-of select="$maxFunction"/>
 211   <xsl:text>;
 212 
 213 // Function names
 214 const char* JvmtiTrace::_function_names[] = {
 215 </xsl:text>
 216   <xsl:call-template name="fillEntityName">
 217     <xsl:with-param name="entities" select="category/function"/>
 218   </xsl:call-template>
 219   <xsl:text>
 220 };
 221 
 222 // Exclude list
 223 short JvmtiTrace::_exclude_functions[] = {
 224   </xsl:text>
 225   <xsl:apply-templates select="category/function" mode="notrace">
 226     <xsl:sort select="@num"/>
 227   </xsl:apply-templates>
 228   <xsl:text>0
 229 };
 230 
 231 </xsl:text>
 232   </xsl:if>
 233 
 234   <xsl:text>
 235 extern "C" {
 236 
 237 </xsl:text>
 238   <xsl:apply-templates select="category" mode="wrapper"/>
 239   <xsl:text>
 240 } /* end extern "C" */
 241 
 242 // JVMTI API functions
 243 struct jvmtiInterface_1_ jvmti</xsl:text>
 244   <xsl:value-of select="$trace"/>
 245   <xsl:text>_Interface = {
 246 </xsl:text>
 247  
 248   <xsl:call-template name="fillFuncStruct">
 249     <xsl:with-param name="funcs" select="category/function[count(@hide)=0]"/>
 250   </xsl:call-template>
 251 
 252   <xsl:text>
 253 };
 254 #endif // INCLUDE_JVMTI
 255 </xsl:text>
 256 </xsl:template>
 257 
 258 <xsl:template match="function" mode="functionid">
 259   <xsl:text>jvmti</xsl:text>
 260   <xsl:value-of select="$trace"/>
 261   <xsl:text>_</xsl:text>
 262   <xsl:value-of select="@id"/>
 263 </xsl:template>
 264 
 265 <xsl:template name="fillFuncStructDoit">
 266   <xsl:param name="func"/>
 267   <xsl:param name="index"/>
 268   <xsl:text>                              /* </xsl:text>
 269   <xsl:number value="$index" format="  1"/>
 270   <xsl:text> : </xsl:text>
 271   <xsl:choose>
 272     <xsl:when test="count($func)=1">
 273       <xsl:value-of select="$func/synopsis"/>
 274       <xsl:text> */
 275       </xsl:text>
 276       <xsl:apply-templates select="$func" mode="functionid"/>
 277     </xsl:when>
 278     <xsl:otherwise>
 279       <xsl:text> RESERVED */
 280       NULL</xsl:text>        
 281     </xsl:otherwise>
 282   </xsl:choose>
 283 </xsl:template>
 284 
 285 <!-- generic function iterator applied to the function structure -->
 286 <xsl:template name="fillFuncStruct">
 287   <xsl:param name="funcs"/>
 288   <xsl:param name="index" select="1"/>
 289   <xsl:call-template name="fillFuncStructDoit">
 290     <xsl:with-param name="func" select="$funcs[@num=$index]"/>
 291     <xsl:with-param name="index" select="$index"/>
 292   </xsl:call-template>
 293   <xsl:if test="count($funcs[@num &gt; $index]) &gt; 0">
 294     <xsl:text>,
 295 </xsl:text>
 296     <xsl:call-template name="fillFuncStruct">
 297       <xsl:with-param name="funcs" select="$funcs"/>
 298       <xsl:with-param name="index" select="1+$index"/>
 299     </xsl:call-template>
 300   </xsl:if>
 301 </xsl:template>
 302 
 303 <xsl:template name="fillEntityNameDoit">
 304   <xsl:param name="entity"/>
 305   <xsl:param name="index"/>
 306   <xsl:choose>
 307     <xsl:when test="count($entity) &gt; 0">
 308       <xsl:text>  "</xsl:text>
 309       <xsl:value-of select="$entity[position()=1]/@id"/>
 310       <xsl:text>"</xsl:text>
 311     </xsl:when>
 312     <xsl:otherwise>
 313       <xsl:text>  NULL</xsl:text>        
 314     </xsl:otherwise>
 315   </xsl:choose>
 316 </xsl:template>
 317 
 318 <!-- generic entity (with id and num) iterator applied to entity names -->
 319 <xsl:template name="fillEntityName">
 320   <xsl:param name="entities"/>
 321   <xsl:param name="index" select="0"/>
 322   <xsl:call-template name="fillEntityNameDoit">
 323     <xsl:with-param name="entity" select="$entities[@num=$index]"/>
 324     <xsl:with-param name="index" select="$index"/>
 325   </xsl:call-template>
 326   <xsl:if test="count($entities[@num &gt; $index]) &gt; 0">
 327     <xsl:text>,
 328 </xsl:text>
 329     <xsl:call-template name="fillEntityName">
 330       <xsl:with-param name="entities" select="$entities"/>
 331       <xsl:with-param name="index" select="1+$index"/>
 332     </xsl:call-template>
 333   </xsl:if>
 334 </xsl:template>
 335 
 336 <xsl:template name="fillEventThreadedDoit">
 337   <xsl:param name="entity"/>
 338   <xsl:param name="index"/>
 339   <xsl:choose>
 340     <xsl:when test="count($entity) &gt; 0">
 341       <xsl:choose>
 342         <xsl:when test="count($entity[position()=1]/@filtered)=0">
 343           <xsl:text>  false</xsl:text>
 344         </xsl:when>
 345         <xsl:otherwise>
 346           <xsl:text>  true</xsl:text>        
 347         </xsl:otherwise>
 348       </xsl:choose>
 349     </xsl:when>
 350     <xsl:otherwise>
 351       <xsl:text>  false</xsl:text>        
 352     </xsl:otherwise>
 353   </xsl:choose>
 354 </xsl:template>
 355 
 356 
 357 <xsl:template name="fillEventThreaded">
 358   <xsl:param name="entities"/>
 359   <xsl:param name="index" select="0"/>
 360   <xsl:call-template name="fillEventThreadedDoit">
 361     <xsl:with-param name="entity" select="$entities[@num=$index]"/>
 362     <xsl:with-param name="index" select="$index"/>
 363   </xsl:call-template>
 364   <xsl:if test="count($entities[@num &gt; $index]) &gt; 0">
 365     <xsl:text>,
 366 </xsl:text>
 367     <xsl:call-template name="fillEventThreaded">
 368       <xsl:with-param name="entities" select="$entities"/>
 369       <xsl:with-param name="index" select="1+$index"/>
 370     </xsl:call-template>
 371   </xsl:if>
 372 </xsl:template>
 373 
 374 <xsl:template match="function" mode="notrace">
 375   <xsl:if test="count(@impl)=1 and contains(@impl,'notrace')">
 376     <xsl:value-of select="@num"/>
 377     <xsl:text>,
 378   </xsl:text>
 379   </xsl:if>
 380 </xsl:template>
 381 
 382 <xsl:template match="category" mode="wrapper">
 383   <xsl:text>
 384   //
 385   // </xsl:text><xsl:value-of select="@label"/><xsl:text> functions
 386   // 
 387 </xsl:text>
 388   <xsl:apply-templates select="function[count(@hide)=0]"/>
 389 </xsl:template>
 390 
 391 <xsl:template match="function" mode="transition">
 392   <xsl:param name="space">
 393     <xsl:text>
 394   </xsl:text>
 395   </xsl:param>
 396   <xsl:value-of select="$space"/>
 397   
 398   <xsl:choose> 
 399     <xsl:when test="count(@callbacksafe)=0 or not(contains(@callbacksafe,'safe'))">
 400       <xsl:text>if (this_thread == NULL || !this_thread->is_Java_thread()) {</xsl:text> 
 401     </xsl:when> 
 402     <xsl:otherwise> 
 403       <xsl:choose>
 404         <xsl:when test="count(@phase)=0 or contains(@phase,'live') or contains(@phase,'start')">
 405           <xsl:text>if (this_thread == NULL || (!this_thread->is_Java_thread() &amp;&amp; !this_thread->is_VM_thread())) {</xsl:text>
 406         </xsl:when>
 407         <xsl:otherwise>
 408           <xsl:text>if (!this_thread->is_Java_thread()) {</xsl:text> 
 409         </xsl:otherwise>
 410       </xsl:choose>
 411      </xsl:otherwise> 
 412   </xsl:choose> 
 413   
 414   <xsl:if test="$trace='Trace'">
 415     <xsl:value-of select="$space"/>
 416     <xsl:text>  if (trace_flags) {</xsl:text>
 417     <xsl:value-of select="$space"/>
 418     <xsl:text>    tty->print_cr("JVMTI [non-attached thread] %s %s",  func_name,</xsl:text>
 419     <xsl:value-of select="$space"/>
 420     <xsl:text>    JvmtiUtil::error_name(JVMTI_ERROR_UNATTACHED_THREAD));</xsl:text>
 421     <xsl:value-of select="$space"/>
 422     <xsl:text>  }</xsl:text>
 423   </xsl:if>
 424   <xsl:value-of select="$space"/>
 425   <xsl:text>  return JVMTI_ERROR_UNATTACHED_THREAD;</xsl:text>
 426   <xsl:value-of select="$space"/>
 427   <xsl:text>}</xsl:text>  
 428   <xsl:value-of select="$space"/>  
 429   <xsl:if test="count(@impl)=0 or not(contains(@impl,'innative'))">
 430     <xsl:text>JavaThread* current_thread = (JavaThread*)this_thread;</xsl:text>   
 431     <xsl:value-of select="$space"/>
 432     <xsl:text>ThreadInVMfromNative __tiv(current_thread);</xsl:text>
 433     <xsl:value-of select="$space"/>
 434     <xsl:text>VM_ENTRY_BASE(jvmtiError, </xsl:text>
 435     <xsl:apply-templates select="." mode="functionid"/>
 436     <xsl:text> , current_thread)</xsl:text>
 437     <xsl:value-of select="$space"/>
 438     <xsl:text>debug_only(VMNativeEntryWrapper __vew;)</xsl:text>
 439     <xsl:if test="count(@callbacksafe)=0 or not(contains(@callbacksafe,'safe'))">
 440       <xsl:value-of select="$space"/>
 441       <xsl:text>CautiouslyPreserveExceptionMark __em(this_thread);</xsl:text>
 442     </xsl:if>
 443   </xsl:if>
 444 </xsl:template>
 445 
 446 
 447 <xsl:template match="required">
 448   <xsl:text>
 449   if (jvmti_env-&gt;get_capabilities()-&gt;</xsl:text>
 450     <xsl:value-of select="@id"/>
 451     <xsl:text> == 0) {
 452 </xsl:text>
 453     <xsl:if test="$trace='Trace'">
 454       <xsl:text>    if (trace_flags) {
 455           tty->print_cr("JVMTI [%s] %s %s",  curr_thread_name, func_name, 
 456                     JvmtiUtil::error_name(JVMTI_ERROR_MUST_POSSESS_CAPABILITY));
 457     }
 458 </xsl:text>
 459     </xsl:if>
 460     <xsl:text>    return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
 461   }
 462 </xsl:text>
 463 </xsl:template>
 464 
 465 
 466 <xsl:template match="function">
 467   <xsl:text>
 468 static jvmtiError JNICALL
 469 </xsl:text>
 470   <xsl:apply-templates select="." mode="functionid"/>
 471   <xsl:text>(jvmtiEnv* env</xsl:text>
 472   <xsl:apply-templates select="parameters" mode="signature"/>
 473   <xsl:text>) {
 474 </xsl:text>
 475 
 476   <xsl:if test="not(contains(@jkernel,'yes'))">
 477   <xsl:text>&#xA;#if !INCLUDE_JVMTI &#xA;</xsl:text>
 478   <xsl:text>  return JVMTI_ERROR_NOT_AVAILABLE; &#xA;</xsl:text>
 479   <xsl:text>#else &#xA;</xsl:text>
 480   </xsl:if>
 481 
 482   <xsl:apply-templates select="." mode="traceSetUp"/>
 483   <xsl:choose>
 484     <xsl:when test="count(@phase)=0 or contains(@phase,'live')">
 485       <xsl:text>  if(!JvmtiEnv::is_vm_live()) {
 486 </xsl:text>
 487     <xsl:if test="$trace='Trace'">
 488       <xsl:text>    if (trace_flags) {
 489           tty->print_cr("JVMTI [-] %s %s",  func_name, 
 490                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
 491     }
 492 </xsl:text>
 493     </xsl:if>
 494     <xsl:text>    return JVMTI_ERROR_WRONG_PHASE;
 495   }</xsl:text>  
 496 
 497       <xsl:text>  
 498   Thread* this_thread = Thread::current_or_null(); </xsl:text>
 499 
 500       <xsl:apply-templates select="." mode="transition"/>
 501     </xsl:when>
 502     <xsl:otherwise>
 503       <xsl:if test="contains(@phase,'onload')">
 504         <xsl:text>  if(JvmtiEnv::get_phase()!=JVMTI_PHASE_ONLOAD</xsl:text>
 505         <xsl:if test="not(contains(@phase,'onloadOnly'))">
 506           <xsl:text> &amp;&amp; JvmtiEnv::get_phase()!=JVMTI_PHASE_LIVE</xsl:text>
 507         </xsl:if>
 508         <xsl:text>) {
 509 </xsl:text>
 510     <xsl:if test="$trace='Trace'">
 511       <xsl:text>    if (trace_flags) {
 512           tty->print_cr("JVMTI [-] %s %s",  func_name, 
 513                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
 514     }
 515 </xsl:text>
 516     </xsl:if>
 517     <xsl:text>    return JVMTI_ERROR_WRONG_PHASE;
 518   }</xsl:text>
 519       </xsl:if>
 520       <xsl:if test="contains(@phase,'start')">
 521         <xsl:text>  if(JvmtiEnv::get_phase()!=JVMTI_PHASE_START &amp;&amp; JvmtiEnv::get_phase()!=JVMTI_PHASE_LIVE) {
 522 </xsl:text>
 523     <xsl:if test="$trace='Trace'">
 524       <xsl:text>    if (trace_flags) {
 525           tty->print_cr("JVMTI [-] %s %s",  func_name, 
 526                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
 527     }
 528 </xsl:text>
 529     </xsl:if>
 530     <xsl:text>    return JVMTI_ERROR_WRONG_PHASE;
 531   }
 532   Thread* this_thread = Thread::current_or_null(); </xsl:text>
 533       <xsl:apply-templates select="." mode="transition"/>
 534       </xsl:if>
 535     </xsl:otherwise>
 536   </xsl:choose>
 537 
 538   <xsl:text>
 539   JvmtiEnv* jvmti_env = JvmtiEnv::JvmtiEnv_from_jvmti_env(env);
 540   if (!jvmti_env->is_valid()) {
 541 </xsl:text>
 542     <xsl:if test="$trace='Trace'">
 543       <xsl:text>    if (trace_flags) {
 544           tty->print_cr("JVMTI [%s] %s %s  env=" PTR_FORMAT,  curr_thread_name, func_name, 
 545                     JvmtiUtil::error_name(JVMTI_ERROR_INVALID_ENVIRONMENT), p2i(env));
 546     }
 547 </xsl:text>
 548     </xsl:if>
 549     <xsl:text>    return JVMTI_ERROR_INVALID_ENVIRONMENT;
 550   }
 551 </xsl:text>
 552 
 553   <xsl:apply-templates select="capabilities/required"/>
 554   
 555   <xsl:text>  jvmtiError err;
 556 </xsl:text>
 557   <xsl:choose>
 558     <xsl:when test="count(@phase)=1 and not(contains(@phase,'live')) and not(contains(@phase,'start'))">    
 559       <xsl:choose>
 560         <xsl:when test="count(@callbacksafe)=0 or not(contains(@callbacksafe,'safe'))">
 561           <xsl:text>  if (Threads::number_of_threads() != 0) {
 562     Thread* this_thread = Thread::current_or_null();</xsl:text>
 563         </xsl:when>
 564         <xsl:otherwise>
 565 
 566           <xsl:text>  Thread* this_thread = NULL;
 567   bool transition;
 568   if (Threads::number_of_threads() == 0) {
 569     transition = false;
 570   } else {
 571     this_thread = Thread::current_or_null();
 572     transition = ((this_thread != NULL) &amp;&amp; !this_thread->is_VM_thread() &amp;&amp; !this_thread->is_ConcurrentGC_thread());
 573   }
 574   if (transition) {</xsl:text>
 575         </xsl:otherwise>
 576 
 577       </xsl:choose>
 578       <!-- we allow use in early phases but there are threads now, -->
 579       <!-- so do thread transition -->
 580       <xsl:apply-templates select="." mode="transition">
 581           <xsl:with-param name="space">
 582             <xsl:text>
 583     </xsl:text>
 584           </xsl:with-param>
 585       </xsl:apply-templates>
 586       <xsl:text>
 587   </xsl:text>
 588       <xsl:apply-templates select="." mode="doCall"/>     
 589       <xsl:text>  } else {
 590   </xsl:text>
 591       <!-- we are pre-thread - no thread transition code -->
 592       <xsl:apply-templates select="." mode="doCall"/>     
 593       <xsl:text>  }
 594 </xsl:text>
 595     </xsl:when>
 596     <xsl:otherwise>
 597       <xsl:apply-templates select="." mode="doCall"/>      
 598     </xsl:otherwise>
 599   </xsl:choose>
 600   <xsl:text>  return err;
 601 </xsl:text>
 602 
 603   <xsl:if test="not(contains(@jkernel,'yes'))">
 604   <xsl:text>#endif // INCLUDE_JVMTI&#xA;</xsl:text>
 605   </xsl:if>
 606 
 607   <xsl:text>}&#xA;</xsl:text>
 608 </xsl:template>
 609 
 610 <xsl:template match="function" mode="doCall">
 611   <xsl:apply-templates select="parameters" mode="dochecks"/>
 612   <xsl:apply-templates select="." mode="traceBefore"/>  
 613   <xsl:apply-templates select="." mode="genCall"/>
 614   <xsl:apply-templates select="." mode="traceAfter"/>
 615 </xsl:template>
 616 
 617 <xsl:template match="function" mode="genCall">
 618   <xsl:text>  err = jvmti_env-&gt;</xsl:text>
 619   <xsl:value-of select="@id"/>
 620   <xsl:text>(</xsl:text>
 621   <xsl:apply-templates select="parameters" mode="HotSpotValue"/>
 622   <xsl:text>);
 623 </xsl:text>
 624 </xsl:template>
 625 
 626 
 627 <xsl:template match="function" mode="traceSetUp">
 628   <xsl:if test="$trace='Trace'">
 629     <xsl:text>  SafeResourceMark rm;
 630   jint trace_flags = JvmtiTrace::trace_flags(</xsl:text>
 631       <xsl:value-of select="@num"/>
 632       <xsl:text>);
 633   const char *func_name = NULL;
 634   const char *curr_thread_name = NULL;
 635   if (trace_flags) {
 636     func_name = JvmtiTrace::function_name(</xsl:text>
 637       <xsl:value-of select="@num"/>
 638       <xsl:text>);
 639     curr_thread_name = JvmtiTrace::safe_get_current_thread_name();
 640   }
 641 </xsl:text>
 642   </xsl:if>
 643 </xsl:template>
 644 
 645 
 646 <xsl:template match="function" mode="traceBefore">
 647   <xsl:if test="$trace='Trace'">
 648     <xsl:text>
 649   if ((trace_flags &amp; JvmtiTrace::SHOW_IN) != 0) {
 650     </xsl:text>
 651     <xsl:apply-templates select="." mode="traceIn"/>
 652     <xsl:text>  }
 653 </xsl:text>
 654   </xsl:if>
 655 </xsl:template>
 656 
 657 
 658 <xsl:template match="param" mode="traceError">
 659   <xsl:param name="err"/>
 660   <xsl:param name="comment"></xsl:param>
 661   <xsl:param name="extraValue"></xsl:param>
 662   <xsl:if test="$trace='Trace'">
 663   <xsl:text>      if ((trace_flags &amp; JvmtiTrace::SHOW_ERROR) != 0) {
 664         if ((trace_flags &amp; JvmtiTrace::SHOW_IN) == 0) {
 665 </xsl:text>
 666   <xsl:apply-templates select="../.." mode="traceIn">
 667     <xsl:with-param name="endParam" select="."/>
 668   </xsl:apply-templates>
 669   <xsl:text>      }
 670         tty->print_cr("JVMTI [%s] %s } %s - erroneous arg is </xsl:text>
 671     <xsl:value-of select="@id"/>
 672     <xsl:value-of select="$comment"/>
 673     <xsl:text>",  curr_thread_name, func_name, 
 674                   JvmtiUtil::error_name(</xsl:text>
 675     <xsl:value-of select="$err"/>
 676     <xsl:text>)</xsl:text>
 677     <xsl:value-of select="$extraValue"/>
 678     <xsl:text>);
 679       }
 680 </xsl:text>
 681   </xsl:if>
 682     <xsl:text>      return </xsl:text>
 683     <xsl:value-of select="$err"/>
 684     <xsl:text>;</xsl:text>
 685 </xsl:template>
 686 
 687 
 688 <xsl:template match="function" mode="traceAfter">
 689   <xsl:if test="$trace='Trace'">
 690     <xsl:text>  if ( err != JVMTI_ERROR_NONE &amp;&amp; (trace_flags &amp; JvmtiTrace::SHOW_ERROR) != 0) {
 691       if ((trace_flags &amp; JvmtiTrace::SHOW_IN) == 0) {
 692 </xsl:text>
 693     <xsl:apply-templates select="." mode="traceIn"/>
 694     <xsl:text>    }
 695     tty->print_cr("JVMTI [%s] %s } %s",  curr_thread_name, func_name, 
 696                   JvmtiUtil::error_name(err));
 697   } else if ((trace_flags &amp; JvmtiTrace::SHOW_OUT) != 0) {
 698     tty->print_cr("JVMTI [%s] %s }",  curr_thread_name, func_name);
 699   }
 700 </xsl:text>
 701   </xsl:if>
 702 </xsl:template>
 703 
 704 <xsl:template match="function" mode="traceIn">
 705   <xsl:param name="endParam"></xsl:param>
 706   <xsl:text>          tty->print_cr("JVMTI [%s] %s { </xsl:text>
 707   <xsl:apply-templates select="parameters" mode="traceInFormat">
 708     <xsl:with-param name="endParam" select="$endParam"/>    
 709   </xsl:apply-templates>
 710   <xsl:text>", curr_thread_name, func_name</xsl:text>
 711   <xsl:apply-templates select="parameters" mode="traceInValue">
 712     <xsl:with-param name="endParam" select="$endParam"/>    
 713   </xsl:apply-templates>
 714   <xsl:text>);
 715 </xsl:text>
 716 </xsl:template>
 717 
 718 <xsl:template match="parameters" mode="dochecks">
 719   <xsl:apply-templates select="param" mode="dochecks"/>
 720 </xsl:template>
 721 
 722 <xsl:template match="param" mode="dochecks">
 723   <xsl:apply-templates select="child::*[position()=1]" mode="dochecks">
 724     <xsl:with-param name="name" select="@id"/>
 725   </xsl:apply-templates>
 726 </xsl:template>
 727 
 728 <xsl:template match="outptr|outbuf|allocfieldbuf|ptrtype|inptr|inbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="dochecks">
 729   <xsl:param name="name"/>
 730   <xsl:if test="count(nullok)=0">
 731     <xsl:text>  if (</xsl:text>
 732     <xsl:value-of select="$name"/>
 733     <xsl:text> == NULL) {
 734 </xsl:text>
 735     <xsl:apply-templates select=".." mode="traceError">     
 736       <xsl:with-param name="err">JVMTI_ERROR_NULL_POINTER</xsl:with-param>
 737     </xsl:apply-templates>
 738     <xsl:text>
 739   }
 740 </xsl:text>
 741   </xsl:if>
 742 </xsl:template>
 743 
 744 <xsl:template match="jrawMonitorID" mode="dochecks">
 745   <xsl:param name="name"/>
 746   <xsl:text>  JvmtiRawMonitor *rmonitor = (JvmtiRawMonitor *)</xsl:text>
 747   <xsl:value-of select="$name"/>
 748   <xsl:text>;
 749   if (rmonitor == NULL) {
 750 </xsl:text>
 751     <xsl:apply-templates select=".." mode="traceError">     
 752       <xsl:with-param name="err">JVMTI_ERROR_INVALID_MONITOR</xsl:with-param>
 753       <xsl:with-param name="comment"> - raw monitor is NULL</xsl:with-param>
 754     </xsl:apply-templates>
 755     <xsl:text>
 756   }
 757   if (!rmonitor->is_valid()) {
 758 </xsl:text>
 759     <xsl:apply-templates select=".." mode="traceError">     
 760       <xsl:with-param name="err">JVMTI_ERROR_INVALID_MONITOR</xsl:with-param>
 761       <xsl:with-param name="comment"> - not a raw monitor " PTR_FORMAT "</xsl:with-param>
 762       <xsl:with-param name="extraValue">, p2i(rmonitor)</xsl:with-param>
 763     </xsl:apply-templates>
 764     <xsl:text>
 765   }
 766 </xsl:text>
 767 </xsl:template>
 768 
 769 <xsl:template match="jthread" mode="dochecksbody">
 770   <xsl:param name="name"/>
 771     <xsl:text>    oop thread_oop = JNIHandles::resolve_external_guard(</xsl:text>
 772     <xsl:value-of select="$name"/>
 773     <xsl:text>);
 774     if (thread_oop == NULL) {
 775 </xsl:text>
 776     <xsl:apply-templates select=".." mode="traceError">     
 777       <xsl:with-param name="err">JVMTI_ERROR_INVALID_THREAD</xsl:with-param>
 778       <xsl:with-param name="comment"> - jthread resolved to NULL - jthread = " PTR_FORMAT "</xsl:with-param>
 779       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 780     </xsl:apply-templates>
 781     <xsl:text>
 782     }
 783     if (!thread_oop-&gt;is_a(SystemDictionary::Thread_klass())) {
 784 </xsl:text>
 785     <xsl:apply-templates select=".." mode="traceError">     
 786       <xsl:with-param name="err">JVMTI_ERROR_INVALID_THREAD</xsl:with-param>
 787       <xsl:with-param name="comment"> - oop is not a thread - jthread = " PTR_FORMAT "</xsl:with-param>
 788       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 789     </xsl:apply-templates>
 790     <xsl:text>
 791     }
 792     java_thread = java_lang_Thread::thread(thread_oop); 
 793     if (java_thread == NULL) {
 794 </xsl:text>
 795     <xsl:apply-templates select=".." mode="traceError">     
 796       <xsl:with-param name="err">
 797         <xsl:text>JVMTI_ERROR_THREAD_NOT_ALIVE</xsl:text>
 798       </xsl:with-param>
 799       <xsl:with-param name="comment"> - not a Java thread - jthread = " PTR_FORMAT "</xsl:with-param>
 800       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 801     </xsl:apply-templates>
 802     <xsl:text>
 803     }
 804 </xsl:text>  
 805 </xsl:template>
 806 
 807 <xsl:template match="jthread" mode="dochecks">
 808   <xsl:param name="name"/>
 809   <!-- If we convert and test threads -->
 810   <xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
 811     <xsl:text>  JavaThread* java_thread;
 812 </xsl:text>
 813     <xsl:choose>
 814       <xsl:when test="count(@null)=0">
 815         <xsl:apply-templates select="." mode="dochecksbody">
 816           <xsl:with-param name="name" select="$name"/>
 817         </xsl:apply-templates>
 818       </xsl:when>
 819       <xsl:otherwise>
 820         <xsl:text>  if (</xsl:text>
 821         <xsl:value-of select="$name"/>
 822         <xsl:text> == NULL) {
 823     java_thread = current_thread;
 824   } else {
 825 </xsl:text>
 826         <xsl:apply-templates select="." mode="dochecksbody">
 827           <xsl:with-param name="name" select="$name"/>
 828         </xsl:apply-templates>
 829         <xsl:text>  }
 830 </xsl:text>
 831       </xsl:otherwise>
 832     </xsl:choose>
 833   </xsl:if>
 834 </xsl:template>
 835 
 836 <xsl:template match="jframeID" mode="dochecks">
 837   <xsl:param name="name"/>
 838   <xsl:text>
 839   if (depth &lt; 0) {
 840 </xsl:text>
 841     <xsl:apply-templates select=".." mode="traceError">     
 842       <xsl:with-param name="err">JVMTI_ERROR_ILLEGAL_ARGUMENT</xsl:with-param>
 843       <xsl:with-param name="comment"> - negative depth - jthread = " INT32_FORMAT "</xsl:with-param>
 844       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 845     </xsl:apply-templates>
 846     <xsl:text>
 847   }
 848 </xsl:text>
 849 </xsl:template>
 850 
 851 <xsl:template match="jclass" mode="dochecks">
 852  <xsl:param name="name"/>
 853  <!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
 854  <xsl:if test="count(@method)=0">
 855   <xsl:text>  oop k_mirror = JNIHandles::resolve_external_guard(</xsl:text>  
 856   <xsl:value-of select="$name"/>
 857   <xsl:text>);
 858   if (k_mirror == NULL) {
 859 </xsl:text>
 860     <xsl:apply-templates select=".." mode="traceError">     
 861       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 862       <xsl:with-param name="comment"> - resolved to NULL - jclass = " PTR_FORMAT "</xsl:with-param>
 863       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 864     </xsl:apply-templates>
 865     <xsl:text>
 866   }
 867   if (!k_mirror->is_a(SystemDictionary::Class_klass())) {
 868 </xsl:text>
 869     <xsl:apply-templates select=".." mode="traceError">     
 870       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 871       <xsl:with-param name="comment"> - not a class - jclass = " PTR_FORMAT "</xsl:with-param>
 872       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 873     </xsl:apply-templates>
 874     <xsl:text>
 875   }
 876 </xsl:text>
 877   <xsl:if test="count(@method|@field)=1">
 878     <xsl:text>
 879   if (java_lang_Class::is_primitive(k_mirror)) {
 880 </xsl:text>
 881     <xsl:apply-templates select=".." mode="traceError">     
 882       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 883       <xsl:with-param name="comment"> - is a primitive class - jclass = " PTR_FORMAT "</xsl:with-param>
 884       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 885     </xsl:apply-templates>
 886     <xsl:text>
 887   }
 888   Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
 889   if (k_oop == NULL) {
 890 </xsl:text>
 891     <xsl:apply-templates select=".." mode="traceError">     
 892       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 893       <xsl:with-param name="comment"> - no Klass* - jclass = " PTR_FORMAT "</xsl:with-param>
 894       <xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
 895     </xsl:apply-templates>
 896     <xsl:text>
 897   }
 898 </xsl:text>
 899   </xsl:if>
 900  </xsl:if>
 901 </xsl:template>
 902 
 903 
 904 <xsl:template match="jmethodID" mode="dochecks">
 905   <xsl:param name="name"/>
 906   <xsl:text>  Method* method_oop = Method::checked_resolve_jmethod_id(</xsl:text>
 907   <xsl:value-of select="$name"/>
 908   <xsl:text>);&#xA;</xsl:text>
 909   <xsl:text>  if (method_oop == NULL) {&#xA;</xsl:text>
 910   <xsl:apply-templates select=".." mode="traceError">     
 911     <xsl:with-param name="err">JVMTI_ERROR_INVALID_METHODID</xsl:with-param>
 912     <xsl:with-param name="comment"></xsl:with-param>
 913     <xsl:with-param name="extraValue"></xsl:with-param>
 914   </xsl:apply-templates>
 915   <xsl:text>&#xA;</xsl:text>
 916   <xsl:text>  }&#xA;</xsl:text>
 917   <xsl:if test="count(@native)=1 and contains(@native,'error')">
 918     <xsl:text>  if (method_oop->is_native()) {&#xA;</xsl:text>   
 919     <xsl:text>    return JVMTI_ERROR_NATIVE_METHOD;&#xA;</xsl:text>   
 920     <xsl:text>  }&#xA;</xsl:text>   
 921   </xsl:if>
 922 </xsl:template>
 923 
 924 
 925 <xsl:template match="jfieldID" mode="dochecks">
 926   <xsl:param name="name"/>
 927   <xsl:text>  ResourceMark rm_fdesc(current_thread);&#xA;</xsl:text>
 928   <xsl:text>  fieldDescriptor fdesc;&#xA;</xsl:text>
 929   <xsl:text>  if (!JvmtiEnv::get_field_descriptor(k_oop, </xsl:text>
 930   <xsl:value-of select="$name"/>
 931   <xsl:text>, &amp;fdesc)) {&#xA;</xsl:text>
 932   <xsl:apply-templates select=".." mode="traceError">     
 933     <xsl:with-param name="err">JVMTI_ERROR_INVALID_FIELDID</xsl:with-param>
 934   </xsl:apply-templates>
 935   <xsl:text>&#xA;</xsl:text>
 936   <xsl:text>  }&#xA;</xsl:text>
 937 </xsl:template>
 938 
 939 
 940 <xsl:template match="jint" mode="dochecks">
 941   <xsl:param name="name"/>
 942   <xsl:if test="count(@min)=1">
 943     <xsl:text>  if (</xsl:text>
 944     <xsl:value-of select="$name"/>
 945     <xsl:text> &lt; </xsl:text>
 946     <xsl:value-of select="@min"/>
 947     <xsl:text>) {
 948 </xsl:text>
 949     <xsl:apply-templates select=".." mode="traceError">     
 950       <xsl:with-param name="err">JVMTI_ERROR_ILLEGAL_ARGUMENT</xsl:with-param>
 951     </xsl:apply-templates>
 952     <xsl:text>
 953   }
 954 </xsl:text>
 955   </xsl:if>
 956 </xsl:template>
 957 
 958 <xsl:template match="jobject|jvalue|jthreadGroup|enum|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|struct" mode="dochecks">
 959 </xsl:template>
 960 
 961 <!-- iterate over parameters, stopping if specified is encountered -->
 962 <xsl:template name="traceInValueParamsUpTo">
 963   <xsl:param name="params"/>
 964   <xsl:param name="endParam"></xsl:param>
 965   <xsl:param name="index" select="1"/>
 966   <xsl:variable name="cParam" select="$params[position()=$index]"/>
 967   <xsl:if test="$cParam!=$endParam">
 968     <xsl:apply-templates select="$cParam" mode="traceInValue"/>
 969     <xsl:if test="count($params) &gt; $index">
 970       <xsl:call-template name="traceInValueParamsUpTo">
 971         <xsl:with-param name="params" select="$params"/>
 972         <xsl:with-param name="endParam" select="$endParam"/>
 973         <xsl:with-param name="index" select="1+$index"/>
 974       </xsl:call-template>
 975     </xsl:if>
 976   </xsl:if>
 977 </xsl:template>
 978 
 979 <xsl:template name="traceInFormatParamsUpTo">
 980   <xsl:param name="params"/>
 981   <xsl:param name="endParam"></xsl:param>
 982   <xsl:param name="index" select="1"/>
 983   <xsl:variable name="cParam" select="$params[position()=$index]"/>
 984   <xsl:if test="$cParam!=$endParam">
 985     <xsl:apply-templates select="$cParam" mode="traceInFormat"/>
 986     <xsl:if test="count($params) &gt; $index">
 987       <xsl:call-template name="traceInFormatParamsUpTo">
 988         <xsl:with-param name="params" select="$params"/>
 989         <xsl:with-param name="endParam" select="$endParam"/>
 990         <xsl:with-param name="index" select="1+$index"/>
 991       </xsl:call-template>
 992     </xsl:if>
 993   </xsl:if>
 994 </xsl:template>
 995 
 996 <xsl:template match="parameters" mode="traceInFormat">
 997   <xsl:param name="endParam"></xsl:param>
 998   <xsl:call-template name="traceInFormatParamsUpTo">
 999     <xsl:with-param name="params" select="param"/>
1000     <xsl:with-param name="endParam" select="$endParam"/>
1001   </xsl:call-template>
1002 </xsl:template>
1003 
1004 <xsl:template match="parameters" mode="traceInValue">
1005   <xsl:param name="endParam"></xsl:param>
1006   <xsl:call-template name="traceInValueParamsUpTo">
1007     <xsl:with-param name="params" select="param"/>
1008     <xsl:with-param name="endParam" select="$endParam"/>
1009   </xsl:call-template>
1010 </xsl:template>
1011 
1012 <xsl:template match="param" mode="traceInFormat">
1013   <xsl:apply-templates select="child::*[position()=1]" mode="traceInFormat">
1014     <xsl:with-param name="name" select="@id"/>
1015   </xsl:apply-templates>
1016 </xsl:template>
1017 
1018 <xsl:template match="param" mode="traceInValue">
1019   <xsl:apply-templates select="child::*[position()=1]" mode="traceInValue">
1020     <xsl:with-param name="name" select="@id"/>
1021   </xsl:apply-templates>
1022 </xsl:template>
1023 
1024 <xsl:template match="outptr|outbuf|allocfieldbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="traceInFormat">
1025 </xsl:template>
1026 
1027 <xsl:template match="outptr|outbuf|allocfieldbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="traceInValue">
1028 </xsl:template>
1029 
1030 <xsl:template match="inbuf" mode="traceInFormat">
1031   <xsl:param name="name"/>
1032   <xsl:text> </xsl:text>
1033   <xsl:value-of select="$name"/>
1034   <xsl:variable name="child" select="child::*[position()=1]"/>
1035   <xsl:choose>g
1036     <xsl:when test="name($child)='char'">
1037       <xsl:text>='%s'</xsl:text>
1038     </xsl:when>
1039     <xsl:otherwise>
1040       <xsl:text>=" PTR_FORMAT "</xsl:text>
1041     </xsl:otherwise>
1042   </xsl:choose>
1043 </xsl:template>
1044 
1045 <xsl:template match="inbuf" mode="traceInValue">
1046   <xsl:param name="name"/>
1047   <xsl:text>, </xsl:text>
1048   <xsl:variable name="child" select="child::*[position()=1]"/>
1049   <xsl:choose>
1050     <xsl:when test="name($child)='char'">
1051       <xsl:value-of select="$name"/>
1052     </xsl:when>
1053     <xsl:otherwise>
1054       p2i(<xsl:value-of select="$name"/>)
1055     </xsl:otherwise>
1056   </xsl:choose>
1057 </xsl:template>
1058 
1059 <xsl:template match="ptrtype" mode="traceInFormat">
1060   <xsl:param name="name"/>
1061   <xsl:variable name="child" select="child::*[position()=1]"/>
1062   <xsl:choose>
1063     <xsl:when test="name($child)='jclass'">
1064       <xsl:text> </xsl:text>
1065       <xsl:value-of select="$name"/>
1066       <xsl:text>=" PTR_FORMAT "</xsl:text>
1067     </xsl:when>
1068     <xsl:otherwise>
1069       <xsl:apply-templates select="$child" mode="traceInFormat"/> 
1070     </xsl:otherwise>
1071   </xsl:choose>
1072 </xsl:template>
1073 
1074 <xsl:template match="ptrtype" mode="traceInValue">
1075   <xsl:param name="name"/>
1076   <xsl:variable name="child" select="child::*[position()=1]"/>
1077   <xsl:choose>
1078     <xsl:when test="name($child)='jclass'">
1079       <xsl:text>, </xsl:text>
1080       p2i(<xsl:value-of select="$name"/>)
1081     </xsl:when>
1082     <xsl:otherwise>
1083       <xsl:apply-templates select="$child" mode="traceInValue"/>
1084     </xsl:otherwise>
1085   </xsl:choose> 
1086 </xsl:template>
1087 
1088 <xsl:template match="inptr" mode="traceInFormat">
1089   <xsl:param name="name"/>
1090   <xsl:text> </xsl:text>
1091   <xsl:value-of select="$name"/>
1092   <xsl:text>=" PTR_FORMAT "</xsl:text>
1093 </xsl:template>
1094 
1095 <xsl:template match="inptr" mode="traceInValue">
1096   <xsl:param name="name"/>
1097   <xsl:text>, </xsl:text>
1098   p2i(<xsl:value-of select="$name"/>)
1099 </xsl:template>
1100 
1101 <xsl:template match="jrawMonitorID|jfieldID" mode="traceInFormat">
1102   <xsl:param name="name"/>
1103   <xsl:text> </xsl:text>
1104   <xsl:value-of select="$name"/>
1105   <xsl:text>=%s</xsl:text>
1106 </xsl:template>
1107 
1108 <xsl:template match="jclass" mode="traceInFormat">
1109   <xsl:param name="name"/>
1110   <!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
1111   <xsl:if test="count(@method)=0">
1112     <xsl:text> </xsl:text>
1113     <xsl:value-of select="$name"/>
1114     <xsl:text>=%s</xsl:text>
1115   </xsl:if>
1116 </xsl:template>
1117 
1118 <xsl:template match="jrawMonitorID" mode="traceInValue">
1119   <xsl:param name="name"/>
1120   <xsl:text>, rmonitor->get_name()</xsl:text>
1121 </xsl:template>
1122 
1123 <xsl:template match="jthread" mode="traceInFormat">
1124   <xsl:param name="name"/>
1125   <!-- If we convert and test threads -->
1126   <xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
1127     <xsl:text> </xsl:text>
1128     <xsl:value-of select="$name"/>
1129     <xsl:text>=%s</xsl:text>
1130   </xsl:if>
1131 </xsl:template>
1132 
1133 <xsl:template match="jthread" mode="traceInValue">
1134   <xsl:param name="name"/>
1135   <!-- If we convert and test threads -->
1136   <xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
1137     <xsl:text>, 
1138                     JvmtiTrace::safe_get_thread_name(java_thread)</xsl:text>  
1139   </xsl:if>
1140 </xsl:template>
1141 
1142 <xsl:template match="jframeID" mode="traceInFormat">
1143   <xsl:param name="name"/>
1144   <xsl:text>depth=%d</xsl:text>
1145 </xsl:template>
1146 
1147 <xsl:template match="jframeID" mode="traceInValue">
1148   <xsl:param name="name"/>
1149   <xsl:text>, </xsl:text>
1150   <xsl:value-of select="$name"/>
1151 </xsl:template>
1152 
1153 <xsl:template match="jclass" mode="traceInValue">
1154   <!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
1155   <xsl:if test="count(@method)=0">
1156     <xsl:text>, 
1157                     JvmtiTrace::get_class_name(k_mirror)</xsl:text>
1158   </xsl:if>
1159 </xsl:template>
1160 
1161 <xsl:template match="jmethodID" mode="traceInFormat">
1162   <xsl:param name="name"/>
1163   <xsl:text> </xsl:text>
1164   <xsl:value-of select="$name"/>
1165   <xsl:text>=%s.%s</xsl:text>
1166 </xsl:template>
1167 
1168 <xsl:template match="jmethodID" mode="traceInValue">
1169   <xsl:param name="name"/>
1170   <xsl:text>, 
1171                     method_oop == NULL? "NULL" : method_oop->klass_name()->as_C_string(),
1172                     method_oop == NULL? "NULL" : method_oop->name()->as_C_string()
1173              </xsl:text>
1174 </xsl:template>
1175 
1176 <xsl:template match="jfieldID" mode="traceInValue">
1177   <xsl:param name="name"/>
1178   <xsl:text>, fdesc.name()->as_C_string()</xsl:text>
1179 </xsl:template>
1180 
1181 <xsl:template match="enum" mode="traceInFormat">
1182   <xsl:param name="name"/>
1183   <xsl:text> </xsl:text>
1184   <xsl:value-of select="$name"/>
1185   <xsl:text>=%d:%s</xsl:text>
1186 </xsl:template>
1187 
1188 <xsl:template match="enum" mode="traceInValue">
1189   <xsl:param name="name"/>
1190   <xsl:text>, </xsl:text>
1191   <xsl:value-of select="$name"/>
1192   <xsl:text>, 
1193                     </xsl:text>
1194   <xsl:choose>
1195     <xsl:when test=".='jvmtiError'">
1196       <xsl:text>JvmtiUtil::error_name(</xsl:text>
1197       <xsl:value-of select="$name"/>
1198       <xsl:text>)
1199 </xsl:text>
1200     </xsl:when>
1201     <xsl:otherwise>
1202       <xsl:choose>
1203         <xsl:when test=".='jvmtiEvent'">
1204           <xsl:text>JvmtiTrace::event_name(</xsl:text>
1205           <xsl:value-of select="$name"/>
1206           <xsl:text>)
1207         </xsl:text>
1208       </xsl:when>
1209       <xsl:otherwise>
1210         <xsl:text>JvmtiTrace::enum_name(</xsl:text>
1211         <xsl:value-of select="."/>
1212         <xsl:text>ConstantNames, </xsl:text>
1213         <xsl:value-of select="."/>
1214         <xsl:text>ConstantValues, </xsl:text>
1215         <xsl:value-of select="$name"/>
1216         <xsl:text>)</xsl:text>
1217       </xsl:otherwise>
1218     </xsl:choose>
1219     </xsl:otherwise>
1220   </xsl:choose>
1221 </xsl:template>
1222 
1223 <xsl:template match="jint" mode="traceInFormat">
1224   <xsl:param name="name"/>
1225   <xsl:text> </xsl:text>
1226   <xsl:value-of select="$name"/>
1227   <xsl:text>=" INT32_FORMAT "</xsl:text>
1228 </xsl:template>
1229 
1230 <xsl:template match="jlocation" mode="traceInFormat">
1231   <xsl:param name="name"/>
1232   <xsl:text> </xsl:text>
1233   <xsl:value-of select="$name"/>
1234   <xsl:text>=" INT64_FORMAT "</xsl:text>
1235 </xsl:template>
1236 
1237 <xsl:template match="jlong" mode="traceInFormat">
1238   <xsl:param name="name"/>
1239   <xsl:text> </xsl:text>
1240   <xsl:value-of select="$name"/>
1241   <xsl:text>=" INT64_FORMAT "</xsl:text>
1242 </xsl:template>
1243 
1244 <xsl:template match="size_t" mode="traceInFormat">
1245   <xsl:param name="name"/>
1246   <xsl:text> </xsl:text>
1247   <xsl:value-of select="$name"/>
1248   <xsl:text>=0x%zx</xsl:text>
1249 </xsl:template>
1250 
1251 <xsl:template match="jfloat|jdouble" mode="traceInFormat">
1252   <xsl:param name="name"/>
1253   <xsl:text> </xsl:text>
1254   <xsl:value-of select="$name"/>
1255   <xsl:text>=%f</xsl:text>
1256 </xsl:template>
1257 
1258 <xsl:template match="char" mode="traceInFormat">
1259   <xsl:param name="name"/>
1260   <xsl:text> </xsl:text>
1261   <xsl:value-of select="$name"/>
1262   <xsl:text>=%c</xsl:text>
1263 </xsl:template>
1264 
1265 <xsl:template match="uchar|jchar" mode="traceInFormat">
1266   <xsl:param name="name"/>
1267   <xsl:text> </xsl:text>
1268   <xsl:value-of select="$name"/>
1269   <xsl:text>=0x%x</xsl:text>
1270 </xsl:template>
1271 
1272 <xsl:template match="jint|jlocation|jchar|jlong|jfloat|jdouble|char|uchar|size_t" mode="traceInValue">
1273   <xsl:param name="name"/>
1274   <xsl:text>, </xsl:text>
1275   <xsl:value-of select="$name"/>
1276 </xsl:template>
1277 
1278 
1279 <xsl:template match="jboolean" mode="traceInFormat">
1280   <xsl:param name="name"/>
1281   <xsl:text> </xsl:text>
1282   <xsl:value-of select="$name"/>
1283   <xsl:text>=%s</xsl:text>
1284 </xsl:template>
1285 
1286 <xsl:template match="jboolean" mode="traceInValue">
1287   <xsl:param name="name"/>
1288   <xsl:text>, </xsl:text>
1289   <xsl:value-of select="$name"/>
1290   <xsl:text>? "true" : "false"</xsl:text>
1291 </xsl:template>
1292 
1293 <xsl:template match="jobject|jvalue|jthreadGroup|void|struct" mode="traceInFormat">
1294 </xsl:template>
1295 
1296 <xsl:template match="jobject|jvalue|jthreadGroup|void|struct" mode="traceInValue">
1297 </xsl:template>
1298 
1299 
1300 
1301 </xsl:stylesheet>