< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/singlestep003.cpp

Print this page
rev 52185 : [mq]: refactor

*** 62,91 **** static jvmtiEventCallbacks callbacks; static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) { jmethodID mid; ! if (!NSK_JNI_VERIFY(env, (mid = NSK_CPP_STUB4(GetMethodID, ! env, klass, METHODS[0][0], METHODS[0][1])) != NULL)) ! NSK_CPP_STUB2(FatalError, env, ! "failed to get ID for the java method\n"); ! ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetBreakpoint, ! jvmti_env, mid, 0))) ! NSK_CPP_STUB2(FatalError, env, ! "failed to set breakpoint\n"); } /** callback functions **/ void JNICALL ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) { char *sig, *generic; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, ! jvmti_env, klass, &sig, &generic))) ! NSK_CPP_STUB2(FatalError, env, ! "failed to obtain a class signature\n"); if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { NSK_DISPLAY1( "ClassLoad event received for the class \"%s\"\n" "\tsetting breakpoint ...\n", --- 62,85 ---- static jvmtiEventCallbacks callbacks; static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) { jmethodID mid; ! if (!NSK_JNI_VERIFY(env, (mid = env->GetMethodID(klass, METHODS[0][0], METHODS[0][1])) != NULL)) ! env->FatalError("failed to get ID for the java method\n"); ! ! if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 0))) ! env->FatalError("failed to set breakpoint\n"); } /** callback functions **/ void JNICALL ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) { char *sig, *generic; ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) ! env->FatalError("failed to obtain a class signature\n"); if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { NSK_DISPLAY1( "ClassLoad event received for the class \"%s\"\n" "\tsetting breakpoint ...\n",
*** 99,122 **** jlocation loc) { jclass klass; char *sig, *generic; NSK_DISPLAY0("Breakpoint event received\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &klass))) NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, ! jvmti_env, klass, &sig, &generic))) ! NSK_CPP_STUB2(FatalError, env, ! "Breakpoint: failed to obtain a class signature\n"); if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n", sig); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n"); } } else { result = STATUS_FAILED; --- 93,112 ---- jlocation loc) { jclass klass; char *sig, *generic; NSK_DISPLAY0("Breakpoint event received\n"); ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n"); ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) ! env->FatalError("Breakpoint: failed to obtain a class signature\n"); if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n", sig); ! if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n"); } } else { result = STATUS_FAILED;
*** 136,159 **** return; } NSK_DISPLAY0(">>>> SingleStep event received\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, ! jvmti_env, method, &methNam, &methSig, NULL))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n"); return; } ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &klass))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n"); return; } ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, ! jvmti_env, klass, &sig, &generic))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n"); return; } --- 126,146 ---- return; } NSK_DISPLAY0(">>>> SingleStep event received\n"); ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n"); return; } ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n"); return; } ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n"); return; }
*** 184,210 **** methNam, methSig, sig); } if (i == (METH_NUM-1)) { NSK_DISPLAY0("Disabling the single step event generation\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n"); } } } } } ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, ! jvmti_env, (unsigned char*) methNam))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n"); } ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, ! jvmti_env, (unsigned char*) methSig))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n"); } NSK_DISPLAY0("<<<<\n\n"); --- 171,194 ---- methNam, methSig, sig); } if (i == (METH_NUM-1)) { NSK_DISPLAY0("Disabling the single step event generation\n"); ! if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n"); } } } } } ! if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n"); } ! if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n"); } NSK_DISPLAY0("<<<<\n\n");
*** 276,311 **** /* add capability to generate compiled method events */ memset(&caps, 0, sizeof(jvmtiCapabilities)); caps.can_generate_breakpoint_events = 1; caps.can_generate_single_step_events = 1; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, ! jvmti, &caps))) return JNI_ERR; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, ! jvmti, &caps))) return JNI_ERR; if (!caps.can_generate_single_step_events) NSK_DISPLAY0("Warning: generation of single step events is not implemented\n"); /* set event callback */ NSK_DISPLAY0("setting event callbacks ...\n"); (void) memset(&callbacks, 0, sizeof(callbacks)); callbacks.ClassLoad = &ClassLoad; callbacks.Breakpoint = &Breakpoint; callbacks.SingleStep = &SingleStep; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, ! jvmti, &callbacks, sizeof(callbacks)))) return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) return JNI_ERR; ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, ! jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); return JNI_OK; } --- 260,290 ---- /* add capability to generate compiled method events */ memset(&caps, 0, sizeof(jvmtiCapabilities)); caps.can_generate_breakpoint_events = 1; caps.can_generate_single_step_events = 1; ! if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; ! if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps))) return JNI_ERR; if (!caps.can_generate_single_step_events) NSK_DISPLAY0("Warning: generation of single step events is not implemented\n"); /* set event callback */ NSK_DISPLAY0("setting event callbacks ...\n"); (void) memset(&callbacks, 0, sizeof(callbacks)); callbacks.ClassLoad = &ClassLoad; callbacks.Breakpoint = &Breakpoint; callbacks.SingleStep = &SingleStep; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)))) return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) return JNI_ERR; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); return JNI_OK; }
< prev index next >