3
Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
28
<xsl:import href="jvmtiLib.xsl"/>
30
<xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
32
<xsl:param name="trace"></xsl:param>
33
<xsl:param name="interface"></xsl:param>
36
<xsl:template match="specification">
37
<xsl:call-template name="sourceHeader"/>
39
# include "precompiled.hpp"
40
# include "classfile/javaClasses.inline.hpp"
41
# include "classfile/vmClasses.hpp"
42
# include "memory/resourceArea.hpp"
43
# include "utilities/macros.hpp"
45
# include "logging/log.hpp"
46
# include "oops/oop.inline.hpp"
47
# include "prims/jvmtiEnter.inline.hpp"
48
# include "prims/jvmtiRawMonitor.hpp"
49
# include "prims/jvmtiUtil.hpp"
50
# include "runtime/fieldDescriptor.inline.hpp"
51
# include "runtime/jniHandles.hpp"
52
# include "runtime/thread.inline.hpp"
53
# include "runtime/threads.hpp"
54
# include "runtime/threadSMR.hpp"
58
<xsl:if test="$trace = 'Trace'">
64
<xsl:if test="$trace != 'Trace'">
68
const char* JvmtiUtil::_error_names[] = {
70
<xsl:call-template name="fillEntityName">
71
<xsl:with-param name="entities" select="errorsection/errorcategory/errorid"/>
78
const bool JvmtiUtil::_event_threaded[] = {
80
<xsl:call-template name="fillEventThreaded">
81
<xsl:with-param name="entities" select="eventsection/event"/>
87
<xsl:call-template name="eventCapabilitiesTest"/>
90
<xsl:if test="$trace = 'Trace'">
92
<!-- all this just to return the highest event number -->
93
<xsl:variable name="maxEvent">
94
<xsl:for-each select="eventsection/event">
95
<xsl:variable name="mynum" select="@num"/>
96
<xsl:if test="count(../../eventsection/event[@num > $mynum]) = 0">
97
<xsl:value-of select="@num"/>
102
<xsl:text>jbyte JvmtiTrace::_event_trace_flags[</xsl:text>
103
<xsl:value-of select="1+$maxEvent"/>
106
jint JvmtiTrace::_max_event_index = </xsl:text>
107
<xsl:value-of select="$maxEvent"/>
111
const char* JvmtiTrace::_event_names[] = {
113
<xsl:call-template name="fillEntityName">
114
<xsl:with-param name="entities" select="eventsection/event"/>
119
<xsl:apply-templates select="//constants[@kind='enum']"/>
121
<xsl:apply-templates select="functionsection"/>
123
<xsl:if test="$trace='Trace'">
125
#endif /*JVMTI_TRACE */
131
<xsl:template match="constants">
135
<xsl:value-of select="@label"/>
137
const char* </xsl:text>
138
<xsl:value-of select="@id"/>
139
<xsl:text>ConstantNames[] = {
141
<xsl:apply-templates select="constant" mode="constname"/>
146
<xsl:value-of select="@label"/>
149
<xsl:value-of select="@id"/>
150
<xsl:text>ConstantValues[] = {
152
<xsl:apply-templates select="constant" mode="constvalue"/>
159
<xsl:template match="constant" mode="constname">
160
<xsl:text> "</xsl:text>
161
<xsl:value-of select="@id"/>
166
<xsl:template match="constant" mode="constvalue">
167
<xsl:text> </xsl:text>
168
<xsl:value-of select="@num"/>
173
<xsl:template name="eventCapabilitiesTest">
176
// Check Event Capabilities
177
bool JvmtiUtil::has_event_capability(jvmtiEvent event_type, const jvmtiCapabilities* capabilities_ptr) {
178
switch (event_type) {
180
<xsl:for-each select="//eventsection/event">
181
<xsl:variable name="capa" select="capabilities/required"/>
182
<xsl:if test="count($capa)">
183
<xsl:text> case </xsl:text>
184
<xsl:value-of select="@const"/>
186
return capabilities_ptr-></xsl:text>
187
<xsl:value-of select="$capa/@id"/>
192
<xsl:text> default: break; }
193
// if it does not have a capability it is required
200
<xsl:template match="functionsection">
201
<xsl:if test="$trace='Trace'">
203
<!-- all this just to return the highest function number -->
204
<xsl:variable name="maxFunction">
205
<xsl:for-each select="category/function">
206
<xsl:variable name="mynum" select="@num"/>
207
<xsl:if test="count(../../category/function[@num > $mynum]) = 0">
208
<xsl:value-of select="@num"/>
213
<xsl:text>jbyte JvmtiTrace::_trace_flags[</xsl:text>
214
<xsl:value-of select="1+$maxFunction"/>
217
jint JvmtiTrace::_max_function_index = </xsl:text>
218
<xsl:value-of select="$maxFunction"/>
222
const char* JvmtiTrace::_function_names[] = {
224
<xsl:call-template name="fillEntityName">
225
<xsl:with-param name="entities" select="category/function"/>
231
short JvmtiTrace::_exclude_functions[] = {
233
<xsl:apply-templates select="category/function" mode="notrace">
234
<xsl:sort select="@num"/>
235
</xsl:apply-templates>
246
<xsl:apply-templates select="category" mode="wrapper"/>
248
} /* end extern "C" */
250
// JVMTI API functions
251
struct jvmtiInterface_1_ jvmti</xsl:text>
252
<xsl:value-of select="$trace"/>
253
<xsl:text>_Interface = {
256
<xsl:call-template name="fillFuncStruct">
257
<xsl:with-param name="funcs" select="category/function[count(@hide)=0]"/>
262
#endif // INCLUDE_JVMTI
266
<xsl:template match="function" mode="functionid">
267
<xsl:text>jvmti</xsl:text>
268
<xsl:value-of select="$trace"/>
269
<xsl:text>_</xsl:text>
270
<xsl:value-of select="@id"/>
273
<xsl:template name="fillFuncStructDoit">
274
<xsl:param name="func"/>
275
<xsl:param name="index"/>
276
<xsl:text> /* </xsl:text>
277
<xsl:number value="$index" format=" 1"/>
278
<xsl:text> : </xsl:text>
280
<xsl:when test="count($func)=1">
281
<xsl:value-of select="$func/synopsis"/>
284
<xsl:apply-templates select="$func" mode="functionid"/>
287
<xsl:text> RESERVED */
293
<!-- generic function iterator applied to the function structure -->
294
<xsl:template name="fillFuncStruct">
295
<xsl:param name="funcs"/>
296
<xsl:param name="index" select="1"/>
297
<xsl:call-template name="fillFuncStructDoit">
298
<xsl:with-param name="func" select="$funcs[@num=$index]"/>
299
<xsl:with-param name="index" select="$index"/>
301
<xsl:if test="count($funcs[@num > $index]) > 0">
304
<xsl:call-template name="fillFuncStruct">
305
<xsl:with-param name="funcs" select="$funcs"/>
306
<xsl:with-param name="index" select="1+$index"/>
311
<xsl:template name="fillEntityNameDoit">
312
<xsl:param name="entity"/>
313
<xsl:param name="index"/>
315
<xsl:when test="count($entity) > 0">
316
<xsl:text> "</xsl:text>
317
<xsl:value-of select="$entity[position()=1]/@id"/>
318
<xsl:text>"</xsl:text>
321
<xsl:text> nullptr</xsl:text>
326
<!-- generic entity (with id and num) iterator applied to entity names -->
327
<xsl:template name="fillEntityName">
328
<xsl:param name="entities"/>
329
<xsl:param name="index" select="0"/>
330
<xsl:call-template name="fillEntityNameDoit">
331
<xsl:with-param name="entity" select="$entities[@num=$index]"/>
332
<xsl:with-param name="index" select="$index"/>
334
<xsl:if test="count($entities[@num > $index]) > 0">
337
<xsl:call-template name="fillEntityName">
338
<xsl:with-param name="entities" select="$entities"/>
339
<xsl:with-param name="index" select="1+$index"/>
344
<xsl:template name="fillEventThreadedDoit">
345
<xsl:param name="entity"/>
346
<xsl:param name="index"/>
348
<xsl:when test="count($entity) > 0">
350
<xsl:when test="count($entity[position()=1]/@filtered)=0">
351
<xsl:text> false</xsl:text>
354
<xsl:text> true</xsl:text>
359
<xsl:text> false</xsl:text>
365
<xsl:template name="fillEventThreaded">
366
<xsl:param name="entities"/>
367
<xsl:param name="index" select="0"/>
368
<xsl:call-template name="fillEventThreadedDoit">
369
<xsl:with-param name="entity" select="$entities[@num=$index]"/>
370
<xsl:with-param name="index" select="$index"/>
372
<xsl:if test="count($entities[@num > $index]) > 0">
375
<xsl:call-template name="fillEventThreaded">
376
<xsl:with-param name="entities" select="$entities"/>
377
<xsl:with-param name="index" select="1+$index"/>
382
<xsl:template match="function" mode="notrace">
383
<xsl:if test="count(@impl)=1 and contains(@impl,'notrace')">
384
<xsl:value-of select="@num"/>
390
<xsl:template match="category" mode="wrapper">
393
// </xsl:text><xsl:value-of select="@label"/><xsl:text> functions
396
<xsl:apply-templates select="function[count(@hide)=0]"/>
399
<xsl:template match="function" mode="transition">
400
<xsl:param name="space">
404
<xsl:value-of select="$space"/>
407
<xsl:when test="count(@callbacksafe)=0 or not(contains(@callbacksafe,'safe'))">
408
<xsl:text>if (this_thread == nullptr || !this_thread->is_Java_thread()) {</xsl:text>
412
<xsl:when test="count(@phase)=0 or contains(@phase,'live') or contains(@phase,'start')">
413
<xsl:text>if (this_thread == nullptr || (!this_thread->is_Java_thread() && !this_thread->is_Named_thread())) {</xsl:text>
416
<xsl:text>if (!this_thread->is_Java_thread()) {</xsl:text>
422
<xsl:if test="$trace='Trace'">
423
<xsl:value-of select="$space"/>
424
<xsl:text> if (trace_flags) {</xsl:text>
425
<xsl:value-of select="$space"/>
426
<xsl:text> log_trace(jvmti)("[non-attached thread] %s %s", func_name,</xsl:text>
427
<xsl:value-of select="$space"/>
428
<xsl:text> JvmtiUtil::error_name(JVMTI_ERROR_UNATTACHED_THREAD));</xsl:text>
429
<xsl:value-of select="$space"/>
430
<xsl:text> }</xsl:text>
432
<xsl:value-of select="$space"/>
433
<xsl:text> return JVMTI_ERROR_UNATTACHED_THREAD;</xsl:text>
434
<xsl:value-of select="$space"/>
435
<xsl:text>}</xsl:text>
436
<xsl:value-of select="$space"/>
437
<xsl:if test="count(@impl)=0 or not(contains(@impl,'innative'))">
438
<xsl:text>JavaThread* current_thread = JavaThread::cast(this_thread);</xsl:text>
439
<xsl:value-of select="$space"/>
440
<xsl:text>MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, current_thread));</xsl:text>
441
<xsl:value-of select="$space"/>
442
<xsl:text>ThreadInVMfromNative __tiv(current_thread);</xsl:text>
443
<xsl:value-of select="$space"/>
444
<xsl:text>VM_ENTRY_BASE(jvmtiError, </xsl:text>
445
<xsl:apply-templates select="." mode="functionid"/>
446
<xsl:text> , current_thread)</xsl:text>
447
<xsl:value-of select="$space"/>
448
<xsl:text>debug_only(VMNativeEntryWrapper __vew;)</xsl:text>
449
<xsl:if test="count(@callbacksafe)=0 or not(contains(@callbacksafe,'safe'))">
450
<xsl:value-of select="$space"/>
451
<xsl:text>PreserveExceptionMark __em(this_thread);</xsl:text>
453
<xsl:value-of select="$space"/>
454
<xsl:if test="$trace='Trace'">
455
<xsl:text>if (trace_flags) {</xsl:text>
456
<xsl:value-of select="$space"/>
457
<xsl:text> curr_thread_name = JvmtiTrace::safe_get_current_thread_name();</xsl:text>
458
<xsl:value-of select="$space"/>
459
<xsl:text>}</xsl:text>
460
<xsl:value-of select="$space"/>
466
<xsl:template match="required">
468
if (jvmti_env->get_capabilities()-></xsl:text>
469
<xsl:value-of select="@id"/>
472
<xsl:if test="$trace='Trace'">
473
<xsl:text> if (trace_flags) {
474
log_trace(jvmti)("[%s] %s %s", curr_thread_name, func_name,
475
JvmtiUtil::error_name(JVMTI_ERROR_MUST_POSSESS_CAPABILITY));
479
<xsl:text> return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
485
<xsl:template match="function">
487
static jvmtiError JNICALL
489
<xsl:apply-templates select="." mode="functionid"/>
490
<xsl:text>(jvmtiEnv* env</xsl:text>
491
<xsl:apply-templates select="parameters" mode="signature"/>
495
<xsl:if test="not(contains(@jkernel,'yes'))">
496
<xsl:text>
#if !INCLUDE_JVMTI 
</xsl:text>
497
<xsl:text> return JVMTI_ERROR_NOT_AVAILABLE; 
</xsl:text>
498
<xsl:text>#else 
</xsl:text>
501
<xsl:apply-templates select="." mode="traceSetUp"/>
503
<xsl:when test="count(@phase)=0 or contains(@phase,'live')">
504
<xsl:text> if(!JvmtiEnv::is_vm_live()) {
506
<xsl:if test="$trace='Trace'">
507
<xsl:text> if (trace_flags) {
508
log_trace(jvmti)("[-] %s %s(%d)", func_name,
509
JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE), JvmtiEnv::get_phase());
513
<xsl:text> return JVMTI_ERROR_WRONG_PHASE;
517
Thread* this_thread = Thread::current_or_null(); </xsl:text>
519
<xsl:apply-templates select="." mode="transition"/>
522
<xsl:if test="contains(@phase,'onload')">
523
<xsl:text> if(JvmtiEnv::get_phase()!=JVMTI_PHASE_ONLOAD</xsl:text>
524
<xsl:if test="not(contains(@phase,'onloadOnly'))">
525
<xsl:text> && JvmtiEnv::get_phase()!=JVMTI_PHASE_LIVE</xsl:text>
529
<xsl:if test="$trace='Trace'">
530
<xsl:text> if (trace_flags) {
531
log_trace(jvmti)("[-] %s %s", func_name,
532
JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
536
<xsl:text> return JVMTI_ERROR_WRONG_PHASE;
539
<xsl:if test="contains(@phase,'start')">
540
<xsl:text> if(JvmtiEnv::get_phase(env)!=JVMTI_PHASE_START && JvmtiEnv::get_phase()!=JVMTI_PHASE_LIVE) {
542
<xsl:if test="$trace='Trace'">
543
<xsl:text> if (trace_flags) {
544
log_trace(jvmti)("[-] %s %s", func_name,
545
JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
549
<xsl:text> return JVMTI_ERROR_WRONG_PHASE;
551
Thread* this_thread = Thread::current_or_null(); </xsl:text>
552
<xsl:apply-templates select="." mode="transition"/>
558
JvmtiEnv* jvmti_env = JvmtiEnv::JvmtiEnv_from_jvmti_env(env);
559
if (!jvmti_env->is_valid()) {
561
<xsl:if test="$trace='Trace'">
562
<xsl:text> if (trace_flags) {
563
log_trace(jvmti)("[%s] %s %s env=" PTR_FORMAT, curr_thread_name, func_name,
564
JvmtiUtil::error_name(JVMTI_ERROR_INVALID_ENVIRONMENT), p2i(env));
568
<xsl:text> return JVMTI_ERROR_INVALID_ENVIRONMENT;
572
<xsl:apply-templates select="capabilities/required"/>
574
<xsl:text> jvmtiError err;
577
<xsl:when test="count(@phase)=1 and not(contains(@phase,'live')) and not(contains(@phase,'start'))">
579
<xsl:when test="count(@callbacksafe)=0 or not(contains(@callbacksafe,'safe'))">
580
<xsl:text> if (Threads::number_of_threads() != 0) {
581
Thread* this_thread = Thread::current_or_null();</xsl:text>
585
<xsl:text> Thread* this_thread = nullptr;
587
if (Threads::number_of_threads() == 0) {
590
this_thread = Thread::current_or_null();
591
transition = ((this_thread != nullptr) && !this_thread->is_Named_thread());
593
if (transition) {</xsl:text>
597
<!-- we allow use in early phases but there are threads now, -->
598
<!-- so do thread transition -->
599
<xsl:apply-templates select="." mode="transition">
600
<xsl:with-param name="space">
604
</xsl:apply-templates>
607
<xsl:apply-templates select="." mode="doCall"/>
610
<!-- we are pre-thread - no thread transition code -->
611
<xsl:apply-templates select="." mode="doCall"/>
616
<xsl:apply-templates select="." mode="doCall"/>
619
<xsl:text> return err;
622
<xsl:if test="not(contains(@jkernel,'yes'))">
623
<xsl:text>#endif // INCLUDE_JVMTI
</xsl:text>
626
<xsl:text>}
</xsl:text>
629
<xsl:template match="function" mode="doCall">
630
<xsl:apply-templates select="parameters" mode="dochecks"/>
631
<xsl:apply-templates select="." mode="traceBefore"/>
632
<xsl:apply-templates select="." mode="genCall"/>
633
<xsl:apply-templates select="." mode="traceAfter"/>
636
<xsl:template match="function" mode="genCall">
637
<xsl:text> err = jvmti_env-></xsl:text>
638
<xsl:value-of select="@id"/>
639
<xsl:text>(</xsl:text>
640
<xsl:apply-templates select="parameters" mode="HotSpotValue"/>
646
<xsl:template match="function" mode="traceSetUp">
647
<xsl:if test="$trace='Trace'">
648
<xsl:text> SafeResourceMark rm;
649
jint trace_flags = JvmtiTrace::trace_flags(</xsl:text>
650
<xsl:value-of select="@num"/>
652
const char *func_name = nullptr;
653
const char *curr_thread_name = nullptr;
655
func_name = JvmtiTrace::function_name(</xsl:text>
656
<xsl:value-of select="@num"/>
658
curr_thread_name = JvmtiTrace::safe_get_current_thread_name();
665
<xsl:template match="function" mode="traceBefore">
666
<xsl:if test="$trace='Trace'">
668
if ((trace_flags & JvmtiTrace::SHOW_IN) != 0) {
670
<xsl:apply-templates select="." mode="traceIn"/>
677
<xsl:template match="param" mode="traceError">
678
<xsl:param name="err"/>
679
<xsl:param name="comment"></xsl:param>
680
<xsl:param name="extraValue"></xsl:param>
681
<xsl:if test="$trace='Trace'">
682
<xsl:text> if ((trace_flags & JvmtiTrace::SHOW_ERROR) != 0) {
683
if ((trace_flags & JvmtiTrace::SHOW_IN) == 0) {
685
<xsl:apply-templates select="../.." mode="traceIn">
686
<xsl:with-param name="endParam" select="."/>
687
</xsl:apply-templates>
689
log_error(jvmti)("[%s] %s } %s - erroneous arg is </xsl:text>
690
<xsl:value-of select="@id"/>
691
<xsl:value-of select="$comment"/>
692
<xsl:text>", curr_thread_name, func_name,
693
JvmtiUtil::error_name(</xsl:text>
694
<xsl:value-of select="$err"/>
695
<xsl:text>)</xsl:text>
696
<xsl:value-of select="$extraValue"/>
701
<xsl:text> return </xsl:text>
702
<xsl:value-of select="$err"/>
703
<xsl:text>;</xsl:text>
707
<xsl:template match="function" mode="traceAfter">
708
<xsl:if test="$trace='Trace'">
709
<xsl:text> if ( err != JVMTI_ERROR_NONE && (trace_flags & JvmtiTrace::SHOW_ERROR) != 0) {
710
if ((trace_flags & JvmtiTrace::SHOW_IN) == 0) {
712
<xsl:apply-templates select="." mode="traceIn"/>
714
log_error(jvmti)("[%s] %s } %s", curr_thread_name, func_name,
715
JvmtiUtil::error_name(err));
716
} else if ((trace_flags & JvmtiTrace::SHOW_OUT) != 0) {
717
log_trace(jvmti)("[%s] %s }", curr_thread_name, func_name);
723
<xsl:template match="function" mode="traceIn">
724
<xsl:param name="endParam"></xsl:param>
725
<xsl:text> log_trace(jvmti)("[%s] %s { </xsl:text>
726
<xsl:apply-templates select="parameters" mode="traceInFormat">
727
<xsl:with-param name="endParam" select="$endParam"/>
728
</xsl:apply-templates>
729
<xsl:text>", curr_thread_name, func_name</xsl:text>
730
<xsl:apply-templates select="parameters" mode="traceInValue">
731
<xsl:with-param name="endParam" select="$endParam"/>
732
</xsl:apply-templates>
737
<xsl:template match="parameters" mode="dochecks">
738
<xsl:apply-templates select="param" mode="dochecks"/>
741
<xsl:template match="param" mode="dochecks">
742
<xsl:apply-templates select="child::*[position()=1]" mode="dochecks">
743
<xsl:with-param name="name" select="@id"/>
744
</xsl:apply-templates>
747
<xsl:template match="outptr|outbuf|allocfieldbuf|ptrtype|inptr|inbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="dochecks">
748
<xsl:param name="name"/>
749
<xsl:if test="count(nullok)=0 and not(contains(@impl,'nonullcheck'))">
750
<xsl:text> if (</xsl:text>
751
<xsl:value-of select="$name"/>
752
<xsl:text> == nullptr) {
754
<xsl:apply-templates select=".." mode="traceError">
755
<xsl:with-param name="err">JVMTI_ERROR_NULL_POINTER</xsl:with-param>
756
</xsl:apply-templates>
763
<xsl:template match="jrawMonitorID" mode="dochecks">
764
<xsl:param name="name"/>
765
<xsl:text> JvmtiRawMonitor *rmonitor = (JvmtiRawMonitor *)</xsl:text>
766
<xsl:value-of select="$name"/>
768
if (rmonitor == nullptr) {
770
<xsl:apply-templates select=".." mode="traceError">
771
<xsl:with-param name="err">JVMTI_ERROR_INVALID_MONITOR</xsl:with-param>
772
<xsl:with-param name="comment"> - raw monitor is nullptr</xsl:with-param>
773
</xsl:apply-templates>
776
if (!rmonitor->is_valid()) {
778
<xsl:apply-templates select=".." mode="traceError">
779
<xsl:with-param name="err">JVMTI_ERROR_INVALID_MONITOR</xsl:with-param>
780
<xsl:with-param name="comment"> - not a raw monitor " PTR_FORMAT "</xsl:with-param>
781
<xsl:with-param name="extraValue">, p2i(rmonitor)</xsl:with-param>
782
</xsl:apply-templates>
788
<xsl:template match="jthread" mode="dochecksbody">
789
<xsl:param name="name"/>
790
<xsl:text> err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), </xsl:text>
791
<xsl:value-of select="$name"/>
792
<xsl:text>, &java_thread, nullptr);
793
if (err != JVMTI_ERROR_NONE) {
795
<xsl:apply-templates select=".." mode="traceError">
796
<xsl:with-param name="err">err</xsl:with-param>
797
<xsl:with-param name="comment"> - jthread did not convert to a JavaThread - jthread = " PTR_FORMAT "</xsl:with-param>
798
<xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
799
</xsl:apply-templates>
805
<xsl:template match="jthread" mode="dochecks">
806
<xsl:param name="name"/>
807
<!-- If we convert and test threads -->
808
<xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
809
<xsl:text> JavaThread* java_thread = nullptr;
810
ThreadsListHandle tlh(this_thread);
813
<xsl:when test="count(@null)=0">
814
<xsl:apply-templates select="." mode="dochecksbody">
815
<xsl:with-param name="name" select="$name"/>
816
</xsl:apply-templates>
819
<xsl:text> if (</xsl:text>
820
<xsl:value-of select="$name"/>
821
<xsl:text> == nullptr) {
822
java_thread = current_thread;
825
<xsl:apply-templates select="." mode="dochecksbody">
826
<xsl:with-param name="name" select="$name"/>
827
</xsl:apply-templates>
835
<xsl:template match="jframeID" mode="dochecks">
836
<xsl:param name="name"/>
840
<xsl:apply-templates select=".." mode="traceError">
841
<xsl:with-param name="err">JVMTI_ERROR_ILLEGAL_ARGUMENT</xsl:with-param>
842
<xsl:with-param name="comment"> - negative depth - jthread = " INT32_FORMAT "</xsl:with-param>
843
<xsl:with-param name="extraValue">, <xsl:value-of select="$name"/></xsl:with-param>
844
</xsl:apply-templates>
850
<xsl:template match="jclass" mode="dochecks">
851
<xsl:param name="name"/>
852
<!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
853
<xsl:if test="count(@method)=0">
854
<xsl:text> oop k_mirror = JNIHandles::resolve_external_guard(</xsl:text>
855
<xsl:value-of select="$name"/>
857
if (k_mirror == nullptr) {
859
<xsl:apply-templates select=".." mode="traceError">
860
<xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
861
<xsl:with-param name="comment"> - resolved to nullptr - jclass = " PTR_FORMAT "</xsl:with-param>
862
<xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
863
</xsl:apply-templates>
866
if (!k_mirror->is_a(vmClasses::Class_klass())) {
868
<xsl:apply-templates select=".." mode="traceError">
869
<xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
870
<xsl:with-param name="comment"> - not a class - jclass = " PTR_FORMAT "</xsl:with-param>
871
<xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
872
</xsl:apply-templates>
876
<xsl:if test="count(@method|@field)=1">
878
if (java_lang_Class::is_primitive(k_mirror)) {
880
<xsl:apply-templates select=".." mode="traceError">
881
<xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
882
<xsl:with-param name="comment"> - is a primitive class - jclass = " PTR_FORMAT "</xsl:with-param>
883
<xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
884
</xsl:apply-templates>
887
Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
888
if (k_oop == nullptr) {
890
<xsl:apply-templates select=".." mode="traceError">
891
<xsl:with-param name="err">JVMTI_ERROR_INVALID_CLASS</xsl:with-param>
892
<xsl:with-param name="comment"> - no Klass* - jclass = " PTR_FORMAT "</xsl:with-param>
893
<xsl:with-param name="extraValue">, p2i(<xsl:value-of select="$name"/>)</xsl:with-param>
894
</xsl:apply-templates>
903
<xsl:template match="jmethodID" mode="dochecks">
904
<xsl:param name="name"/>
905
<xsl:text> Method* checked_method = Method::checked_resolve_jmethod_id(</xsl:text>
906
<xsl:value-of select="$name"/>
907
<xsl:text>);
</xsl:text>
908
<xsl:text> if (checked_method == nullptr) {
</xsl:text>
909
<xsl:apply-templates select=".." mode="traceError">
910
<xsl:with-param name="err">JVMTI_ERROR_INVALID_METHODID</xsl:with-param>
911
<xsl:with-param name="comment"></xsl:with-param>
912
<xsl:with-param name="extraValue"></xsl:with-param>
913
</xsl:apply-templates>
914
<xsl:text>
</xsl:text>
915
<xsl:text> }
</xsl:text>
916
<xsl:if test="count(@native)=1 and contains(@native,'error')">
917
<xsl:text> if (checked_method->is_native()) {
</xsl:text>
918
<xsl:text> return JVMTI_ERROR_NATIVE_METHOD;
</xsl:text>
919
<xsl:text> }
</xsl:text>
924
<xsl:template match="jfieldID" mode="dochecks">
925
<xsl:param name="name"/>
926
<xsl:text> ResourceMark rm_fdesc(current_thread);
</xsl:text>
927
<xsl:text> fieldDescriptor fdesc;
</xsl:text>
928
<xsl:text> if (!JvmtiEnv::get_field_descriptor(k_oop, </xsl:text>
929
<xsl:value-of select="$name"/>
930
<xsl:text>, &fdesc)) {
</xsl:text>
931
<xsl:apply-templates select=".." mode="traceError">
932
<xsl:with-param name="err">JVMTI_ERROR_INVALID_FIELDID</xsl:with-param>
933
</xsl:apply-templates>
934
<xsl:text>
</xsl:text>
935
<xsl:text> }
</xsl:text>
939
<xsl:template match="jint" mode="dochecks">
940
<xsl:param name="name"/>
941
<xsl:if test="count(@min)=1">
942
<xsl:text> if (</xsl:text>
943
<xsl:value-of select="$name"/>
944
<xsl:text> < </xsl:text>
945
<xsl:value-of select="@min"/>
948
<xsl:apply-templates select=".." mode="traceError">
949
<xsl:with-param name="err">JVMTI_ERROR_ILLEGAL_ARGUMENT</xsl:with-param>
950
</xsl:apply-templates>
957
<xsl:template match="jobject|jvalue|jthreadGroup|enum|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|struct" mode="dochecks">
960
<!-- iterate over parameters, stopping if specified is encountered -->
961
<xsl:template name="traceInValueParamsUpTo">
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="traceInValue"/>
968
<xsl:if test="count($params) > $index">
969
<xsl:call-template name="traceInValueParamsUpTo">
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"/>
978
<xsl:template name="traceInFormatParamsUpTo">
979
<xsl:param name="params"/>
980
<xsl:param name="endParam"></xsl:param>
981
<xsl:param name="index" select="1"/>
982
<xsl:variable name="cParam" select="$params[position()=$index]"/>
983
<xsl:if test="$cParam!=$endParam">
984
<xsl:apply-templates select="$cParam" mode="traceInFormat"/>
985
<xsl:if test="count($params) > $index">
986
<xsl:call-template name="traceInFormatParamsUpTo">
987
<xsl:with-param name="params" select="$params"/>
988
<xsl:with-param name="endParam" select="$endParam"/>
989
<xsl:with-param name="index" select="1+$index"/>
995
<xsl:template match="parameters" mode="traceInFormat">
996
<xsl:param name="endParam"></xsl:param>
997
<xsl:call-template name="traceInFormatParamsUpTo">
998
<xsl:with-param name="params" select="param"/>
999
<xsl:with-param name="endParam" select="$endParam"/>
1000
</xsl:call-template>
1003
<xsl:template match="parameters" mode="traceInValue">
1004
<xsl:param name="endParam"></xsl:param>
1005
<xsl:call-template name="traceInValueParamsUpTo">
1006
<xsl:with-param name="params" select="param"/>
1007
<xsl:with-param name="endParam" select="$endParam"/>
1008
</xsl:call-template>
1011
<xsl:template match="param" mode="traceInFormat">
1012
<xsl:apply-templates select="child::*[position()=1]" mode="traceInFormat">
1013
<xsl:with-param name="name" select="@id"/>
1014
</xsl:apply-templates>
1017
<xsl:template match="param" mode="traceInValue">
1018
<xsl:apply-templates select="child::*[position()=1]" mode="traceInValue">
1019
<xsl:with-param name="name" select="@id"/>
1020
</xsl:apply-templates>
1023
<xsl:template match="outptr|outbuf|allocfieldbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="traceInFormat">
1026
<xsl:template match="outptr|outbuf|allocfieldbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="traceInValue">
1029
<xsl:template match="inbuf" mode="traceInFormat">
1030
<xsl:param name="name"/>
1031
<xsl:text> </xsl:text>
1032
<xsl:value-of select="$name"/>
1033
<xsl:variable name="child" select="child::*[position()=1]"/>
1035
<xsl:when test="name($child)='char'">
1036
<xsl:text>='%s'</xsl:text>
1039
<xsl:text>=" PTR_FORMAT "</xsl:text>
1044
<xsl:template match="inbuf" mode="traceInValue">
1045
<xsl:param name="name"/>
1046
<xsl:text>, </xsl:text>
1047
<xsl:variable name="child" select="child::*[position()=1]"/>
1049
<xsl:when test="name($child)='char'">
1050
<xsl:value-of select="$name"/>
1053
p2i(<xsl:value-of select="$name"/>)
1058
<xsl:template match="ptrtype" mode="traceInFormat">
1059
<xsl:param name="name"/>
1060
<xsl:variable name="child" select="child::*[position()=1]"/>
1062
<xsl:when test="name($child)='jclass'">
1063
<xsl:text> </xsl:text>
1064
<xsl:value-of select="$name"/>
1065
<xsl:text>=" PTR_FORMAT "</xsl:text>
1068
<xsl:apply-templates select="$child" mode="traceInFormat"/>
1073
<xsl:template match="ptrtype" mode="traceInValue">
1074
<xsl:param name="name"/>
1075
<xsl:variable name="child" select="child::*[position()=1]"/>
1077
<xsl:when test="name($child)='jclass'">
1078
<xsl:text>, </xsl:text>
1079
p2i(<xsl:value-of select="$name"/>)
1082
<xsl:apply-templates select="$child" mode="traceInValue"/>
1087
<xsl:template match="inptr" mode="traceInFormat">
1088
<xsl:param name="name"/>
1089
<xsl:text> </xsl:text>
1090
<xsl:value-of select="$name"/>
1091
<xsl:text>=" PTR_FORMAT "</xsl:text>
1094
<xsl:template match="inptr" mode="traceInValue">
1095
<xsl:param name="name"/>
1096
<xsl:text>, </xsl:text>
1097
p2i(<xsl:value-of select="$name"/>)
1100
<xsl:template match="jrawMonitorID|jfieldID" mode="traceInFormat">
1101
<xsl:param name="name"/>
1102
<xsl:text> </xsl:text>
1103
<xsl:value-of select="$name"/>
1104
<xsl:text>=%s</xsl:text>
1107
<xsl:template match="jclass" mode="traceInFormat">
1108
<xsl:param name="name"/>
1109
<!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
1110
<xsl:if test="count(@method)=0">
1111
<xsl:text> </xsl:text>
1112
<xsl:value-of select="$name"/>
1113
<xsl:text>=%s</xsl:text>
1117
<xsl:template match="jrawMonitorID" mode="traceInValue">
1118
<xsl:param name="name"/>
1119
<xsl:text>, rmonitor->get_name()</xsl:text>
1122
<xsl:template match="jthread" mode="traceInFormat">
1123
<xsl:param name="name"/>
1124
<!-- If we convert and test threads -->
1125
<xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
1126
<xsl:text> </xsl:text>
1127
<xsl:value-of select="$name"/>
1128
<xsl:text>=%s</xsl:text>
1132
<xsl:template match="jthread" mode="traceInValue">
1133
<xsl:param name="name"/>
1134
<!-- If we convert and test threads -->
1135
<xsl:if test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
1137
JvmtiTrace::safe_get_thread_name(java_thread)</xsl:text>
1141
<xsl:template match="jframeID" mode="traceInFormat">
1142
<xsl:param name="name"/>
1143
<xsl:text>depth=%d</xsl:text>
1146
<xsl:template match="jframeID" mode="traceInValue">
1147
<xsl:param name="name"/>
1148
<xsl:text>, </xsl:text>
1149
<xsl:value-of select="$name"/>
1152
<xsl:template match="jclass" mode="traceInValue">
1153
<!-- for JVMTI a jclass/jmethodID becomes just jmethodID -->
1154
<xsl:if test="count(@method)=0">
1156
JvmtiTrace::get_class_name(k_mirror)</xsl:text>
1160
<xsl:template match="jmethodID" mode="traceInFormat">
1161
<xsl:param name="name"/>
1162
<xsl:text> </xsl:text>
1163
<xsl:value-of select="$name"/>
1164
<xsl:text>=%s.%s</xsl:text>
1167
<xsl:template match="jmethodID" mode="traceInValue">
1168
<xsl:param name="name"/>
1170
checked_method == nullptr? "nullptr" : checked_method->klass_name()->as_C_string(),
1171
checked_method == nullptr? "nullptr" : checked_method->name()->as_C_string()
1175
<xsl:template match="jfieldID" mode="traceInValue">
1176
<xsl:param name="name"/>
1177
<xsl:text>, fdesc.name()->as_C_string()</xsl:text>
1180
<xsl:template match="enum" mode="traceInFormat">
1181
<xsl:param name="name"/>
1182
<xsl:text> </xsl:text>
1183
<xsl:value-of select="$name"/>
1184
<xsl:text>=%d:%s</xsl:text>
1187
<xsl:template match="enum" mode="traceInValue">
1188
<xsl:param name="name"/>
1189
<xsl:text>, </xsl:text>
1190
<xsl:value-of select="$name"/>
1194
<xsl:when test=".='jvmtiError'">
1195
<xsl:text>JvmtiUtil::error_name(</xsl:text>
1196
<xsl:value-of select="$name"/>
1202
<xsl:when test=".='jvmtiEvent'">
1203
<xsl:text>JvmtiTrace::event_name(</xsl:text>
1204
<xsl:value-of select="$name"/>
1209
<xsl:text>JvmtiTrace::enum_name(</xsl:text>
1210
<xsl:value-of select="."/>
1211
<xsl:text>ConstantNames, </xsl:text>
1212
<xsl:value-of select="."/>
1213
<xsl:text>ConstantValues, </xsl:text>
1214
<xsl:value-of select="$name"/>
1215
<xsl:text>)</xsl:text>
1222
<xsl:template match="jint" mode="traceInFormat">
1223
<xsl:param name="name"/>
1224
<xsl:text> </xsl:text>
1225
<xsl:value-of select="$name"/>
1226
<xsl:text>=" INT32_FORMAT "</xsl:text>
1229
<xsl:template match="jlocation" mode="traceInFormat">
1230
<xsl:param name="name"/>
1231
<xsl:text> </xsl:text>
1232
<xsl:value-of select="$name"/>
1233
<xsl:text>=" JLONG_FORMAT "</xsl:text>
1236
<xsl:template match="jlong" mode="traceInFormat">
1237
<xsl:param name="name"/>
1238
<xsl:text> </xsl:text>
1239
<xsl:value-of select="$name"/>
1240
<xsl:text>=" JLONG_FORMAT "</xsl:text>
1243
<xsl:template match="size_t" mode="traceInFormat">
1244
<xsl:param name="name"/>
1245
<xsl:text> </xsl:text>
1246
<xsl:value-of select="$name"/>
1247
<xsl:text>=" SIZE_FORMAT_X "</xsl:text>
1250
<xsl:template match="jfloat|jdouble" mode="traceInFormat">
1251
<xsl:param name="name"/>
1252
<xsl:text> </xsl:text>
1253
<xsl:value-of select="$name"/>
1254
<xsl:text>=%f</xsl:text>
1257
<xsl:template match="char" mode="traceInFormat">
1258
<xsl:param name="name"/>
1259
<xsl:text> </xsl:text>
1260
<xsl:value-of select="$name"/>
1261
<xsl:text>=%c</xsl:text>
1264
<xsl:template match="uchar|jchar" mode="traceInFormat">
1265
<xsl:param name="name"/>
1266
<xsl:text> </xsl:text>
1267
<xsl:value-of select="$name"/>
1268
<xsl:text>=0x%x</xsl:text>
1271
<xsl:template match="jint|jlocation|jchar|jlong|jfloat|jdouble|char|uchar|size_t" mode="traceInValue">
1272
<xsl:param name="name"/>
1273
<xsl:text>, </xsl:text>
1274
<xsl:value-of select="$name"/>
1278
<xsl:template match="jboolean" mode="traceInFormat">
1279
<xsl:param name="name"/>
1280
<xsl:text> </xsl:text>
1281
<xsl:value-of select="$name"/>
1282
<xsl:text>=%s</xsl:text>
1285
<xsl:template match="jboolean" mode="traceInValue">
1286
<xsl:param name="name"/>
1287
<xsl:text>, </xsl:text>
1288
<xsl:value-of select="$name"/>
1289
<xsl:text>? "true" : "false"</xsl:text>
1292
<xsl:template match="jobject|jvalue|jthreadGroup|void|struct" mode="traceInFormat">
1295
<xsl:template match="jobject|jvalue|jthreadGroup|void|struct" mode="traceInValue">