author | iignatyev |
Tue, 28 Aug 2018 14:37:34 -0700 | |
changeset 51551 | e409244ce72e |
parent 50260 | test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.c@46c67f5e27c2 |
child 51715 | 13a63d4a3f8d |
permissions | -rw-r--r-- |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
4 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
8 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
14 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
18 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
22 |
*/ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
23 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
24 |
#include <stdio.h> |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
25 |
#include <stdlib.h> |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
26 |
#include "jvmti.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
27 |
#include "agent_common.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
28 |
#include "JVMTITools.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
29 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
30 |
#ifdef __cplusplus |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
31 |
extern "C" { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
32 |
#endif |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
33 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
34 |
#ifndef JNI_ENV_ARG |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
35 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
36 |
#ifdef __cplusplus |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
37 |
#define JNI_ENV_ARG(x, y) y |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
38 |
#define JNI_ENV_PTR(x) x |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
39 |
#else |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
40 |
#define JNI_ENV_ARG(x,y) x, y |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
41 |
#define JNI_ENV_PTR(x) (*x) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
42 |
#endif |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
43 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
44 |
#endif |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
45 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
46 |
#define STATUS_FAILED 2 |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
47 |
#define PASSED 0 |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
48 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
49 |
static jvmtiEnv *jvmti; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
50 |
static jvmtiCapabilities caps; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
51 |
static jvmtiEventCallbacks callbacks; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
52 |
static int watch_ev = 0; /* ignore JVMTI events by default */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
53 |
static int gen_ev = 0; /* number of generated events */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
54 |
static int tot_result = PASSED; /* total result of the test */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
55 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
56 |
static jrawMonitorID watch_ev_monitor; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
57 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
58 |
static void set_watch_ev(int value) { |
51551 | 59 |
jvmti->RawMonitorEnter(watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
60 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
61 |
watch_ev = value; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
62 |
|
51551 | 63 |
jvmti->RawMonitorExit(watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
64 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
65 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
66 |
void JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
67 |
FramePop(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
68 |
jmethodID method, jboolean wasPopedByException) { |
51551 | 69 |
jvmti->RawMonitorEnter(watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
70 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
71 |
if (watch_ev) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
72 |
printf("#### FramePop event occurred ####\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
73 |
gen_ev++; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
74 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
75 |
|
51551 | 76 |
jvmti->RawMonitorExit(watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
77 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
78 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
79 |
void JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
80 |
MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
81 |
jmethodID method, jboolean was_poped_by_exc, jvalue return_value) { |
51551 | 82 |
jvmti->RawMonitorEnter(watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
83 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
84 |
if (watch_ev) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
85 |
printf("#### MethodExit event occurred ####\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
86 |
gen_ev++; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
87 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
88 |
|
51551 | 89 |
jvmti->RawMonitorExit(watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
90 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
91 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
92 |
JNIEXPORT jint JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
93 |
Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
94 |
jclass cls, jint vrb, jobject susThr) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
95 |
jvmtiError err; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
96 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
97 |
if (!caps.can_pop_frame || !caps.can_suspend) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
98 |
return PASSED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
99 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
100 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
101 |
if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
102 |
printf(">>>>>>>> Invoke SuspendThread()\n"); |
51551 | 103 |
if ((err = (jvmti->SuspendThread(susThr))) != JVMTI_ERROR_NONE) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
104 |
printf("%s: Failed to call SuspendThread(): error=%d: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
105 |
__FILE__, err, TranslateError(err)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
106 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
107 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
108 |
if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
109 |
printf("<<<<<<<< SuspendThread() is successfully done\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
110 |
return PASSED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
111 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
112 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
113 |
JNIEXPORT jint JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
114 |
Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jint vrb, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
115 |
jobject susThr) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
116 |
jvmtiError err; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
117 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
118 |
if (!caps.can_pop_frame || !caps.can_suspend) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
119 |
return PASSED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
120 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
121 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
122 |
if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
123 |
printf(">>>>>>>> Invoke ResumeThread()\n"); |
51551 | 124 |
if ((err = (jvmti->ResumeThread(susThr))) != JVMTI_ERROR_NONE) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
125 |
printf("%s: Failed to call ResumeThread(): error=%d: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
126 |
__FILE__, err, TranslateError(err)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
127 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
128 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
129 |
if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
130 |
printf("<<<<<<<< ResumeThread() is successfully done\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
131 |
return PASSED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
132 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
133 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
134 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
135 |
JNIEXPORT jint JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
136 |
Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jint vrb, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
137 |
jobject frameThr) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
138 |
jvmtiError err; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
139 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
140 |
if (!caps.can_pop_frame || !caps.can_suspend) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
141 |
return PASSED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
142 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
143 |
|
51551 | 144 |
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
145 |
JVMTI_EVENT_METHOD_EXIT, frameThr); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
146 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
147 |
printf("Failed to enable METHOD_EXIT event: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
148 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
149 |
tot_result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
150 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
151 |
|
51551 | 152 |
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
153 |
JVMTI_EVENT_FRAME_POP, frameThr); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
154 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
155 |
printf("Failed to enable FRAME_POP event: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
156 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
157 |
tot_result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
158 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
159 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
160 |
if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
161 |
printf(">>>>>>>> Invoke PopFrame()\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
162 |
set_watch_ev(1); /* watch JVMTI events */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
163 |
|
51551 | 164 |
if ((err = (jvmti->PopFrame(frameThr))) != JVMTI_ERROR_NONE) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
165 |
printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
166 |
err, TranslateError(err)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
167 |
printf("\tFor more info about this error see the JVMTI spec.\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
168 |
tot_result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
169 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
170 |
else if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
171 |
printf("Check #1 PASSED: PopFrame() is successfully done\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
172 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
173 |
set_watch_ev(0); /* ignore again JVMTI events */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
174 |
if (gen_ev) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
175 |
printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
176 |
gen_ev); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
177 |
tot_result = STATUS_FAILED; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
178 |
} else if (vrb == 1) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
179 |
printf("Check #2 PASSED: No JVMTI events were generated by the function PopFrame()\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
180 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
181 |
return(tot_result); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
182 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
183 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
184 |
#ifdef STATIC_BUILD |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
185 |
JNIEXPORT jint JNICALL Agent_OnLoad_popframe003(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
186 |
return Agent_Initialize(jvm, options, reserved); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
187 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
188 |
JNIEXPORT jint JNICALL Agent_OnAttach_popframe003(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
189 |
return Agent_Initialize(jvm, options, reserved); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
190 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
191 |
JNIEXPORT jint JNI_OnLoad_popframe003(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
192 |
return JNI_VERSION_1_8; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
193 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
194 |
#endif |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
195 |
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
196 |
jint res; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
197 |
jvmtiError err; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
198 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
199 |
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
200 |
JVMTI_VERSION_1_1); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
201 |
if (res != JNI_OK || jvmti == NULL) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
202 |
printf("Wrong result of a valid call to GetEnv!\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
203 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
204 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
205 |
|
51551 | 206 |
err = jvmti->GetPotentialCapabilities(&caps); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
207 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
208 |
printf("(GetPotentialCapabilities) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
209 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
210 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
211 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
212 |
|
51551 | 213 |
err = jvmti->AddCapabilities(&caps); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
214 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
215 |
printf("(AddCapabilities) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
216 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
217 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
218 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
219 |
|
51551 | 220 |
err = jvmti->GetCapabilities(&caps); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
221 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
222 |
printf("(GetCapabilities) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
223 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
224 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
225 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
226 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
227 |
if (!caps.can_pop_frame) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
228 |
printf("Warning: PopFrame is not implemented\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
229 |
return JNI_OK; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
230 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
231 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
232 |
if (!caps.can_suspend) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
233 |
printf("Warning: suspend/resume is not implemented\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
234 |
return JNI_OK; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
235 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
236 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
237 |
if (caps.can_generate_frame_pop_events && |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
238 |
caps.can_generate_method_exit_events) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
239 |
callbacks.MethodExit = &MethodExit; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
240 |
callbacks.FramePop = &FramePop; |
51551 | 241 |
err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
242 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
243 |
printf("(SetEventCallbacks) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
244 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
245 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
246 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
247 |
} else { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
248 |
printf("Warning: FramePop or MethodExit event is not implemented\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
249 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
250 |
|
51551 | 251 |
err = jvmti->CreateRawMonitor("watch_ev_monitor", &watch_ev_monitor); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
252 |
if (err != JVMTI_ERROR_NONE) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
253 |
printf("(CreateRawMonitor) unexpected error: %s (%d)\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
254 |
TranslateError(err), err); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
255 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
256 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
257 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
258 |
return JNI_OK; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
259 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
260 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
261 |
#ifdef __cplusplus |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
262 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
263 |
#endif |