1 <?xml version="1.0"?> 
   2 <!--
   3  Copyright (c) 2002, 2014, 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 "utilities/macros.hpp"
  41 #if INCLUDE_JVMTI
  42 # include "oops/oop.inline.hpp"
  43 # include "prims/jvmtiEnter.hpp"
  44 # include "prims/jvmtiRawMonitor.hpp"
  45 # include "prims/jvmtiUtil.hpp"
  46 
  47 // There are known-bad format/arg pairings in the code generated by this file.
  48 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  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>  }
 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>    tty->print_cr("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           tty->print_cr("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           tty->print_cr("JVMTI [-] %s %s",  func_name, 
 492                     JvmtiUtil::error_name(JVMTI_ERROR_WRONG_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*)ThreadLocalStorage::thread(); </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           tty->print_cr("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()!=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           tty->print_cr("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*)ThreadLocalStorage::thread(); </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           tty->print_cr("JVMTI [%s] %s %s  env=%d",  curr_thread_name, func_name, 
 547                     JvmtiUtil::error_name(JVMTI_ERROR_INVALID_ENVIRONMENT), 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*)ThreadLocalStorage::thread();</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*)ThreadLocalStorage::thread();
 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;
 636   const char *curr_thread_name;
 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         tty->print_cr("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     tty->print_cr("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     tty->print_cr("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>          tty->print_cr("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 0x%x</xsl:with-param>
 764       <xsl:with-param name="extraValue">, 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>    oop thread_oop = JNIHandles::resolve_external_guard(</xsl:text>
 774     <xsl:value-of select="$name"/>
 775     <xsl:text>);
 776     if (thread_oop == NULL) {
 777 </xsl:text>
 778     <xsl:apply-templates select=".." mode="traceError">     
 779       <xsl:with-param name="err">JVMTI_ERROR_INVALID_THREAD</xsl:with-param>
 780       <xsl:with-param name="comment"> - jthread resolved to NULL - jthread = 0x%x</xsl:with-param>
 781       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 782     </xsl:apply-templates>
 783     <xsl:text>
 784     }
 785     if (!thread_oop-&gt;is_a(SystemDictionary::Thread_klass())) {
 786 </xsl:text>
 787     <xsl:apply-templates select=".." mode="traceError">     
 788       <xsl:with-param name="err">JVMTI_ERROR_INVALID_THREAD</xsl:with-param>
 789       <xsl:with-param name="comment"> - oop is not a thread - jthread = 0x%x</xsl:with-param>
 790       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 791     </xsl:apply-templates>
 792     <xsl:text>
 793     }
 794     java_thread = java_lang_Thread::thread(thread_oop); 
 795     if (java_thread == NULL) {
 796 </xsl:text>
 797     <xsl:apply-templates select=".." mode="traceError">     
 798       <xsl:with-param name="err">
 799         <xsl:text>JVMTI_ERROR_THREAD_NOT_ALIVE</xsl:text>
 800       </xsl:with-param>
 801       <xsl:with-param name="comment"> - not a Java thread - jthread = 0x%x</xsl:with-param>
 802       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 803     </xsl:apply-templates>
 804     <xsl:text>
 805     }
 806 </xsl:text>  
 807 </xsl:template>
 808 
 809 <xsl:template match="jthread" mode="dochecks">
 810   <xsl:param name="name"/>
 811   <!-- If we convert and test threads -->
 812   <xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
 813     <xsl:text>  JavaThread* java_thread;
 814 </xsl:text>
 815     <xsl:choose>
 816       <xsl:when test="count(@null)=0">
 817         <xsl:apply-templates select="." mode="dochecksbody">
 818           <xsl:with-param name="name" select="$name"/>
 819         </xsl:apply-templates>
 820       </xsl:when>
 821       <xsl:otherwise>
 822         <xsl:text>  if (</xsl:text>
 823         <xsl:value-of select="$name"/>
 824         <xsl:text> == NULL) {
 825     java_thread = current_thread;
 826   } else {
 827 </xsl:text>
 828         <xsl:apply-templates select="." mode="dochecksbody">
 829           <xsl:with-param name="name" select="$name"/>
 830         </xsl:apply-templates>
 831         <xsl:text>  }
 832 </xsl:text>
 833       </xsl:otherwise>
 834     </xsl:choose>
 835   </xsl:if>
 836 </xsl:template>
 837 
 838 <xsl:template match="jframeID" mode="dochecks">
 839   <xsl:param name="name"/>
 840   <xsl:text>
 841   if (depth &lt; 0) {
 842 </xsl:text>
 843     <xsl:apply-templates select=".." mode="traceError">     
 844       <xsl:with-param name="err">JVMTI_ERROR_ILLEGAL_ARGUMENT</xsl:with-param>
 845       <xsl:with-param name="comment"> - negative depth - jthread = 0x%x</xsl:with-param>
 846       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 847     </xsl:apply-templates>
 848     <xsl:text>
 849   }
 850 </xsl:text>
 851 </xsl:template>
 852 
 853 <xsl:template match="jclass" mode="dochecks">
 854  <xsl:param name="name"/>
 855  <!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
 856  <xsl:if test="count(@method)=0">
 857   <xsl:text>  oop k_mirror = JNIHandles::resolve_external_guard(</xsl:text>  
 858   <xsl:value-of select="$name"/>
 859   <xsl:text>);
 860   if (k_mirror == NULL) {
 861 </xsl:text>
 862     <xsl:apply-templates select=".." mode="traceError">     
 863       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 864       <xsl:with-param name="comment"> - resolved to NULL - jclass = 0x%x</xsl:with-param>
 865       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 866     </xsl:apply-templates>
 867     <xsl:text>
 868   }
 869   if (!k_mirror->is_a(SystemDictionary::Class_klass())) {
 870 </xsl:text>
 871     <xsl:apply-templates select=".." mode="traceError">     
 872       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 873       <xsl:with-param name="comment"> - not a class - jclass = 0x%x</xsl:with-param>
 874       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 875     </xsl:apply-templates>
 876     <xsl:text>
 877   }
 878 </xsl:text>
 879   <xsl:if test="count(@method|@field)=1">
 880     <xsl:text>
 881   if (java_lang_Class::is_primitive(k_mirror)) {
 882 </xsl:text>
 883     <xsl:apply-templates select=".." mode="traceError">     
 884       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 885       <xsl:with-param name="comment"> - is a primitive class - jclass = 0x%x</xsl:with-param>
 886       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 887     </xsl:apply-templates>
 888     <xsl:text>
 889   }
 890   Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
 891   if (k_oop == NULL) {
 892 </xsl:text>
 893     <xsl:apply-templates select=".." mode="traceError">     
 894       <xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
 895       <xsl:with-param name="comment"> - no Klass* - jclass = 0x%x</xsl:with-param>
 896       <xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
 897     </xsl:apply-templates>
 898     <xsl:text>
 899   }
 900 </xsl:text>
 901   </xsl:if>
 902  </xsl:if>
 903 </xsl:template>
 904 
 905 
 906 <xsl:template match="jmethodID" mode="dochecks">
 907   <xsl:param name="name"/>
 908   <xsl:text>  Method* method_oop = Method::checked_resolve_jmethod_id(</xsl:text>
 909   <xsl:value-of select="$name"/>
 910   <xsl:text>);&#xA;</xsl:text>
 911   <xsl:text>  if (method_oop == NULL) {&#xA;</xsl:text>
 912   <xsl:apply-templates select=".." mode="traceError">     
 913     <xsl:with-param name="err">JVMTI_ERROR_INVALID_METHODID</xsl:with-param>
 914     <xsl:with-param name="comment"></xsl:with-param>
 915     <xsl:with-param name="extraValue"></xsl:with-param>
 916   </xsl:apply-templates>
 917   <xsl:text>&#xA;</xsl:text>
 918   <xsl:text>  }&#xA;</xsl:text>
 919   <xsl:if test="count(@native)=1 and contains(@native,'error')">
 920     <xsl:text>  if (method_oop->is_native()) {&#xA;</xsl:text>   
 921     <xsl:text>    return JVMTI_ERROR_NATIVE_METHOD;&#xA;</xsl:text>   
 922     <xsl:text>  }&#xA;</xsl:text>   
 923   </xsl:if>
 924 </xsl:template>
 925 
 926 
 927 <xsl:template match="jfieldID" mode="dochecks">
 928   <xsl:param name="name"/>
 929   <xsl:text>  ResourceMark rm_fdesc(current_thread);&#xA;</xsl:text>
 930   <xsl:text>  fieldDescriptor fdesc;&#xA;</xsl:text>
 931   <xsl:text>  if (!JvmtiEnv::get_field_descriptor(k_oop, </xsl:text>
 932   <xsl:value-of select="$name"/>
 933   <xsl:text>, &amp;fdesc)) {&#xA;</xsl:text>
 934   <xsl:apply-templates select=".." mode="traceError">     
 935     <xsl:with-param name="err">JVMTI_ERROR_INVALID_FIELDID</xsl:with-param>
 936   </xsl:apply-templates>
 937   <xsl:text>&#xA;</xsl:text>
 938   <xsl:text>  }&#xA;</xsl:text>
 939 </xsl:template>
 940 
 941 
 942 <xsl:template match="jint" mode="dochecks">
 943   <xsl:param name="name"/>
 944   <xsl:if test="count(@min)=1">
 945     <xsl:text>  if (</xsl:text>
 946     <xsl:value-of select="$name"/>
 947     <xsl:text> &lt; </xsl:text>
 948     <xsl:value-of select="@min"/>
 949     <xsl:text>) {
 950 </xsl:text>
 951     <xsl:apply-templates select=".." mode="traceError">     
 952       <xsl:with-param name="err">JVMTI_ERROR_ILLEGAL_ARGUMENT</xsl:with-param>
 953     </xsl:apply-templates>
 954     <xsl:text>
 955   }
 956 </xsl:text>
 957   </xsl:if>
 958 </xsl:template>
 959 
 960 <xsl:template match="jobject|jvalue|jthreadGroup|enum|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|struct" mode="dochecks">
 961 </xsl:template>
 962 
 963 <!-- iterate over parameters, stopping if specified is encountered -->
 964 <xsl:template name="traceInValueParamsUpTo">
 965   <xsl:param name="params"/>
 966   <xsl:param name="endParam"></xsl:param>
 967   <xsl:param name="index" select="1"/>
 968   <xsl:variable name="cParam" select="$params[position()=$index]"/>
 969   <xsl:if test="$cParam!=$endParam">
 970     <xsl:apply-templates select="$cParam" mode="traceInValue"/>
 971     <xsl:if test="count($params) &gt; $index">
 972       <xsl:call-template name="traceInValueParamsUpTo">
 973         <xsl:with-param name="params" select="$params"/>
 974         <xsl:with-param name="endParam" select="$endParam"/>
 975         <xsl:with-param name="index" select="1+$index"/>
 976       </xsl:call-template>
 977     </xsl:if>
 978   </xsl:if>
 979 </xsl:template>
 980 
 981 <xsl:template name="traceInFormatParamsUpTo">
 982   <xsl:param name="params"/>
 983   <xsl:param name="endParam"></xsl:param>
 984   <xsl:param name="index" select="1"/>
 985   <xsl:variable name="cParam" select="$params[position()=$index]"/>
 986   <xsl:if test="$cParam!=$endParam">
 987     <xsl:apply-templates select="$cParam" mode="traceInFormat"/>
 988     <xsl:if test="count($params) &gt; $index">
 989       <xsl:call-template name="traceInFormatParamsUpTo">
 990         <xsl:with-param name="params" select="$params"/>
 991         <xsl:with-param name="endParam" select="$endParam"/>
 992         <xsl:with-param name="index" select="1+$index"/>
 993       </xsl:call-template>
 994     </xsl:if>
 995   </xsl:if>
 996 </xsl:template>
 997 
 998 <xsl:template match="parameters" mode="traceInFormat">
 999   <xsl:param name="endParam"></xsl:param>
1000   <xsl:call-template name="traceInFormatParamsUpTo">
1001     <xsl:with-param name="params" select="param"/>
1002     <xsl:with-param name="endParam" select="$endParam"/>
1003   </xsl:call-template>
1004 </xsl:template>
1005 
1006 <xsl:template match="parameters" mode="traceInValue">
1007   <xsl:param name="endParam"></xsl:param>
1008   <xsl:call-template name="traceInValueParamsUpTo">
1009     <xsl:with-param name="params" select="param"/>
1010     <xsl:with-param name="endParam" select="$endParam"/>
1011   </xsl:call-template>
1012 </xsl:template>
1013 
1014 <xsl:template match="param" mode="traceInFormat">
1015   <xsl:apply-templates select="child::*[position()=1]" mode="traceInFormat">
1016     <xsl:with-param name="name" select="@id"/>
1017   </xsl:apply-templates>
1018 </xsl:template>
1019 
1020 <xsl:template match="param" mode="traceInValue">
1021   <xsl:apply-templates select="child::*[position()=1]" mode="traceInValue">
1022     <xsl:with-param name="name" select="@id"/>
1023   </xsl:apply-templates>
1024 </xsl:template>
1025 
1026 <xsl:template match="outptr|outbuf|allocfieldbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="traceInFormat">
1027 </xsl:template>
1028 
1029 <xsl:template match="outptr|outbuf|allocfieldbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="traceInValue">
1030 </xsl:template>
1031 
1032 <xsl:template match="inbuf" mode="traceInFormat">
1033   <xsl:param name="name"/>
1034   <xsl:text> </xsl:text>
1035   <xsl:value-of select="$name"/>
1036   <xsl:variable name="child" select="child::*[position()=1]"/>
1037   <xsl:choose>
1038     <xsl:when test="name($child)='char'">
1039       <xsl:text>='%s'</xsl:text>
1040     </xsl:when>
1041     <xsl:otherwise>
1042       <xsl:text>=0x%x</xsl:text>
1043     </xsl:otherwise>
1044   </xsl:choose>
1045 </xsl:template>
1046 
1047 <xsl:template match="inbuf" mode="traceInValue">
1048   <xsl:param name="name"/>
1049   <xsl:text>, </xsl:text>
1050   <xsl:value-of select="$name"/>
1051 </xsl:template>
1052 
1053 <xsl:template match="ptrtype" mode="traceInFormat">
1054   <xsl:param name="name"/>
1055   <xsl:variable name="child" select="child::*[position()=1]"/>
1056   <xsl:choose>
1057     <xsl:when test="name($child)='jclass'">
1058       <xsl:text> </xsl:text>
1059       <xsl:value-of select="$name"/>
1060       <xsl:text>=0x%x</xsl:text>
1061     </xsl:when>
1062     <xsl:otherwise>
1063       <xsl:apply-templates select="$child" mode="traceInFormat"/> 
1064     </xsl:otherwise>
1065   </xsl:choose>
1066 </xsl:template>
1067 
1068 <xsl:template match="ptrtype" mode="traceInValue">
1069   <xsl:param name="name"/>
1070   <xsl:variable name="child" select="child::*[position()=1]"/>
1071   <xsl:choose>
1072     <xsl:when test="name($child)='jclass'">
1073       <xsl:text>, </xsl:text>
1074       <xsl:value-of select="$name"/>
1075     </xsl:when>
1076     <xsl:otherwise>
1077       <xsl:apply-templates select="$child" mode="traceInValue"/>
1078     </xsl:otherwise>
1079   </xsl:choose> 
1080 </xsl:template>
1081 
1082 <xsl:template match="inptr" mode="traceInFormat">
1083   <xsl:param name="name"/>
1084   <xsl:text> </xsl:text>
1085   <xsl:value-of select="$name"/>
1086   <xsl:text>=0x%x</xsl:text>
1087 </xsl:template>
1088 
1089 <xsl:template match="inptr" mode="traceInValue">
1090   <xsl:param name="name"/>
1091   <xsl:text>, </xsl:text>
1092   <xsl:value-of select="$name"/>
1093 </xsl:template>
1094 
1095 <xsl:template match="jrawMonitorID|jfieldID" mode="traceInFormat">
1096   <xsl:param name="name"/>
1097   <xsl:text> </xsl:text>
1098   <xsl:value-of select="$name"/>
1099   <xsl:text>=%s</xsl:text>
1100 </xsl:template>
1101 
1102 <xsl:template match="jclass" mode="traceInFormat">
1103   <xsl:param name="name"/>
1104   <!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
1105   <xsl:if test="count(@method)=0">
1106     <xsl:text> </xsl:text>
1107     <xsl:value-of select="$name"/>
1108     <xsl:text>=%s</xsl:text>
1109   </xsl:if>
1110 </xsl:template>
1111 
1112 <xsl:template match="jrawMonitorID" mode="traceInValue">
1113   <xsl:param name="name"/>
1114   <xsl:text>, rmonitor->get_name()</xsl:text>
1115 </xsl:template>
1116 
1117 <xsl:template match="jthread" mode="traceInFormat">
1118   <xsl:param name="name"/>
1119   <!-- If we convert and test threads -->
1120   <xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
1121     <xsl:text> </xsl:text>
1122     <xsl:value-of select="$name"/>
1123     <xsl:text>=%s</xsl:text>
1124   </xsl:if>
1125 </xsl:template>
1126 
1127 <xsl:template match="jthread" mode="traceInValue">
1128   <xsl:param name="name"/>
1129   <!-- If we convert and test threads -->
1130   <xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
1131     <xsl:text>, 
1132                     JvmtiTrace::safe_get_thread_name(java_thread)</xsl:text>  
1133   </xsl:if>
1134 </xsl:template>
1135 
1136 <xsl:template match="jframeID" mode="traceInFormat">
1137   <xsl:param name="name"/>
1138   <xsl:text>depth=%d</xsl:text>
1139 </xsl:template>
1140 
1141 <xsl:template match="jframeID" mode="traceInValue">
1142   <xsl:param name="name"/>
1143   <xsl:text>, </xsl:text>
1144   <xsl:value-of select="$name"/>
1145 </xsl:template>
1146 
1147 <xsl:template match="jclass" mode="traceInValue">
1148   <!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
1149   <xsl:if test="count(@method)=0">
1150     <xsl:text>, 
1151                     JvmtiTrace::get_class_name(k_mirror)</xsl:text>
1152   </xsl:if>
1153 </xsl:template>
1154 
1155 <xsl:template match="jmethodID" mode="traceInFormat">
1156   <xsl:param name="name"/>
1157   <xsl:text> </xsl:text>
1158   <xsl:value-of select="$name"/>
1159   <xsl:text>=%s.%s</xsl:text>
1160 </xsl:template>
1161 
1162 <xsl:template match="jmethodID" mode="traceInValue">
1163   <xsl:param name="name"/>
1164   <xsl:text>, 
1165                     method_oop == NULL? "NULL" : method_oop->klass_name()->as_C_string(),
1166                     method_oop == NULL? "NULL" : method_oop->name()->as_C_string()
1167              </xsl:text>
1168 </xsl:template>
1169 
1170 <xsl:template match="jfieldID" mode="traceInValue">
1171   <xsl:param name="name"/>
1172   <xsl:text>, fdesc.name()->as_C_string()</xsl:text>
1173 </xsl:template>
1174 
1175 <xsl:template match="enum" mode="traceInFormat">
1176   <xsl:param name="name"/>
1177   <xsl:text> </xsl:text>
1178   <xsl:value-of select="$name"/>
1179   <xsl:text>=%d:%s</xsl:text>
1180 </xsl:template>
1181 
1182 <xsl:template match="enum" mode="traceInValue">
1183   <xsl:param name="name"/>
1184   <xsl:text>, </xsl:text>
1185   <xsl:value-of select="$name"/>
1186   <xsl:text>, 
1187                     </xsl:text>
1188   <xsl:choose>
1189     <xsl:when test=".='jvmtiError'">
1190       <xsl:text>JvmtiUtil::error_name(</xsl:text>
1191       <xsl:value-of select="$name"/>
1192       <xsl:text>)
1193 </xsl:text>
1194     </xsl:when>
1195     <xsl:otherwise>
1196       <xsl:choose>
1197         <xsl:when test=".='jvmtiEvent'">
1198           <xsl:text>JvmtiTrace::event_name(</xsl:text>
1199           <xsl:value-of select="$name"/>
1200           <xsl:text>)
1201         </xsl:text>
1202       </xsl:when>
1203       <xsl:otherwise>
1204         <xsl:text>JvmtiTrace::enum_name(</xsl:text>
1205         <xsl:value-of select="."/>
1206         <xsl:text>ConstantNames, </xsl:text>
1207         <xsl:value-of select="."/>
1208         <xsl:text>ConstantValues, </xsl:text>
1209         <xsl:value-of select="$name"/>
1210         <xsl:text>)</xsl:text>
1211       </xsl:otherwise>
1212     </xsl:choose>
1213     </xsl:otherwise>
1214   </xsl:choose>
1215 </xsl:template>
1216 
1217 <xsl:template match="jint|jlocation" mode="traceInFormat">
1218   <xsl:param name="name"/>
1219   <xsl:text> </xsl:text>
1220   <xsl:value-of select="$name"/>
1221   <xsl:text>=%d</xsl:text>
1222 </xsl:template>
1223 
1224 <xsl:template match="jlong" mode="traceInFormat">
1225   <xsl:param name="name"/>
1226   <xsl:text> </xsl:text>
1227   <xsl:value-of select="$name"/>
1228   <xsl:text>=%ld</xsl:text>
1229 </xsl:template>
1230 
1231 <xsl:template match="size_t" mode="traceInFormat">
1232   <xsl:param name="name"/>
1233   <xsl:text> </xsl:text>
1234   <xsl:value-of select="$name"/>
1235   <xsl:text>=0x%zx</xsl:text>
1236 </xsl:template>
1237 
1238 <xsl:template match="jfloat|jdouble" mode="traceInFormat">
1239   <xsl:param name="name"/>
1240   <xsl:text> </xsl:text>
1241   <xsl:value-of select="$name"/>
1242   <xsl:text>=%f</xsl:text>
1243 </xsl:template>
1244 
1245 <xsl:template match="char" mode="traceInFormat">
1246   <xsl:param name="name"/>
1247   <xsl:text> </xsl:text>
1248   <xsl:value-of select="$name"/>
1249   <xsl:text>=%c</xsl:text>
1250 </xsl:template>
1251 
1252 <xsl:template match="uchar|jchar" mode="traceInFormat">
1253   <xsl:param name="name"/>
1254   <xsl:text> </xsl:text>
1255   <xsl:value-of select="$name"/>
1256   <xsl:text>=0x%x</xsl:text>
1257 </xsl:template>
1258 
1259 <xsl:template match="jint|jlocation|jchar|jlong|jfloat|jdouble|char|uchar|size_t" mode="traceInValue">
1260   <xsl:param name="name"/>
1261   <xsl:text>, </xsl:text>
1262   <xsl:value-of select="$name"/>
1263 </xsl:template>
1264 
1265 
1266 <xsl:template match="jboolean" mode="traceInFormat">
1267   <xsl:param name="name"/>
1268   <xsl:text> </xsl:text>
1269   <xsl:value-of select="$name"/>
1270   <xsl:text>=%s</xsl:text>
1271 </xsl:template>
1272 
1273 <xsl:template match="jboolean" mode="traceInValue">
1274   <xsl:param name="name"/>
1275   <xsl:text>, </xsl:text>
1276   <xsl:value-of select="$name"/>
1277   <xsl:text>? "true" : "false"</xsl:text>
1278 </xsl:template>
1279 
1280 <xsl:template match="jobject|jvalue|jthreadGroup|void|struct" mode="traceInFormat">
1281 </xsl:template>
1282 
1283 <xsl:template match="jobject|jvalue|jthreadGroup|void|struct" mode="traceInValue">
1284 </xsl:template>
1285 
1286 
1287 
1288 </xsl:stylesheet>