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