< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst002/resumethrdlst002.cpp

Print this page
rev 52200 : [mq]: spaces


 233     for (i = 0; i < foundCount; i++) {
 234         if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread)
 235                     jni->NewGlobalRef(foundThreads[i])) != NULL)) {
 236             nsk_jvmti_setFailStatus();
 237             return NSK_FALSE;
 238         }
 239         NSK_DISPLAY2("  ... thread #%d: %p\n", i, foundThreads[i]);
 240     }
 241 
 242     return NSK_TRUE;
 243 }
 244 
 245 /* ============================================================================= */
 246 
 247 /** THREAD_END callback. */
 248 JNIEXPORT void JNICALL
 249 callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
 250     int i = 0;
 251 
 252     jvmtiError e = jvmti->RawMonitorEnter(eventsReceivedMtx);
 253     if ( !NSK_JVMTI_VERIFY(e) ) {
 254         NSK_DISPLAY1("  ... ERROR entering raw monitor for thread %p\n", (void *) thread);
 255         return;
 256     }
 257 
 258     /* check if event is for tested thread */
 259     for (i = 0; i < threadsCount; i++) {
 260         if (thread != NULL &&
 261                 jni->IsSameObject(threads[i], thread)) {
 262             NSK_DISPLAY2("  ... received THREAD_END event for thread #%d: %p\n",
 263                                                                     i, (void*)thread);
 264             eventsReceived++;
 265             jvmti->RawMonitorExit(eventsReceivedMtx);
 266             return;
 267         }
 268     }
 269     jvmti->RawMonitorExit(eventsReceivedMtx);
 270     NSK_DISPLAY1("  ... received THREAD_END event for unknown thread: %p\n", (void*)thread);
 271 }
 272 
 273 /* ============================================================================= */


 306     /* add specific capabilities for suspending thread */
 307     {
 308         jvmtiCapabilities suspendCaps;
 309         memset(&suspendCaps, 0, sizeof(suspendCaps));
 310         suspendCaps.can_suspend = 1;
 311         if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
 312             return JNI_ERR;
 313     }
 314 
 315     /* set callbacks for THREAD_END event */
 316     {
 317         jvmtiEventCallbacks callbacks;
 318         memset(&callbacks, 0, sizeof(callbacks));
 319         callbacks.ThreadEnd = callbackThreadEnd;
 320         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
 321         return JNI_ERR;
 322     }
 323 
 324     /* create a mutex for the eventsReceived variable */
 325     {
 326         if ( ! NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("eventsReceived", &eventsReceivedMtx))) {
 327             return JNI_ERR;
 328         }
 329     }
 330 
 331     /* register agent proc and arg */
 332     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 333         return JNI_ERR;
 334 
 335     return JNI_OK;
 336 }
 337 
 338 /* ============================================================================= */
 339 
 340 }


 233     for (i = 0; i < foundCount; i++) {
 234         if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread)
 235                     jni->NewGlobalRef(foundThreads[i])) != NULL)) {
 236             nsk_jvmti_setFailStatus();
 237             return NSK_FALSE;
 238         }
 239         NSK_DISPLAY2("  ... thread #%d: %p\n", i, foundThreads[i]);
 240     }
 241 
 242     return NSK_TRUE;
 243 }
 244 
 245 /* ============================================================================= */
 246 
 247 /** THREAD_END callback. */
 248 JNIEXPORT void JNICALL
 249 callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
 250     int i = 0;
 251 
 252     jvmtiError e = jvmti->RawMonitorEnter(eventsReceivedMtx);
 253     if (!NSK_JVMTI_VERIFY(e)) {
 254         NSK_DISPLAY1("  ... ERROR entering raw monitor for thread %p\n", (void *) thread);
 255         return;
 256     }
 257 
 258     /* check if event is for tested thread */
 259     for (i = 0; i < threadsCount; i++) {
 260         if (thread != NULL &&
 261                 jni->IsSameObject(threads[i], thread)) {
 262             NSK_DISPLAY2("  ... received THREAD_END event for thread #%d: %p\n",
 263                                                                     i, (void*)thread);
 264             eventsReceived++;
 265             jvmti->RawMonitorExit(eventsReceivedMtx);
 266             return;
 267         }
 268     }
 269     jvmti->RawMonitorExit(eventsReceivedMtx);
 270     NSK_DISPLAY1("  ... received THREAD_END event for unknown thread: %p\n", (void*)thread);
 271 }
 272 
 273 /* ============================================================================= */


 306     /* add specific capabilities for suspending thread */
 307     {
 308         jvmtiCapabilities suspendCaps;
 309         memset(&suspendCaps, 0, sizeof(suspendCaps));
 310         suspendCaps.can_suspend = 1;
 311         if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
 312             return JNI_ERR;
 313     }
 314 
 315     /* set callbacks for THREAD_END event */
 316     {
 317         jvmtiEventCallbacks callbacks;
 318         memset(&callbacks, 0, sizeof(callbacks));
 319         callbacks.ThreadEnd = callbackThreadEnd;
 320         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
 321         return JNI_ERR;
 322     }
 323 
 324     /* create a mutex for the eventsReceived variable */
 325     {
 326         if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("eventsReceived", &eventsReceivedMtx))) {
 327             return JNI_ERR;
 328         }
 329     }
 330 
 331     /* register agent proc and arg */
 332     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 333         return JNI_ERR;
 334 
 335     return JNI_OK;
 336 }
 337 
 338 /* ============================================================================= */
 339 
 340 }
< prev index next >