< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/share/JVMTIagent.cpp

Print this page
rev 51840 : [mq]: refactor

*** 158,171 **** if (hotswap != HOTSWAP_OFF) { /* enter into a raw monitor for exclusive work with redefined class */ lock(jni_env); display(0, "#### JVMTIagent: ClassLoad: >>>>>>>> entered the raw monitor \"eventLock\" ####\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, ! jvmti_env, klass, &cls_sig, /*&generic*/NULL))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to get class signature\n"); else { if (shortTestName != NULL) { if (strstr((const char*) cls_sig, shortTestName) != NULL) { display(0, "#### JVMTIagent: found test class matched with \"%s\"\n\ <JVMTIagent>\tsignature=%s\n", --- 158,169 ---- if (hotswap != HOTSWAP_OFF) { /* enter into a raw monitor for exclusive work with redefined class */ lock(jni_env); display(0, "#### JVMTIagent: ClassLoad: >>>>>>>> entered the raw monitor \"eventLock\" ####\n"); ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &cls_sig, /*&generic*/NULL))) ! jni_env->FatalError("JVMTIagent: failed to get class signature\n"); else { if (shortTestName != NULL) { if (strstr((const char*) cls_sig, shortTestName) != NULL) { display(0, "#### JVMTIagent: found test class matched with \"%s\"\n\ <JVMTIagent>\tsignature=%s\n",
*** 242,259 **** getVerdict(jni_env, "Exception"); if (hotswap == HOTSWAP_EVERY_EXCEPTION || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &decl_clazz))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to hotswap class\n"); } } void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *jni_env, --- 240,254 ---- getVerdict(jni_env, "Exception"); if (hotswap == HOTSWAP_EVERY_EXCEPTION || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &decl_clazz))) ! jni_env->FatalError("JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! jni_env->FatalError("JVMTIagent: failed to hotswap class\n"); } } void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
*** 416,433 **** "#### JVMTIagent: SingleStep occurred ####\n"); getVerdict(jni_env, "SingleStep"); if (hotswap == HOTSWAP_EVERY_SINGLE_STEP) { ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &decl_clazz))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to hotswap class\n"); } } void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, --- 411,425 ---- "#### JVMTIagent: SingleStep occurred ####\n"); getVerdict(jni_env, "SingleStep"); if (hotswap == HOTSWAP_EVERY_SINGLE_STEP) { ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &decl_clazz))) ! jni_env->FatalError("JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! jni_env->FatalError("JVMTIagent: failed to hotswap class\n"); } } void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
*** 440,457 **** getVerdict(jni_env, "MethodEntry"); if (hotswap == HOTSWAP_EVERY_METHOD_ENTRY || hotswap == HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS) { ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &decl_clazz))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to hotswap class\n"); } } void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, --- 432,446 ---- getVerdict(jni_env, "MethodEntry"); if (hotswap == HOTSWAP_EVERY_METHOD_ENTRY || hotswap == HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS) { ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &decl_clazz))) ! jni_env->FatalError("JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! jni_env->FatalError("JVMTIagent: failed to hotswap class\n"); } } void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
*** 474,507 **** getVerdict(jni_env, "ExceptionCatch"); if (hotswap == HOTSWAP_EVERY_EXCEPTION || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &decl_clazz))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to hotswap class\n"); } } /************************/ static void lock(JNIEnv *jni_env) { ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, ! jvmti, eventLock))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to enter a raw monitor\n"); } static void unlock(JNIEnv *jni_env) { ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, ! jvmti, eventLock))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to exit a raw monitor\n"); } JNIEXPORT jint JNICALL Java_nsk_share_RASagent_setHotSwapMode(JNIEnv *jni_env, jclass cls, jboolean vrb, jint level, jstring shortName) { --- 463,489 ---- getVerdict(jni_env, "ExceptionCatch"); if (hotswap == HOTSWAP_EVERY_EXCEPTION || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &decl_clazz))) ! jni_env->FatalError("JVMTIagent: failed to get method declaring class\n"); if (findAndHotSwap(jni_env, decl_clazz) != 0) ! jni_env->FatalError("JVMTIagent: failed to hotswap class\n"); } } /************************/ static void lock(JNIEnv *jni_env) { ! if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(eventLock))) ! jni_env->FatalError("JVMTIagent: failed to enter a raw monitor\n"); } static void unlock(JNIEnv *jni_env) { ! if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(eventLock))) ! jni_env->FatalError("JVMTIagent: failed to exit a raw monitor\n"); } JNIEXPORT jint JNICALL Java_nsk_share_RASagent_setHotSwapMode(JNIEnv *jni_env, jclass cls, jboolean vrb, jint level, jstring shortName) {
*** 513,526 **** __FILE__, __LINE__); return 1; } /* get supported JVMTI capabilities */ ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, ! jvmti, &capabil))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to get capabilities\n"); if (capabil.can_redefine_classes != 1) { /* ???????????? */ printf("ERROR: JVMTIagent: Class File Redefinition (HotSwap) is not implemented in this VM\n"); return 1; } --- 495,506 ---- __FILE__, __LINE__); return 1; } /* get supported JVMTI capabilities */ ! if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&capabil))) ! jni_env->FatalError("JVMTIagent: failed to get capabilities\n"); if (capabil.can_redefine_classes != 1) { /* ???????????? */ printf("ERROR: JVMTIagent: Class File Redefinition (HotSwap) is not implemented in this VM\n"); return 1; }
*** 566,585 **** printf("ERROR(%s,%d): JVMTIagent: unknown value of HotSwap stress level: \"%d\"\n", __FILE__,__LINE__,hotswap); return 1; } ! if (!NSK_JNI_VERIFY(jni_env, (shortTestName = NSK_CPP_STUB3(GetStringUTFChars, ! jni_env, shortName, NULL)) != NULL)) { printf("ERROR: JVMTIagent: unable to get UTF-8 characters of the string\n"); return 1; } display(0, "#### JVMTIagent: short name of current test is \"%s\"\n", shortTestName); ! if (!NSK_JNI_VERIFY(jni_env, (rasCls = NSK_CPP_STUB2(NewGlobalRef, ! jni_env, cls)) != NULL)) { printf("ERROR JVMTIagent: unable to create a new global reference of the class \"RASagent\"\n"); return 1; } if (addStressEvents() != 0) { --- 546,563 ---- printf("ERROR(%s,%d): JVMTIagent: unknown value of HotSwap stress level: \"%d\"\n", __FILE__,__LINE__,hotswap); return 1; } ! if (!NSK_JNI_VERIFY(jni_env, (shortTestName = jni_env->GetStringUTFChars(shortName, NULL)) != NULL)) { printf("ERROR: JVMTIagent: unable to get UTF-8 characters of the string\n"); return 1; } display(0, "#### JVMTIagent: short name of current test is \"%s\"\n", shortTestName); ! if (!NSK_JNI_VERIFY(jni_env, (rasCls = jni_env->NewGlobalRef(cls)) != NULL)) { printf("ERROR JVMTIagent: unable to create a new global reference of the class \"RASagent\"\n"); return 1; } if (addStressEvents() != 0) {
*** 597,637 **** jbyteArray classBytes; jboolean isCopy; if ((_clsInfo = (class_info*) malloc(sizeof(class_info))) == NULL) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: cannot allocate memory for class_info\n"); /* fill the structure class_info */ _clsInfo->clazzsig = cls_sig; ! if (!NSK_JNI_VERIFY(jni_env, ((*_clsInfo).cls = NSK_CPP_STUB2(NewGlobalRef, ! jni_env, clazz)) != NULL)) { printf("ERROR: JVMTIagent: unable to create a new global reference of class \"%s\"\n", _clsInfo->clazzsig); free(_clsInfo); deallocClsInfo(jni_env); ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: unable to create a new global reference of class\n"); } if (!NSK_JNI_VERIFY(jni_env, (mid = ! NSK_CPP_STUB4(GetStaticMethodID, jni_env, rasCls, ! "loadFromClassFile", "(Ljava/lang/String;)[B")) != NULL)) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: unable to get ID of the method \"loadFromClassFile\"\n"); ! classBytes = (jbyteArray) NSK_CPP_STUB4(CallStaticObjectMethod, ! jni_env, rasCls, mid, NSK_CPP_STUB2(NewStringUTF, jni_env, cls_sig)); clearJavaException(jni_env); ! (*_clsInfo).bCount = NSK_CPP_STUB2(GetArrayLength, jni_env, classBytes); (*_clsInfo).clsBytes = ! NSK_CPP_STUB3(GetByteArrayElements, jni_env, classBytes, &isCopy); _clsInfo->next = NULL; if (clsInfo != NULL) { clsInfo->next = (struct class_info*) _clsInfo; --- 575,609 ---- jbyteArray classBytes; jboolean isCopy; if ((_clsInfo = (class_info*) malloc(sizeof(class_info))) == NULL) ! jni_env->FatalError("JVMTIagent: cannot allocate memory for class_info\n"); /* fill the structure class_info */ _clsInfo->clazzsig = cls_sig; ! if (!NSK_JNI_VERIFY(jni_env, ((*_clsInfo).cls = jni_env->NewGlobalRef(clazz)) != NULL)) { printf("ERROR: JVMTIagent: unable to create a new global reference of class \"%s\"\n", _clsInfo->clazzsig); free(_clsInfo); deallocClsInfo(jni_env); ! jni_env->FatalError("JVMTIagent: unable to create a new global reference of class\n"); } if (!NSK_JNI_VERIFY(jni_env, (mid = ! jni_env->GetStaticMethodID(rasCls, "loadFromClassFile", "(Ljava/lang/String;)[B")) != NULL)) ! jni_env->FatalError("JVMTIagent: unable to get ID of the method \"loadFromClassFile\"\n"); ! classBytes = (jbyteArray) jni_env->CallStaticObjectMethod(rasCls, mid, jni_env->NewStringUTF(cls_sig)); clearJavaException(jni_env); ! (*_clsInfo).bCount = jni_env->GetArrayLength(classBytes); (*_clsInfo).clsBytes = ! jni_env->GetByteArrayElements(classBytes, &isCopy); _clsInfo->next = NULL; if (clsInfo != NULL) { clsInfo->next = (struct class_info*) _clsInfo;
*** 645,665 **** } static void deallocClsInfo(JNIEnv *jni_env) { class_info *clsInfoCurr = clsInfoFst; ! NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni_env, rasCls)); while(clsInfoCurr != NULL) { class_info *_clsInfo = clsInfoCurr; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, ! jvmti, (unsigned char*) clsInfoCurr->clazzsig))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: failed to deallocate memory for clazzsig\n"); ! NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni_env, clsInfoCurr->cls)); clsInfoCurr = (class_info*) clsInfoCurr->next; free(_clsInfo); } --- 617,635 ---- } static void deallocClsInfo(JNIEnv *jni_env) { class_info *clsInfoCurr = clsInfoFst; ! NSK_TRACE(jni_env->DeleteGlobalRef(rasCls)); while(clsInfoCurr != NULL) { class_info *_clsInfo = clsInfoCurr; ! if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) clsInfoCurr->clazzsig))) ! jni_env->FatalError("JVMTIagent: failed to deallocate memory for clazzsig\n"); ! NSK_TRACE(jni_env->DeleteGlobalRef(clsInfoCurr->cls)); clsInfoCurr = (class_info*) clsInfoCurr->next; free(_clsInfo); }
*** 671,684 **** int ret_code = 0; char *clazzsig = NULL; class_info *clsInfoCurr = clsInfoFst; display(1, "\n#### JVMTIagent: findAndHotSwap: obtaining class signature of class to be hotswap ...\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, ! jvmti, clazz, &clazzsig, /*&generic*/NULL))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: findAndHotSwap: failed to get class signature\n"); else { display(1, "#### JVMTIagent: findAndHotSwap: ... class signature obtained: \"%s\"\n", clazzsig); /* enter into a raw monitor for exclusive work with redefined class */ --- 641,652 ---- int ret_code = 0; char *clazzsig = NULL; class_info *clsInfoCurr = clsInfoFst; display(1, "\n#### JVMTIagent: findAndHotSwap: obtaining class signature of class to be hotswap ...\n"); ! if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(clazz, &clazzsig, /*&generic*/NULL))) ! jni_env->FatalError("JVMTIagent: findAndHotSwap: failed to get class signature\n"); else { display(1, "#### JVMTIagent: findAndHotSwap: ... class signature obtained: \"%s\"\n", clazzsig); /* enter into a raw monitor for exclusive work with redefined class */
*** 688,701 **** while(clsInfoCurr != NULL) { if (hotswap == HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { display(1, "\n#### JVMTIagent: findAndHotSwap: going to hotswap tested class \"%s\" during execution of class \"%s\" ...\n", clsInfoCurr->clazzsig, clazzsig); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, ! jvmti, (unsigned char*) clazzsig))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: findAndHotSwap: failed to deallocate memory for clazzsig\n"); if (doHotSwap(jni_env, clsInfoCurr->cls, clsInfoCurr->bCount, clsInfoCurr->clsBytes) != 0) { ret_code = 1; break; --- 656,667 ---- while(clsInfoCurr != NULL) { if (hotswap == HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { display(1, "\n#### JVMTIagent: findAndHotSwap: going to hotswap tested class \"%s\" during execution of class \"%s\" ...\n", clsInfoCurr->clazzsig, clazzsig); ! if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) clazzsig))) ! jni_env->FatalError("JVMTIagent: findAndHotSwap: failed to deallocate memory for clazzsig\n"); if (doHotSwap(jni_env, clsInfoCurr->cls, clsInfoCurr->bCount, clsInfoCurr->clsBytes) != 0) { ret_code = 1; break;
*** 704,717 **** else { if (strcmp(clazzsig, clsInfoCurr->clazzsig) == 0) { display(0, "\n#### JVMTIagent: findAndHotSwap: tested class found \"%s\" ...\n", clazzsig); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, ! jvmti, (unsigned char*) clazzsig))) ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: findAndHotSwap: failed to deallocate memory for clazzsig\n"); display(0, "\n#### JVMTIagent: findAndHotSwap: going to hotswap tested class \"%s\" ...\n", clsInfoCurr->clazzsig); if (doHotSwap(jni_env, clsInfoCurr->cls, clsInfoCurr->bCount, clsInfoCurr->clsBytes) != 0) { --- 670,681 ---- else { if (strcmp(clazzsig, clsInfoCurr->clazzsig) == 0) { display(0, "\n#### JVMTIagent: findAndHotSwap: tested class found \"%s\" ...\n", clazzsig); ! if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) clazzsig))) ! jni_env->FatalError("JVMTIagent: findAndHotSwap: failed to deallocate memory for clazzsig\n"); display(0, "\n#### JVMTIagent: findAndHotSwap: going to hotswap tested class \"%s\" ...\n", clsInfoCurr->clazzsig); if (doHotSwap(jni_env, clsInfoCurr->cls, clsInfoCurr->bCount, clsInfoCurr->clsBytes) != 0) {
*** 742,753 **** classDef.class_bytes = (unsigned char*) classBytes; display(0, "#### JVMTIagent: >>>>>>>> Invoke RedefineClasses():\n\ <JVMTIagent>\tnew class byte count=%d\n", classDef.class_byte_count); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RedefineClasses, ! jvmti, 1, &classDef))) return 1; display(0, "#### JVMTIagent: <<<<<<<< RedefineClasses() is successfully done ####\n"); return 0; --- 706,716 ---- classDef.class_bytes = (unsigned char*) classBytes; display(0, "#### JVMTIagent: >>>>>>>> Invoke RedefineClasses():\n\ <JVMTIagent>\tnew class byte count=%d\n", classDef.class_byte_count); ! if (!NSK_JVMTI_VERIFY(jvmti->RedefineClasses(1, &classDef))) return 1; display(0, "#### JVMTIagent: <<<<<<<< RedefineClasses() is successfully done ####\n"); return 0;
*** 763,774 **** if (stepEventSet == JNI_FALSE) { /* don't set the event twice */ display(0, "#### JVMTIagent: setting SingleStep events ...\n"); callbacks.SingleStep = &SingleStep; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) return JNI_ERR; stepEventSet = JNI_TRUE; display(0, "#### JVMTIagent: ... setting SingleStep events done\n"); --- 726,736 ---- if (stepEventSet == JNI_FALSE) { /* don't set the event twice */ display(0, "#### JVMTIagent: setting SingleStep events ...\n"); callbacks.SingleStep = &SingleStep; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) return JNI_ERR; stepEventSet = JNI_TRUE; display(0, "#### JVMTIagent: ... setting SingleStep events done\n");
*** 780,802 **** if (methodsEventSet == JNI_FALSE) { /* don't set the event twice */ display(0, "#### JVMTIagent: setting MethodEntry events ...\n"); callbacks.MethodEntry = &MethodEntry; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MethodEntry events done\n"); /* MethodExit events */ display(0, "#### JVMTIagent: setting MethodExit events ...\n"); callbacks.MethodExit = &MethodExit; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MethodExit events done\n"); methodsEventSet = JNI_TRUE; --- 742,762 ---- if (methodsEventSet == JNI_FALSE) { /* don't set the event twice */ display(0, "#### JVMTIagent: setting MethodEntry events ...\n"); callbacks.MethodEntry = &MethodEntry; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MethodEntry events done\n"); /* MethodExit events */ display(0, "#### JVMTIagent: setting MethodExit events ...\n"); callbacks.MethodExit = &MethodExit; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MethodExit events done\n"); methodsEventSet = JNI_TRUE;
*** 808,829 **** if (excCatchEventSet == JNI_FALSE) { /* don't set the event twice */ display(0, "#### JVMTIagent: setting ExceptionCatch events ...\n"); callbacks.ExceptionCatch = &ExceptionCatch; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL))) return JNI_ERR; excCatchEventSet = JNI_TRUE; display(0, "#### JVMTIagent: ... setting ExceptionCatch events done\n"); } } ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, ! jvmti, &callbacks, sizeof(callbacks)))) return JNI_ERR; else return 0; } --- 768,787 ---- if (excCatchEventSet == JNI_FALSE) { /* don't set the event twice */ display(0, "#### JVMTIagent: setting ExceptionCatch events ...\n"); callbacks.ExceptionCatch = &ExceptionCatch; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL))) return JNI_ERR; excCatchEventSet = JNI_TRUE; display(0, "#### JVMTIagent: ... setting ExceptionCatch events done\n"); } } ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)))) return JNI_ERR; else return 0; }
*** 847,1135 **** caps.can_generate_garbage_collection_events = 1; caps.can_generate_monitor_events = 1; caps.can_generate_native_method_bind_events = 1; caps.can_generate_object_free_events = 1; caps.can_generate_vm_object_alloc_events = 1; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, ! jvmti, &caps))) return JNI_ERR; /* Breakpoint events */ display(0, "#### JVMTIagent: setting Breakpoint events ...\n"); callbacks.Breakpoint = &Breakpoint; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting Breakpoint events done\n"); /* ClassFileLoadHook events */ display(0, "#### JVMTIagent: setting ClassFileLoadHook events ...\n"); callbacks.ClassFileLoadHook = &ClassFileLoadHook; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassFileLoadHook events done\n"); /* ClassLoad events */ display(0, "#### JVMTIagent: setting ClassLoad events ...\n"); callbacks.ClassLoad = &ClassLoad; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassLoad events done\n"); /* ClassPrepare events */ display(0, "#### JVMTIagent: setting ClassPrepare events ...\n"); callbacks.ClassPrepare = &ClassPrepare; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassPrepare events done\n"); /* CompiledMethodLoad events */ display(0, "#### JVMTIagent: setting CompiledMethodLoad events ...\n"); callbacks.CompiledMethodLoad = &CompiledMethodLoad; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting CompiledMethodLoad events done\n"); /* CompiledMethodUnload events */ display(0, "#### JVMTIagent: setting CompiledMethodUnload events ...\n"); callbacks.CompiledMethodUnload = &CompiledMethodUnload; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting CompiledMethodUnload events done\n"); /* DataDumpRequest events */ display(0, "#### JVMTIagent: setting DataDumpRequest events ...\n"); callbacks.DataDumpRequest = &DataDumpRequest; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_DATA_DUMP_REQUEST, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting DataDumpRequest events done\n"); /* DynamicCodeGenerated events */ display(0, "#### JVMTIagent: setting DynamicCodeGenerated events ...\n"); callbacks.DynamicCodeGenerated = &DynamicCodeGenerated; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting DynamicCodeGenerated events done\n"); /* Exception events */ display(0, "#### JVMTIagent: setting Exception events ...\n"); callbacks.Exception = &Exception; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting Exception events done\n"); /* FieldAccess events */ display(0, "#### JVMTIagent: setting FieldAccess events ...\n"); callbacks.FieldAccess = &FieldAccess; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FieldAccess events done\n"); /* FieldModification events */ display(0, "#### JVMTIagent: setting FieldModification events ...\n"); callbacks.FieldModification = &FieldModification; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FieldModification events done\n"); /* FramePop events */ display(0, "#### JVMTIagent: setting FramePop events ...\n"); callbacks.FramePop = &FramePop; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FramePop events done\n"); /* GarbageCollectionFinish events */ display(0, "#### JVMTIagent: setting GarbageCollectionFinish events ...\n"); callbacks.GarbageCollectionFinish = &GarbageCollectionFinish; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting GarbageCollectionFinish events done\n"); /* GarbageCollectionStart events */ display(0, "#### JVMTIagent: setting GarbageCollectionStart events ...\n"); callbacks.GarbageCollectionStart = &GarbageCollectionStart; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting GarbageCollectionStart events done\n"); /* MonitorContendedEnter events */ display(0, "#### JVMTIagent: setting MonitorContendedEnter events ...\n"); callbacks.MonitorContendedEnter = &MonitorContendedEnter; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorContendedEnter events done\n"); /* MonitorContendedEntered events */ display(0, "#### JVMTIagent: setting MonitorContendedEntered events ...\n"); callbacks.MonitorContendedEntered = &MonitorContendedEntered; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorContendedEntered events done\n"); /* MonitorWait events */ display(0, "#### JVMTIagent: setting MonitorWait events ...\n"); callbacks.MonitorWait = &MonitorWait; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorWait events done\n"); /* MonitorWaited events */ display(0, "#### JVMTIagent: setting MonitorWaited events ...\n"); callbacks.MonitorWaited = &MonitorWaited; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorWaited events done\n"); /* NativeMethodBind events */ display(0, "#### JVMTIagent: setting NativeMethodBind events ...\n"); callbacks.NativeMethodBind = &NativeMethodBind; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting NativeMethodBind events done\n"); /* ObjectFree events */ display(0, "#### JVMTIagent: setting ObjectFree events ...\n"); callbacks.ObjectFree = &ObjectFree; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ObjectFree events done\n"); /* ThreadEnd events */ display(0, "#### JVMTIagent: setting ThreadEnd events ...\n"); callbacks.ThreadEnd = &ThreadEnd; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ThreadEnd events done\n"); /* ThreadStart events */ display(0, "#### JVMTIagent: setting ThreadStart events ...\n"); callbacks.ThreadStart = &ThreadStart; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ThreadStart events done\n"); /* VMDeath events */ display(0, "#### JVMTIagent: setting VMDeath events ...\n"); callbacks.VMDeath = &VMDeath; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMDeath events done\n"); /* VMInit events */ display(0, "#### JVMTIagent: setting VMInit events ...\n"); callbacks.VMInit = &VMInit; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMInit events done\n"); /* VMStart events */ display(0, "#### JVMTIagent: setting VMStart events ...\n"); callbacks.VMStart = &VMStart; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMStart events done\n"); /* VMObjectAlloc events */ display(0, "#### JVMTIagent: setting VMObjectAlloc events ...\n"); callbacks.VMObjectAlloc = &VMObjectAlloc; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMObjectAlloc events done\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, ! jvmti, &callbacks, sizeof(callbacks)))) return JNI_ERR; return 0; } static void clearJavaException(JNIEnv* jni_env) { ! if (NSK_CPP_STUB1(ExceptionOccurred, jni_env)) { ! NSK_CPP_STUB1(ExceptionDescribe, jni_env); ! NSK_CPP_STUB1(ExceptionClear, jni_env); ! NSK_CPP_STUB2(FatalError, jni_env, ! "JVMTIagent: exception occurred in java code, aborting\n"); } } static int get_tok(char **src, char *buf, int buflen, char sep) { int i; --- 805,1064 ---- caps.can_generate_garbage_collection_events = 1; caps.can_generate_monitor_events = 1; caps.can_generate_native_method_bind_events = 1; caps.can_generate_object_free_events = 1; caps.can_generate_vm_object_alloc_events = 1; ! if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; /* Breakpoint events */ display(0, "#### JVMTIagent: setting Breakpoint events ...\n"); callbacks.Breakpoint = &Breakpoint; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting Breakpoint events done\n"); /* ClassFileLoadHook events */ display(0, "#### JVMTIagent: setting ClassFileLoadHook events ...\n"); callbacks.ClassFileLoadHook = &ClassFileLoadHook; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassFileLoadHook events done\n"); /* ClassLoad events */ display(0, "#### JVMTIagent: setting ClassLoad events ...\n"); callbacks.ClassLoad = &ClassLoad; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassLoad events done\n"); /* ClassPrepare events */ display(0, "#### JVMTIagent: setting ClassPrepare events ...\n"); callbacks.ClassPrepare = &ClassPrepare; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassPrepare events done\n"); /* CompiledMethodLoad events */ display(0, "#### JVMTIagent: setting CompiledMethodLoad events ...\n"); callbacks.CompiledMethodLoad = &CompiledMethodLoad; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting CompiledMethodLoad events done\n"); /* CompiledMethodUnload events */ display(0, "#### JVMTIagent: setting CompiledMethodUnload events ...\n"); callbacks.CompiledMethodUnload = &CompiledMethodUnload; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting CompiledMethodUnload events done\n"); /* DataDumpRequest events */ display(0, "#### JVMTIagent: setting DataDumpRequest events ...\n"); callbacks.DataDumpRequest = &DataDumpRequest; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DATA_DUMP_REQUEST, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting DataDumpRequest events done\n"); /* DynamicCodeGenerated events */ display(0, "#### JVMTIagent: setting DynamicCodeGenerated events ...\n"); callbacks.DynamicCodeGenerated = &DynamicCodeGenerated; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting DynamicCodeGenerated events done\n"); /* Exception events */ display(0, "#### JVMTIagent: setting Exception events ...\n"); callbacks.Exception = &Exception; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting Exception events done\n"); /* FieldAccess events */ display(0, "#### JVMTIagent: setting FieldAccess events ...\n"); callbacks.FieldAccess = &FieldAccess; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FieldAccess events done\n"); /* FieldModification events */ display(0, "#### JVMTIagent: setting FieldModification events ...\n"); callbacks.FieldModification = &FieldModification; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FieldModification events done\n"); /* FramePop events */ display(0, "#### JVMTIagent: setting FramePop events ...\n"); callbacks.FramePop = &FramePop; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FramePop events done\n"); /* GarbageCollectionFinish events */ display(0, "#### JVMTIagent: setting GarbageCollectionFinish events ...\n"); callbacks.GarbageCollectionFinish = &GarbageCollectionFinish; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting GarbageCollectionFinish events done\n"); /* GarbageCollectionStart events */ display(0, "#### JVMTIagent: setting GarbageCollectionStart events ...\n"); callbacks.GarbageCollectionStart = &GarbageCollectionStart; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting GarbageCollectionStart events done\n"); /* MonitorContendedEnter events */ display(0, "#### JVMTIagent: setting MonitorContendedEnter events ...\n"); callbacks.MonitorContendedEnter = &MonitorContendedEnter; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorContendedEnter events done\n"); /* MonitorContendedEntered events */ display(0, "#### JVMTIagent: setting MonitorContendedEntered events ...\n"); callbacks.MonitorContendedEntered = &MonitorContendedEntered; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorContendedEntered events done\n"); /* MonitorWait events */ display(0, "#### JVMTIagent: setting MonitorWait events ...\n"); callbacks.MonitorWait = &MonitorWait; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorWait events done\n"); /* MonitorWaited events */ display(0, "#### JVMTIagent: setting MonitorWaited events ...\n"); callbacks.MonitorWaited = &MonitorWaited; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorWaited events done\n"); /* NativeMethodBind events */ display(0, "#### JVMTIagent: setting NativeMethodBind events ...\n"); callbacks.NativeMethodBind = &NativeMethodBind; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting NativeMethodBind events done\n"); /* ObjectFree events */ display(0, "#### JVMTIagent: setting ObjectFree events ...\n"); callbacks.ObjectFree = &ObjectFree; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ObjectFree events done\n"); /* ThreadEnd events */ display(0, "#### JVMTIagent: setting ThreadEnd events ...\n"); callbacks.ThreadEnd = &ThreadEnd; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ThreadEnd events done\n"); /* ThreadStart events */ display(0, "#### JVMTIagent: setting ThreadStart events ...\n"); callbacks.ThreadStart = &ThreadStart; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ThreadStart events done\n"); /* VMDeath events */ display(0, "#### JVMTIagent: setting VMDeath events ...\n"); callbacks.VMDeath = &VMDeath; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMDeath events done\n"); /* VMInit events */ display(0, "#### JVMTIagent: setting VMInit events ...\n"); callbacks.VMInit = &VMInit; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMInit events done\n"); /* VMStart events */ display(0, "#### JVMTIagent: setting VMStart events ...\n"); callbacks.VMStart = &VMStart; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMStart events done\n"); /* VMObjectAlloc events */ display(0, "#### JVMTIagent: setting VMObjectAlloc events ...\n"); callbacks.VMObjectAlloc = &VMObjectAlloc; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMObjectAlloc events done\n"); ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)))) return JNI_ERR; return 0; } static void clearJavaException(JNIEnv* jni_env) { ! if (jni_env->ExceptionOccurred()) { ! jni_env->ExceptionDescribe(); ! jni_env->ExceptionClear(); ! jni_env->FatalError("JVMTIagent: exception occurred in java code, aborting\n"); } } static int get_tok(char **src, char *buf, int buflen, char sep) { int i;
*** 1220,1230 **** if (jni_env==NULL) { /* some event callbacks have no pointer to jni */ printf("ERROR: %s\n", error_msg); exit(97); } else ! NSK_CPP_STUB2(FatalError, jni_env, error_msg); } } static void display(int level, const char format[], ...) { va_list ar; --- 1149,1159 ---- if (jni_env==NULL) { /* some event callbacks have no pointer to jni */ printf("ERROR: %s\n", error_msg); exit(97); } else ! jni_env->FatalError(error_msg); } } static void display(int level, const char format[], ...) { va_list ar;
*** 1248,1259 **** nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) return JNI_ERR; doSetup(options); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, ! jvmti, "_event_lock", &eventLock))) return JNI_ERR; if (enableEventsCaps() == 0 && addStressEvents() == 0) { display(0, "#### JVMTIagent: all events were successfully enabled and capabilities/events callbacks set ####\n\n"); } else { --- 1177,1187 ---- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) return JNI_ERR; doSetup(options); ! if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_event_lock", &eventLock))) return JNI_ERR; if (enableEventsCaps() == 0 && addStressEvents() == 0) { display(0, "#### JVMTIagent: all events were successfully enabled and capabilities/events callbacks set ####\n\n"); } else {
< prev index next >