110 if (!clean()) {
111 nsk_jvmti_setFailStatus();
112 return;
113 }
114 }
115
116 NSK_DISPLAY0("Let debuggee to finish\n");
117 if (!nsk_jvmti_resumeSync())
118 return;
119 }
120
121 /* ============================================================================= */
122
123 /**
124 * Enable or disable tested events.
125 */
126 static int enableEvents(jvmtiEventMode enable) {
127 int i;
128
129 for (i = 0; i < EVENTS_COUNT; i++) {
130 if (!NSK_JVMTI_VERIFY(
131 NSK_CPP_STUB4(SetEventNotificationMode, jvmti, enable,
132 eventsList[i], NULL))) {
133 nsk_jvmti_setFailStatus();
134 return NSK_FALSE;
135 }
136 }
137 return NSK_TRUE;
138 }
139
140 /**
141 * Prepare data.
142 * - find tested thread
143 * - get tested methodIDs
144 * - enable events
145 */
146 static int prepare() {
147 jclass debugeeClass = NULL;
148 jclass threadClass = NULL;
149 jfieldID threadFieldID = NULL;
150 jthread thread = NULL;
151 int i;
152
153 for (i = 0; i < METHODS_COUNT; i++) {
154 methodsDesc[i].method = (jmethodID)NULL;
155 methodsDesc[i].loadEvents = 0;
156 methodsDesc[i].unloadEvents = 0;
157 }
158
159 if (!NSK_JNI_VERIFY(jni, (debugeeClass =
160 NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL))
161 return NSK_FALSE;
162
163 if (!NSK_JNI_VERIFY(jni, (threadFieldID =
164 NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass,
165 THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != NULL))
166 return NSK_FALSE;
167
168 if (!NSK_JNI_VERIFY(jni, (thread = (jthread)
169 NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, threadFieldID)) != NULL))
170 return NSK_FALSE;
171
172 if (!NSK_JNI_VERIFY(jni, (threadClass =
173 NSK_CPP_STUB2(GetObjectClass, jni, thread)) != NULL))
174 return NSK_FALSE;
175
176 NSK_DISPLAY0("Find tested methods:\n");
177 for (i = 0; i < METHODS_COUNT; i++) {
178 if (!NSK_JNI_VERIFY(jni, (methodsDesc[i].method =
179 NSK_CPP_STUB4(GetMethodID, jni, threadClass,
180 methodsDesc[i].methodName, methodsDesc[i].methodSig)) != NULL))
181 return NSK_FALSE;
182 NSK_DISPLAY3(" method #%d (%s): 0x%p\n",
183 i, methodsDesc[i].methodName, (void*)methodsDesc[i].method);
184 }
185
186 NSK_DISPLAY0("Enable events\n");
187 if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL))
188 return NSK_FALSE;
189
190 return NSK_TRUE;
191 }
192
193 /**
194 * Testcase: check tested events.
195 * - check if expected events received for each method
196 *
197 * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
198 */
199 static int checkEvents() {
200 int i;
310 }
311 JNIEXPORT jint JNI_OnLoad_em05t001(JavaVM *jvm, char *options, void *reserved) {
312 return JNI_VERSION_1_8;
313 }
314 #endif
315 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
316
317 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
318 return JNI_ERR;
319
320 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
321
322 if (!NSK_VERIFY((jvmti =
323 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
324 return JNI_ERR;
325
326 {
327 jvmtiCapabilities caps;
328 memset(&caps, 0, sizeof(caps));
329 caps.can_generate_compiled_method_load_events = 1;
330 if (!NSK_JVMTI_VERIFY(
331 NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
332 return JNI_ERR;
333 }
334
335 {
336 jvmtiEventCallbacks eventCallbacks;
337 memset(&eventCallbacks, 0, sizeof(eventCallbacks));
338 eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
339 eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
340 if (!NSK_JVMTI_VERIFY(
341 NSK_CPP_STUB3(SetEventCallbacks, jvmti,
342 &eventCallbacks, sizeof(eventCallbacks))))
343 return JNI_ERR;
344 }
345
346 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
347 return JNI_ERR;
348
349 return JNI_OK;
350 }
351
352 /* ============================================================================= */
353
354 }
|
110 if (!clean()) {
111 nsk_jvmti_setFailStatus();
112 return;
113 }
114 }
115
116 NSK_DISPLAY0("Let debuggee to finish\n");
117 if (!nsk_jvmti_resumeSync())
118 return;
119 }
120
121 /* ============================================================================= */
122
123 /**
124 * Enable or disable tested events.
125 */
126 static int enableEvents(jvmtiEventMode enable) {
127 int i;
128
129 for (i = 0; i < EVENTS_COUNT; i++) {
130 if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, eventsList[i], NULL))) {
131 nsk_jvmti_setFailStatus();
132 return NSK_FALSE;
133 }
134 }
135 return NSK_TRUE;
136 }
137
138 /**
139 * Prepare data.
140 * - find tested thread
141 * - get tested methodIDs
142 * - enable events
143 */
144 static int prepare() {
145 jclass debugeeClass = NULL;
146 jclass threadClass = NULL;
147 jfieldID threadFieldID = NULL;
148 jthread thread = NULL;
149 int i;
150
151 for (i = 0; i < METHODS_COUNT; i++) {
152 methodsDesc[i].method = (jmethodID)NULL;
153 methodsDesc[i].loadEvents = 0;
154 methodsDesc[i].unloadEvents = 0;
155 }
156
157 if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL))
158 return NSK_FALSE;
159
160 if (!NSK_JNI_VERIFY(jni, (threadFieldID =
161 jni->GetStaticFieldID(debugeeClass, THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != NULL))
162 return NSK_FALSE;
163
164 if (!NSK_JNI_VERIFY(jni, (thread = (jthread)
165 jni->GetStaticObjectField(debugeeClass, threadFieldID)) != NULL))
166 return NSK_FALSE;
167
168 if (!NSK_JNI_VERIFY(jni, (threadClass = jni->GetObjectClass(thread)) != NULL))
169 return NSK_FALSE;
170
171 NSK_DISPLAY0("Find tested methods:\n");
172 for (i = 0; i < METHODS_COUNT; i++) {
173 if (!NSK_JNI_VERIFY(jni, (methodsDesc[i].method =
174 jni->GetMethodID(threadClass, methodsDesc[i].methodName, methodsDesc[i].methodSig)) != NULL))
175 return NSK_FALSE;
176 NSK_DISPLAY3(" method #%d (%s): 0x%p\n",
177 i, methodsDesc[i].methodName, (void*)methodsDesc[i].method);
178 }
179
180 NSK_DISPLAY0("Enable events\n");
181 if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL))
182 return NSK_FALSE;
183
184 return NSK_TRUE;
185 }
186
187 /**
188 * Testcase: check tested events.
189 * - check if expected events received for each method
190 *
191 * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
192 */
193 static int checkEvents() {
194 int i;
304 }
305 JNIEXPORT jint JNI_OnLoad_em05t001(JavaVM *jvm, char *options, void *reserved) {
306 return JNI_VERSION_1_8;
307 }
308 #endif
309 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
310
311 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
312 return JNI_ERR;
313
314 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
315
316 if (!NSK_VERIFY((jvmti =
317 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
318 return JNI_ERR;
319
320 {
321 jvmtiCapabilities caps;
322 memset(&caps, 0, sizeof(caps));
323 caps.can_generate_compiled_method_load_events = 1;
324 if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
325 return JNI_ERR;
326 }
327
328 {
329 jvmtiEventCallbacks eventCallbacks;
330 memset(&eventCallbacks, 0, sizeof(eventCallbacks));
331 eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
332 eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
333 if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
334 return JNI_ERR;
335 }
336
337 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
338 return JNI_ERR;
339
340 return JNI_OK;
341 }
342
343 /* ============================================================================= */
344
345 }
|