< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/threadstart002.cpp

Print this page
rev 52200 : [mq]: spaces


 128         result = STATUS_FAILED;
 129         NSK_COMPLAIN0("[agent] failed to notify about agent_start_lock\n");
 130     }
 131 
 132     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, agent_start_lock))) {
 133         result = STATUS_FAILED;
 134         NSK_COMPLAIN0("[agent] failed to release agent_start_lock\n");
 135     }
 136 
 137     NSK_DISPLAY0(">>> [agent] agent created\n");
 138 
 139     debug_agent_started = JNI_TRUE;
 140 
 141     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, thr_start_lock))) {
 142         result = STATUS_FAILED;
 143         NSK_COMPLAIN0("[agent] failed to enter thr_start_lock\n");
 144     }
 145 
 146     while (terminate_debug_agent != JNI_TRUE) {
 147 
 148         if (next_thread == NULL ) {
 149             /* wait till new thread will be created and started */
 150             if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait, jvmti, thr_start_lock, (jlong)0))) {
 151                 result = STATUS_FAILED;
 152                 NSK_COMPLAIN0("[agent] Failed while waiting thr_start_lock\n");
 153             }
 154         }
 155 
 156         if (next_thread != NULL) {
 157             /* hmm, why NewGlobalRef is called one more time???
 158              * next_thread = NSK_CPP_STUB2(NewGlobalRef, env, next_thread);
 159              */
 160             if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(SuspendThread, jvmti, next_thread))) {
 161                 result = STATUS_FAILED;
 162                 NSK_COMPLAIN1("[agent] Failed to suspend thread#%d\n", eventsCount);
 163             }
 164 
 165             NSK_DISPLAY2(">>> [agent] thread#%d %s suspended ...\n", eventsCount, inf.name);
 166 
 167             /* these dummy calls provoke VM to hang */
 168             temp = NSK_CPP_STUB2(NewGlobalRef, env, next_thread);


 304             result = STATUS_FAILED;
 305         }
 306 
 307         /* Store thread */
 308         next_thread = NSK_CPP_STUB2(NewGlobalRef, env, thread);
 309         debug_agent_timed_out = JNI_TRUE;
 310 
 311         /* Notify agent thread about new started thread and let agent thread to work with it */
 312         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorNotify, jvmti_env, thr_start_lock))) {
 313             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to notify about thr_start_lock\n", eventsCount);
 314             result = STATUS_FAILED;
 315         }
 316 
 317         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_start_lock))) {
 318             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_start_lock\n", eventsCount);
 319             result = STATUS_FAILED;
 320         }
 321 
 322         /* Wait till this started thread will be resumed by agent thread */
 323         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait,
 324                 jvmti_env, thr_resume_lock, (jlong)WAIT_TIME ))) {
 325             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed while waiting for thr_resume_lock\n", eventsCount);
 326             result = STATUS_FAILED;
 327         }
 328 
 329         if (debug_agent_timed_out == JNI_TRUE) {
 330             NSK_COMPLAIN1("[ThreadStart hook] \"%s\": debug agent timed out\n", inf.name);
 331             NSK_CPP_STUB2(FatalError, env, "[ThreadStart hook] could not recover");
 332         }
 333 
 334         /* Release thr_resume_lock lock */
 335         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_resume_lock))) {
 336             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_resume_lock\n", eventsCount);
 337             result = STATUS_FAILED;
 338         }
 339 
 340         /* check that thread is not in SUSPENDED state */
 341         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadState, jvmti_env, thread, &thrStat))) {
 342             NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread state for thread#%d\n", eventsCount);
 343             result = STATUS_FAILED;
 344         }




 128         result = STATUS_FAILED;
 129         NSK_COMPLAIN0("[agent] failed to notify about agent_start_lock\n");
 130     }
 131 
 132     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, agent_start_lock))) {
 133         result = STATUS_FAILED;
 134         NSK_COMPLAIN0("[agent] failed to release agent_start_lock\n");
 135     }
 136 
 137     NSK_DISPLAY0(">>> [agent] agent created\n");
 138 
 139     debug_agent_started = JNI_TRUE;
 140 
 141     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, thr_start_lock))) {
 142         result = STATUS_FAILED;
 143         NSK_COMPLAIN0("[agent] failed to enter thr_start_lock\n");
 144     }
 145 
 146     while (terminate_debug_agent != JNI_TRUE) {
 147 
 148         if (next_thread == NULL) {
 149             /* wait till new thread will be created and started */
 150             if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait, jvmti, thr_start_lock, (jlong)0))) {
 151                 result = STATUS_FAILED;
 152                 NSK_COMPLAIN0("[agent] Failed while waiting thr_start_lock\n");
 153             }
 154         }
 155 
 156         if (next_thread != NULL) {
 157             /* hmm, why NewGlobalRef is called one more time???
 158              * next_thread = NSK_CPP_STUB2(NewGlobalRef, env, next_thread);
 159              */
 160             if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(SuspendThread, jvmti, next_thread))) {
 161                 result = STATUS_FAILED;
 162                 NSK_COMPLAIN1("[agent] Failed to suspend thread#%d\n", eventsCount);
 163             }
 164 
 165             NSK_DISPLAY2(">>> [agent] thread#%d %s suspended ...\n", eventsCount, inf.name);
 166 
 167             /* these dummy calls provoke VM to hang */
 168             temp = NSK_CPP_STUB2(NewGlobalRef, env, next_thread);


 304             result = STATUS_FAILED;
 305         }
 306 
 307         /* Store thread */
 308         next_thread = NSK_CPP_STUB2(NewGlobalRef, env, thread);
 309         debug_agent_timed_out = JNI_TRUE;
 310 
 311         /* Notify agent thread about new started thread and let agent thread to work with it */
 312         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorNotify, jvmti_env, thr_start_lock))) {
 313             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to notify about thr_start_lock\n", eventsCount);
 314             result = STATUS_FAILED;
 315         }
 316 
 317         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_start_lock))) {
 318             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_start_lock\n", eventsCount);
 319             result = STATUS_FAILED;
 320         }
 321 
 322         /* Wait till this started thread will be resumed by agent thread */
 323         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait,
 324                 jvmti_env, thr_resume_lock, (jlong)WAIT_TIME))) {
 325             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed while waiting for thr_resume_lock\n", eventsCount);
 326             result = STATUS_FAILED;
 327         }
 328 
 329         if (debug_agent_timed_out == JNI_TRUE) {
 330             NSK_COMPLAIN1("[ThreadStart hook] \"%s\": debug agent timed out\n", inf.name);
 331             NSK_CPP_STUB2(FatalError, env, "[ThreadStart hook] could not recover");
 332         }
 333 
 334         /* Release thr_resume_lock lock */
 335         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_resume_lock))) {
 336             NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_resume_lock\n", eventsCount);
 337             result = STATUS_FAILED;
 338         }
 339 
 340         /* check that thread is not in SUSPENDED state */
 341         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadState, jvmti_env, thread, &thrStat))) {
 342             NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread state for thread#%d\n", eventsCount);
 343             result = STATUS_FAILED;
 344         }


< prev index next >