< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/Breakpoint/breakpoint001/breakpoint001.cpp

Print this page
rev 51942 : [mq]: refactor

*** 65,83 **** static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) { jmethodID mid; int i; for (i=0; i<METH_NUM; i++) { ! if (!NSK_JNI_VERIFY(env, (mid = NSK_CPP_STUB4(GetMethodID, ! env, klass, METHODS[i][0], METHODS[i][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 --- 65,79 ---- static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) { jmethodID mid; int i; for (i=0; i<METH_NUM; i++) { ! if (!NSK_JNI_VERIFY(env, (mid = env->GetMethodID(klass, METHODS[i][0], METHODS[i][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
*** 86,99 **** jvmti->RawMonitorEnter(agent_lock); if (vm_started) { // GetClassSignature may be called only during the start or the live phase ! 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 breakpoints ...\n", --- 82,93 ---- jvmti->RawMonitorEnter(agent_lock); if (vm_started) { // GetClassSignature may be called only during the start or the live phase ! 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 breakpoints ...\n",
*** 115,126 **** int i; NSK_DISPLAY0(">>>> Breakpoint event received\n"); /* checking thread info */ ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, ! jvmti_env, thread, &thr_info))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get thread info during Breakpoint callback\n\n"); return; } if (thr_info.name == NULL || --- 109,119 ---- int i; NSK_DISPLAY0(">>>> Breakpoint event received\n"); /* checking thread info */ ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &thr_info))) { result = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get thread info during Breakpoint callback\n\n"); return; } if (thr_info.name == NULL ||
*** 146,163 **** else NSK_DISPLAY1("CHECK PASSED: location: %ld as expected\n", (long) location); /* checking method info */ ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, ! jvmti_env, method, &klass))) { result = checkStatus = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during Breakpoint callback\n\n"); return; } ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, ! jvmti_env, klass, &clsSig, &generic))) { result = checkStatus = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during Breakpoint callback\n\n"); return; } if (clsSig == NULL || --- 139,154 ---- else NSK_DISPLAY1("CHECK PASSED: location: %ld as expected\n", (long) location); /* checking method info */ ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) { result = checkStatus = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during Breakpoint callback\n\n"); return; } ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &clsSig, &generic))) { result = checkStatus = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during Breakpoint callback\n\n"); return; } if (clsSig == NULL ||
*** 170,181 **** } else NSK_DISPLAY1("CHECK PASSED: class signature: \"%s\"\n", clsSig); ! if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, ! jvmti_env, method, &methNam, &methSig, NULL))) { result = checkStatus = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); return; } --- 161,171 ---- } else NSK_DISPLAY1("CHECK PASSED: class signature: \"%s\"\n", clsSig); ! if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) { result = checkStatus = STATUS_FAILED; NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); return; }
*** 187,203 **** if (checkStatus == PASSED) bpEvents[i]++; break; } ! 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"); --- 177,191 ---- if (checkStatus == PASSED) bpEvents[i]++; break; } ! 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");
*** 263,278 **** initCounters(); /* add capability to generate compiled method events */ memset(&caps, 0, sizeof(jvmtiCapabilities)); caps.can_generate_breakpoint_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"); --- 251,264 ---- initCounters(); /* add capability to generate compiled method events */ memset(&caps, 0, sizeof(jvmtiCapabilities)); caps.can_generate_breakpoint_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");
*** 280,303 **** NSK_DISPLAY0("setting event callbacks ...\n"); (void) memset(&callbacks, 0, sizeof(callbacks)); callbacks.ClassLoad = &ClassLoad; callbacks.Breakpoint = &Breakpoint; callbacks.VMStart = &VMStart; ! 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_VM_START, NULL))) return JNI_ERR; ! 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"); if (jvmti->CreateRawMonitor("agent_lock", &agent_lock) != JVMTI_ERROR_NONE) { return JNI_ERR; --- 266,285 ---- NSK_DISPLAY0("setting event callbacks ...\n"); (void) memset(&callbacks, 0, sizeof(callbacks)); callbacks.ClassLoad = &ClassLoad; callbacks.Breakpoint = &Breakpoint; callbacks.VMStart = &VMStart; ! 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_VM_START, NULL))) return JNI_ERR; ! 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"); if (jvmti->CreateRawMonitor("agent_lock", &agent_lock) != JVMTI_ERROR_NONE) { return JNI_ERR;
< prev index next >