112 return ec_jni->GetStaticObjectField(klass, fieldID, TRACE_JNI_CALL); |
112 return ec_jni->GetStaticObjectField(klass, fieldID, TRACE_JNI_CALL); |
113 } |
113 } |
114 |
114 |
115 /* ============================================================================= */ |
115 /* ============================================================================= */ |
116 |
116 |
117 static int prepare() { |
117 static bool prepare() { |
118 |
118 |
119 ExceptionCheckingJniEnvPtr ec_jni(jni); |
119 ExceptionCheckingJniEnvPtr ec_jni(jni); |
120 mainThread = findThread(MAIN_THREAD_NAME); |
120 mainThread = findThread(MAIN_THREAD_NAME); |
121 if (!NSK_VERIFY(mainThread != NULL)) { |
121 if (!NSK_VERIFY(mainThread != NULL)) { |
122 NSK_COMPLAIN1("<%s> thread not found\n", MAIN_THREAD_NAME); |
122 NSK_COMPLAIN1("<%s> thread not found\n", MAIN_THREAD_NAME); |
123 return NSK_FALSE; |
123 return false; |
124 } |
124 } |
125 |
125 |
126 /* make thread accessable for a long time */ |
126 /* make thread accessable for a long time */ |
127 mainThread = ec_jni->NewGlobalRef(mainThread, TRACE_JNI_CALL); |
127 mainThread = ec_jni->NewGlobalRef(mainThread, TRACE_JNI_CALL); |
128 startObject = getStaticObjField(DEBUGEE_CLASS_NAME, START_FIELD_NAME, OBJECT_FIELD_SIG); |
128 startObject = getStaticObjField(DEBUGEE_CLASS_NAME, START_FIELD_NAME, OBJECT_FIELD_SIG); |
129 if (!NSK_VERIFY(startObject != NULL)) |
129 if (!NSK_VERIFY(startObject != NULL)) |
130 return NSK_FALSE; |
130 return false; |
131 |
131 |
132 /*make object accessable for a long time*/ |
132 /*make object accessable for a long time*/ |
133 startObject = ec_jni->NewGlobalRef(startObject, TRACE_JNI_CALL); |
133 startObject = ec_jni->NewGlobalRef(startObject, TRACE_JNI_CALL); |
134 |
134 |
135 endObject = getStaticObjField(DEBUGEE_CLASS_NAME, END_FIELD_NAME, OBJECT_FIELD_SIG); |
135 endObject = getStaticObjField(DEBUGEE_CLASS_NAME, END_FIELD_NAME, OBJECT_FIELD_SIG); |
136 if (!NSK_VERIFY(endObject != NULL)) |
136 if (!NSK_VERIFY(endObject != NULL)) |
137 return NSK_FALSE; |
137 return false; |
138 |
138 |
139 /*make object accessable for a long time*/ |
139 /*make object accessable for a long time*/ |
140 endObject = ec_jni->NewGlobalRef(endObject, TRACE_JNI_CALL); |
140 endObject = ec_jni->NewGlobalRef(endObject, TRACE_JNI_CALL); |
141 |
141 |
142 debuggeeThread = (jthread) getStaticObjField(DEBUGEE_CLASS_NAME, |
142 debuggeeThread = (jthread) getStaticObjField(DEBUGEE_CLASS_NAME, |
143 THREAD_FIELD_NAME, |
143 THREAD_FIELD_NAME, |
144 THREAD_FIELD_SIG); |
144 THREAD_FIELD_SIG); |
145 if (!NSK_VERIFY(debuggeeThread != NULL)) |
145 if (!NSK_VERIFY(debuggeeThread != NULL)) |
146 return NSK_FALSE; |
146 return false; |
147 |
147 |
148 /* make thread accessable for a long time */ |
148 /* make thread accessable for a long time */ |
149 debuggeeThread = ec_jni->NewGlobalRef(debuggeeThread, TRACE_JNI_CALL); |
149 debuggeeThread = ec_jni->NewGlobalRef(debuggeeThread, TRACE_JNI_CALL); |
150 return NSK_TRUE; |
150 return true; |
151 } |
151 } |
152 |
152 |
153 /* ============================================================================= */ |
153 /* ============================================================================= */ |
154 |
154 |
155 static int |
155 static bool clean() { |
156 clean() { |
|
157 |
156 |
158 ExceptionCheckingJniEnvPtr ec_jni(jni); |
157 ExceptionCheckingJniEnvPtr ec_jni(jni); |
159 /* disable MonitorContendedEnter event */ |
158 /* disable MonitorContendedEnter event */ |
160 if (!NSK_JVMTI_VERIFY( |
159 if (!NSK_JVMTI_VERIFY( |
161 jvmti->SetEventNotificationMode( |
160 jvmti->SetEventNotificationMode( |
275 if (currentCounts[i] != 1) { |
274 if (currentCounts[i] != 1) { |
276 nsk_jvmti_setFailStatus(); |
275 nsk_jvmti_setFailStatus(); |
277 NSK_COMPLAIN2("Unexpected events number %7d for %s\n\texpected value is 1\n", |
276 NSK_COMPLAIN2("Unexpected events number %7d for %s\n\texpected value is 1\n", |
278 currentCounts[i], |
277 currentCounts[i], |
279 TranslateEvent(curr)); |
278 TranslateEvent(curr)); |
280 result = NSK_FALSE; |
279 result = false; |
281 } |
280 } |
282 } else { |
281 } else { |
283 if (currentCounts[i] > 0) { |
282 if (currentCounts[i] > 0) { |
284 NSK_COMPLAIN2("Unexpected event %s was sent %d times\n", |
283 NSK_COMPLAIN2("Unexpected event %s was sent %d times\n", |
285 TranslateEvent(curr), |
284 TranslateEvent(curr), |
286 currentCounts[i]); |
285 currentCounts[i]); |
287 result = NSK_FALSE; |
286 result = false; |
288 } |
287 } |
289 } |
288 } |
290 } |
289 } |
291 |
290 |
292 return result; |
291 return result; |
544 debuggeeThread, endObject); |
543 debuggeeThread, endObject); |
545 } |
544 } |
546 |
545 |
547 /* ============================================================================= */ |
546 /* ============================================================================= */ |
548 |
547 |
549 static int enableEvent(jvmtiEvent event) { |
548 static bool enableEvent(jvmtiEvent event) { |
550 |
549 |
551 if (nsk_jvmti_isOptionalEvent(event) |
550 if (nsk_jvmti_isOptionalEvent(event) |
552 && (event != JVMTI_EVENT_MONITOR_CONTENDED_ENTER) |
551 && (event != JVMTI_EVENT_MONITOR_CONTENDED_ENTER) |
553 && (event != JVMTI_EVENT_MONITOR_CONTENDED_ENTERED) |
552 && (event != JVMTI_EVENT_MONITOR_CONTENDED_ENTERED) |
554 && (event != JVMTI_EVENT_MONITOR_WAIT) |
553 && (event != JVMTI_EVENT_MONITOR_WAIT) |
555 && (event != JVMTI_EVENT_MONITOR_WAITED)) { |
554 && (event != JVMTI_EVENT_MONITOR_WAITED)) { |
556 if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, |
555 if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, |
557 jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { |
556 jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { |
558 NSK_COMPLAIN1("Unexpected error enabling %s\n", |
557 NSK_COMPLAIN1("Unexpected error enabling %s\n", |
559 TranslateEvent(event)); |
558 TranslateEvent(event)); |
560 return NSK_FALSE; |
559 return false; |
561 } |
560 } |
562 } else { |
561 } else { |
563 if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { |
562 if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { |
564 NSK_COMPLAIN1("Unexpected error enabling %s\n", |
563 NSK_COMPLAIN1("Unexpected error enabling %s\n", |
565 TranslateEvent(event)); |
564 TranslateEvent(event)); |
566 return NSK_FALSE; |
565 return false; |
567 } |
566 } |
568 } |
567 } |
569 |
568 |
570 return NSK_TRUE; |
569 return true; |
571 } |
570 } |
572 |
571 |
573 static int enableEventList() { |
572 static bool enableEventList() { |
574 int i; |
573 int i; |
575 int result = NSK_TRUE; |
574 bool result = true; |
576 |
575 |
577 NSK_DISPLAY0("Enable events\n"); |
576 NSK_DISPLAY0("Enable events\n"); |
578 |
577 |
579 result = enableEvent(JVMTI_EVENT_VM_INIT); |
578 result = enableEvent(JVMTI_EVENT_VM_INIT); |
580 |
579 |
586 |
585 |
587 if (nsk_jvmti_isOptionalEvent(event)) |
586 if (nsk_jvmti_isOptionalEvent(event)) |
588 result = result && enableEvent(event); |
587 result = result && enableEvent(event); |
589 } |
588 } |
590 |
589 |
591 if (result == NSK_FALSE) { |
590 if (!result) { |
592 nsk_jvmti_setFailStatus(); |
591 nsk_jvmti_setFailStatus(); |
593 return NSK_FALSE; |
592 return false; |
594 } |
593 } |
595 |
594 |
596 return NSK_TRUE; |
595 return true; |
597 } |
596 } |
598 |
597 |
599 /* ============================================================================= */ |
598 /* ============================================================================= */ |
600 |
599 |
601 static int |
600 static bool setCallBacks(int step) { |
602 setCallBacks(int step) { |
|
603 |
601 |
604 int i; |
602 int i; |
605 |
603 |
606 jvmtiEventCallbacks eventCallbacks; |
604 jvmtiEventCallbacks eventCallbacks; |
607 memset(&eventCallbacks, 0, sizeof(eventCallbacks)); |
605 memset(&eventCallbacks, 0, sizeof(eventCallbacks)); |