228 jint millis;
229 jboolean timeout_is_reached;
230 unsigned int waited_millis;
231
232 if (jvmti == NULL) {
233 printf("JVMTI client was not properly loaded!\n");
234 result = STATUS_FAILED;
235 return;
236 }
237
238 if (thr_ptr == NULL) {
239 printf("Missing thread \"thr1\" start event\n");
240 result = STATUS_FAILED;
241 return;
242 }
243
244 if (!caps.can_suspend) {
245 return;
246 }
247
248 printf( "START checkStatus for \"thr1\" (0x%p%s), check state: %s\n",
249 thr_ptr, suspStr, TranslateState(state[statInd]) );
250
251 timeout_is_reached = JNI_TRUE;
252 for (millis = WAIT_START, waited_millis=0; millis < wait_time; millis <<= 1) {
253 err = jvmti->GetThreadState(thr_ptr, &thrState);
254 if (err != JVMTI_ERROR_NONE) {
255 printf("(GetThreadState#%d) unexpected error: %s (%d)\n",
256 statInd, TranslateError(err), err);
257 result = STATUS_FAILED;
258 timeout_is_reached = JNI_FALSE;
259 break;
260 }
261 suspState = thrState & JVMTI_THREAD_STATE_SUSPENDED;
262 if (suspended || (thrState & JVMTI_THREAD_STATE_RUNNABLE) == 0 ||
263 (state[statInd] == JVMTI_THREAD_STATE_RUNNABLE)) {
264 timeout_is_reached = JNI_FALSE;
265 break;
266 }
267
268 waited_millis += millis;
269 wait_for(millis);
|
228 jint millis;
229 jboolean timeout_is_reached;
230 unsigned int waited_millis;
231
232 if (jvmti == NULL) {
233 printf("JVMTI client was not properly loaded!\n");
234 result = STATUS_FAILED;
235 return;
236 }
237
238 if (thr_ptr == NULL) {
239 printf("Missing thread \"thr1\" start event\n");
240 result = STATUS_FAILED;
241 return;
242 }
243
244 if (!caps.can_suspend) {
245 return;
246 }
247
248 printf("START checkStatus for \"thr1\" (0x%p%s), check state: %s\n",
249 thr_ptr, suspStr, TranslateState(state[statInd]));
250
251 timeout_is_reached = JNI_TRUE;
252 for (millis = WAIT_START, waited_millis=0; millis < wait_time; millis <<= 1) {
253 err = jvmti->GetThreadState(thr_ptr, &thrState);
254 if (err != JVMTI_ERROR_NONE) {
255 printf("(GetThreadState#%d) unexpected error: %s (%d)\n",
256 statInd, TranslateError(err), err);
257 result = STATUS_FAILED;
258 timeout_is_reached = JNI_FALSE;
259 break;
260 }
261 suspState = thrState & JVMTI_THREAD_STATE_SUSPENDED;
262 if (suspended || (thrState & JVMTI_THREAD_STATE_RUNNABLE) == 0 ||
263 (state[statInd] == JVMTI_THREAD_STATE_RUNNABLE)) {
264 timeout_is_reached = JNI_FALSE;
265 break;
266 }
267
268 waited_millis += millis;
269 wait_for(millis);
|