135 return;
136
137 NSK_DISPLAY0("Clean data\n");
138 if (!clean()) {
139 nsk_jvmti_setFailStatus();
140 return;
141 }
142 }
143
144 NSK_DISPLAY0("Let debuggee to finish\n");
145 if (!nsk_jvmti_resumeSync())
146 return;
147 }
148
149 /* ============================================================================= */
150
151 /**
152 * Generate tested events (COMPILED_METHOD_LOAD only).
153 */
154 static int generateEvents() {
155 if (!NSK_JVMTI_VERIFY(
156 NSK_CPP_STUB2(GenerateEvents, jvmti, JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
157 nsk_jvmti_setFailStatus();
158 return NSK_FALSE;
159 }
160 return NSK_TRUE;
161 }
162
163 /**
164 * Prepare data.
165 * - find tested thread
166 * - get tested methodIDs
167 * - enable events
168 */
169 static int prepare() {
170 jclass debugeeClass = NULL;
171 jclass threadClass = NULL;
172 jfieldID threadFieldID = NULL;
173 jthread thread = NULL;
174 int i;
175
176 for (i = 0; i < METHODS_COUNT; i++) {
177 int j;
178 methodsDesc[i].method = (jmethodID)NULL;
179 methodsDesc[i].compiled = NSK_FALSE;
180 for (j = 0; j < MOMENTS_COUNT; j++) {
181 methodsDesc[i].loadEvents[j] = 0;
182 methodsDesc[i].unloadEvents[j] = 0;
183 }
184 }
185
186 if (!NSK_JNI_VERIFY(jni, (debugeeClass =
187 NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL))
188 return NSK_FALSE;
189
190 if (!NSK_JNI_VERIFY(jni, (threadFieldID =
191 NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass,
192 THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != NULL))
193 return NSK_FALSE;
194
195 if (!NSK_JNI_VERIFY(jni, (thread = (jthread)
196 NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, threadFieldID)) != NULL))
197 return NSK_FALSE;
198
199 if (!NSK_JNI_VERIFY(jni, (threadClass =
200 NSK_CPP_STUB2(GetObjectClass, jni, thread)) != NULL))
201 return NSK_FALSE;
202
203 NSK_DISPLAY0("Find tested methods:\n");
204 for (i = 0; i < METHODS_COUNT; i++) {
205 if (!NSK_JNI_VERIFY(jni, (methodsDesc[i].method =
206 NSK_CPP_STUB4(GetMethodID, jni, threadClass,
207 methodsDesc[i].methodName, methodsDesc[i].methodSig)) != NULL))
208 return NSK_FALSE;
209 NSK_DISPLAY3(" method #%d (%s): 0x%p\n",
210 i, methodsDesc[i].methodName, (void*)methodsDesc[i].method);
211 }
212
213 NSK_DISPLAY0("Enable events\n");
214 if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL))
215 return NSK_FALSE;
216
217 return NSK_TRUE;
218 }
219
220 /**
221 * Testcase: check tested events.
222 * - check if expected events received for each method
223 *
224 * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
225 */
226 static int checkEvents() {
227 int i;
378 }
379 JNIEXPORT jint JNI_OnLoad_em05t002(JavaVM *jvm, char *options, void *reserved) {
380 return JNI_VERSION_1_8;
381 }
382 #endif
383 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
384
385 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
386 return JNI_ERR;
387
388 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
389
390 if (!NSK_VERIFY((jvmti =
391 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
392 return JNI_ERR;
393
394 {
395 jvmtiCapabilities caps;
396 memset(&caps, 0, sizeof(caps));
397 caps.can_generate_compiled_method_load_events = 1;
398 if (!NSK_JVMTI_VERIFY(
399 NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
400 return JNI_ERR;
401 }
402
403 {
404 jvmtiEventCallbacks eventCallbacks;
405 memset(&eventCallbacks, 0, sizeof(eventCallbacks));
406 eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
407 eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
408 if (!NSK_JVMTI_VERIFY(
409 NSK_CPP_STUB3(SetEventCallbacks, jvmti,
410 &eventCallbacks, sizeof(eventCallbacks))))
411 return JNI_ERR;
412 }
413
414 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
415 return JNI_ERR;
416
417 return JNI_OK;
418 }
419
420 /* ============================================================================= */
421
422 }
|
135 return;
136
137 NSK_DISPLAY0("Clean data\n");
138 if (!clean()) {
139 nsk_jvmti_setFailStatus();
140 return;
141 }
142 }
143
144 NSK_DISPLAY0("Let debuggee to finish\n");
145 if (!nsk_jvmti_resumeSync())
146 return;
147 }
148
149 /* ============================================================================= */
150
151 /**
152 * Generate tested events (COMPILED_METHOD_LOAD only).
153 */
154 static int generateEvents() {
155 if (!NSK_JVMTI_VERIFY(jvmti->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
156 nsk_jvmti_setFailStatus();
157 return NSK_FALSE;
158 }
159 return NSK_TRUE;
160 }
161
162 /**
163 * Prepare data.
164 * - find tested thread
165 * - get tested methodIDs
166 * - enable events
167 */
168 static int prepare() {
169 jclass debugeeClass = NULL;
170 jclass threadClass = NULL;
171 jfieldID threadFieldID = NULL;
172 jthread thread = NULL;
173 int i;
174
175 for (i = 0; i < METHODS_COUNT; i++) {
176 int j;
177 methodsDesc[i].method = (jmethodID)NULL;
178 methodsDesc[i].compiled = NSK_FALSE;
179 for (j = 0; j < MOMENTS_COUNT; j++) {
180 methodsDesc[i].loadEvents[j] = 0;
181 methodsDesc[i].unloadEvents[j] = 0;
182 }
183 }
184
185 if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL))
186 return NSK_FALSE;
187
188 if (!NSK_JNI_VERIFY(jni, (threadFieldID =
189 jni->GetStaticFieldID(debugeeClass, THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != NULL))
190 return NSK_FALSE;
191
192 if (!NSK_JNI_VERIFY(jni, (thread = (jthread)
193 jni->GetStaticObjectField(debugeeClass, threadFieldID)) != NULL))
194 return NSK_FALSE;
195
196 if (!NSK_JNI_VERIFY(jni, (threadClass = jni->GetObjectClass(thread)) != NULL))
197 return NSK_FALSE;
198
199 NSK_DISPLAY0("Find tested methods:\n");
200 for (i = 0; i < METHODS_COUNT; i++) {
201 if (!NSK_JNI_VERIFY(jni, (methodsDesc[i].method =
202 jni->GetMethodID(threadClass, methodsDesc[i].methodName, methodsDesc[i].methodSig)) != NULL))
203 return NSK_FALSE;
204 NSK_DISPLAY3(" method #%d (%s): 0x%p\n",
205 i, methodsDesc[i].methodName, (void*)methodsDesc[i].method);
206 }
207
208 NSK_DISPLAY0("Enable events\n");
209 if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL))
210 return NSK_FALSE;
211
212 return NSK_TRUE;
213 }
214
215 /**
216 * Testcase: check tested events.
217 * - check if expected events received for each method
218 *
219 * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
220 */
221 static int checkEvents() {
222 int i;
373 }
374 JNIEXPORT jint JNI_OnLoad_em05t002(JavaVM *jvm, char *options, void *reserved) {
375 return JNI_VERSION_1_8;
376 }
377 #endif
378 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
379
380 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
381 return JNI_ERR;
382
383 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
384
385 if (!NSK_VERIFY((jvmti =
386 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
387 return JNI_ERR;
388
389 {
390 jvmtiCapabilities caps;
391 memset(&caps, 0, sizeof(caps));
392 caps.can_generate_compiled_method_load_events = 1;
393 if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
394 return JNI_ERR;
395 }
396
397 {
398 jvmtiEventCallbacks eventCallbacks;
399 memset(&eventCallbacks, 0, sizeof(eventCallbacks));
400 eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
401 eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
402 if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
403 return JNI_ERR;
404 }
405
406 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
407 return JNI_ERR;
408
409 return JNI_OK;
410 }
411
412 /* ============================================================================= */
413
414 }
|