8212148: Remove remaining NSK_CPP_STUBs

Remove remaining macros

Reviewed-by: amenkov, phh, iignatyev
This commit is contained in:
Jean Christophe Beyler 2018-10-22 12:43:15 -07:00
parent dafc483475
commit a623db2148
36 changed files with 472 additions and 785 deletions

View File

@ -43,36 +43,28 @@ static jvmtiPhase phase;
/* Check SetVerboseFlag function /* Check SetVerboseFlag function
*/ */
static int checkSetVerboseFlag(jvmtiEnv *jvmti) { static int checkSetVerboseFlag(jvmtiEnv *jvmti) {
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_OTHER, JNI_TRUE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_OTHER, JNI_TRUE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_OTHER, JNI_FALSE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_OTHER, JNI_FALSE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_GC, JNI_TRUE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_GC, JNI_TRUE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_GC, JNI_FALSE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_GC, JNI_FALSE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_CLASS, JNI_TRUE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_CLASS, JNI_TRUE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_CLASS, JNI_FALSE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_CLASS, JNI_FALSE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_JNI, JNI_TRUE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_JNI, JNI_TRUE)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_JNI, JNI_FALSE)))
NSK_CPP_STUB3(SetVerboseFlag, jvmti, JVMTI_VERBOSE_JNI, JNI_FALSE)))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -83,7 +75,7 @@ static int checkSetVerboseFlag(jvmtiEnv *jvmti) {
void JNICALL void JNICALL
VMInit(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) { VMInit(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti, &phase))) if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
NSK_DISPLAY1("Phase: %s\n", TranslatePhase(phase)); NSK_DISPLAY1("Phase: %s\n", TranslatePhase(phase));
@ -105,10 +97,10 @@ ClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni,
unsigned char** new_class_data) { unsigned char** new_class_data) {
jvmtiPhase curr_phase; jvmtiPhase curr_phase;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, access_lock))) if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(access_lock)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti, &curr_phase))) if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&curr_phase)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
if (phase != curr_phase) { if (phase != curr_phase) {
@ -121,7 +113,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni,
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, access_lock))) if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(access_lock)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -135,7 +127,7 @@ agentProc(jvmtiEnv *jvmti, JNIEnv* jni, void* arg) {
if (!nsk_jvmti_waitForSync(timeout)) if (!nsk_jvmti_waitForSync(timeout))
return; return;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti, &phase))) if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
NSK_DISPLAY1("Phase: %s\n", TranslatePhase(phase)); NSK_DISPLAY1("Phase: %s\n", TranslatePhase(phase));
@ -181,12 +173,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR; return JNI_ERR;
/* Create data access lock */ /* Create data access lock */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_access_lock", &access_lock)))
NSK_CPP_STUB3(CreateRawMonitor, jvmti,
"_access_lock", &access_lock)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti, &phase))) if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase)))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY1("Phase: %s\n", TranslatePhase(phase)); NSK_DISPLAY1("Phase: %s\n", TranslatePhase(phase));
@ -199,21 +189,17 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
callbacks.VMInit = &VMInit; callbacks.VMInit = &VMInit;
callbacks.ClassFileLoadHook = &ClassFileLoadHook; callbacks.ClassFileLoadHook = &ClassFileLoadHook;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
NSK_CPP_STUB3(SetEventCallbacks, jvmti,
&callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
/* enable VMInit event */ /* enable VMInit event */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_ENABLE, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL)))
JVMTI_EVENT_VM_INIT, NULL)))
return JNI_ERR; return JNI_ERR;
/* enable ClassFileLoadHook event */ /* enable ClassFileLoadHook event */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_ENABLE, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)))
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)))
return JNI_ERR; return JNI_ERR;
/* register agent proc and arg */ /* register agent proc and arg */

View File

@ -47,8 +47,7 @@ agentProc(jvmtiEnv *jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY0("Check on JVMTI_ERROR_ILLEGAL_ARGUMENT\n"); NSK_DISPLAY0("Check on JVMTI_ERROR_ILLEGAL_ARGUMENT\n");
if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_ILLEGAL_ARGUMENT, if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_ILLEGAL_ARGUMENT,
NSK_CPP_STUB3(SetVerboseFlag, jvmti, jvmti->SetVerboseFlag((jvmtiVerboseFlag)(-1), JNI_TRUE)))
(jvmtiVerboseFlag)(-1), JNI_TRUE)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
/* resume debugee after last sync */ /* resume debugee after last sync */

View File

@ -63,15 +63,11 @@ static jrawMonitorID agent_lock;
static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) { static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) {
jmethodID mid; jmethodID mid;
if (!NSK_JNI_VERIFY(env, (mid = NSK_CPP_STUB4(GetMethodID, if (!NSK_JNI_VERIFY(env, (mid = env->GetMethodID(klass, METHODS[0], METHOD_SIGS[0])) != NULL))
env, klass, METHODS[0], METHOD_SIGS[0])) != NULL)) env->FatalError("failed to get ID for the java method\n");
NSK_CPP_STUB2(FatalError, env,
"failed to get ID for the java method\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetBreakpoint, if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 0)))
jvmti_env, mid, 0))) env->FatalError("failed to set breakpoint\n");
NSK_CPP_STUB2(FatalError, env,
"failed to set breakpoint\n");
} }
/** callback functions **/ /** callback functions **/
@ -82,10 +78,8 @@ ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
jvmti->RawMonitorEnter(agent_lock); jvmti->RawMonitorEnter(agent_lock);
if (vm_started) { if (vm_started) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
jvmti_env, klass, &sig, &generic))) env->FatalError("failed to obtain a class signature\n");
NSK_CPP_STUB2(FatalError, env,
"failed to obtain a class signature\n");
if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
NSK_DISPLAY1( NSK_DISPLAY1(
@ -106,20 +100,16 @@ Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method,
char *sig, *generic; char *sig, *generic;
NSK_DISPLAY0("Breakpoint event received\n"); NSK_DISPLAY0("Breakpoint event received\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass)))
jvmti_env, method, &klass)))
NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n"); NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
jvmti_env, klass, &sig, &generic))) env->FatalError("Breakpoint: failed to obtain a class signature\n");
NSK_CPP_STUB2(FatalError, env,
"Breakpoint: failed to obtain a class signature\n");
if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n", NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n",
sig); sig);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) {
jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n"); NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n");
} }
@ -142,20 +132,17 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
NSK_DISPLAY0(">>>> SingleStep event received\n"); NSK_DISPLAY0(">>>> SingleStep event received\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
jvmti_env, method, &methNam, &methSig, NULL))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n");
return; return;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) {
jvmti_env, method, &klass))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n");
return; return;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) {
jvmti_env, klass, &sig, &generic))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n");
return; return;
@ -187,21 +174,18 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
"CHECK PASSED: SingleStep event received for the method \"%s\" as expected\n" "CHECK PASSED: SingleStep event received for the method \"%s\" as expected\n"
"\tdisabling the event generation\n", "\tdisabling the event generation\n",
methNam); methNam);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) {
jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n"); NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n");
} }
} }
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) {
jvmti_env, (unsigned char*) methNam))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
jvmti_env, (unsigned char*) methSig))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n");
} }
@ -261,12 +245,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(jvmtiCapabilities)); memset(&caps, 0, sizeof(jvmtiCapabilities));
caps.can_generate_breakpoint_events = 1; caps.can_generate_breakpoint_events = 1;
caps.can_generate_single_step_events = 1; caps.can_generate_single_step_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
jvmti, &caps)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
jvmti, &caps)))
return JNI_ERR; return JNI_ERR;
if (!caps.can_generate_single_step_events) if (!caps.can_generate_single_step_events)
@ -279,24 +261,19 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
callbacks.Breakpoint = &Breakpoint; callbacks.Breakpoint = &Breakpoint;
callbacks.SingleStep = &SingleStep; callbacks.SingleStep = &SingleStep;
callbacks.VMStart = &VMStart; callbacks.VMStart = &VMStart;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("enabling the events done\n\n"); NSK_DISPLAY0("enabling the events done\n\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("agent lock", &agent_lock)))
jvmti, "agent lock", &agent_lock)))
return JNI_ERR; return JNI_ERR;
return JNI_OK; return JNI_OK;

View File

@ -50,8 +50,7 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
jmethodID method, jlocation location) { jmethodID method, jlocation location) {
jvmtiPhase phase; jvmtiPhase phase;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
jvmti_env, &phase))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to obtain phase of the VM execution during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to obtain phase of the VM execution during SingleStep callback\n\n");
} }
@ -105,12 +104,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
/* add capability to generate compiled method events */ /* add capability to generate compiled method events */
memset(&caps, 0, sizeof(jvmtiCapabilities)); memset(&caps, 0, sizeof(jvmtiCapabilities));
caps.can_generate_single_step_events = 1; caps.can_generate_single_step_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
jvmti, &caps)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
jvmti, &caps)))
return JNI_ERR; return JNI_ERR;
if (!caps.can_generate_single_step_events) if (!caps.can_generate_single_step_events)
@ -121,16 +118,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
(void) memset(&callbacks, 0, sizeof(callbacks)); (void) memset(&callbacks, 0, sizeof(callbacks));
callbacks.SingleStep = &SingleStep; callbacks.SingleStep = &SingleStep;
callbacks.VMDeath = &VMDeath; callbacks.VMDeath = &VMDeath;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("enabling the events done\n\n"); NSK_DISPLAY0("enabling the events done\n\n");

View File

@ -64,15 +64,11 @@ static jvmtiEventCallbacks callbacks;
static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) { static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) {
jmethodID mid; jmethodID mid;
if (!NSK_JNI_VERIFY(env, (mid = NSK_CPP_STUB4(GetMethodID, if (!NSK_JNI_VERIFY(env, (mid = env->GetMethodID(klass, METHODS[0][0], METHODS[0][1])) != NULL))
env, klass, METHODS[0][0], METHODS[0][1])) != NULL)) env->FatalError("failed to get ID for the java method\n");
NSK_CPP_STUB2(FatalError, env,
"failed to get ID for the java method\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetBreakpoint, if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 0)))
jvmti_env, mid, 0))) env->FatalError("failed to set breakpoint\n");
NSK_CPP_STUB2(FatalError, env,
"failed to set breakpoint\n");
} }
/** callback functions **/ /** callback functions **/
@ -80,10 +76,8 @@ void JNICALL
ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) { ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
char *sig, *generic; char *sig, *generic;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
jvmti_env, klass, &sig, &generic))) env->FatalError("failed to obtain a class signature\n");
NSK_CPP_STUB2(FatalError, env,
"failed to obtain a class signature\n");
if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
NSK_DISPLAY1( NSK_DISPLAY1(
@ -101,20 +95,16 @@ Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method,
char *sig, *generic; char *sig, *generic;
NSK_DISPLAY0("Breakpoint event received\n"); NSK_DISPLAY0("Breakpoint event received\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass)))
jvmti_env, method, &klass)))
NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n"); NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
jvmti_env, klass, &sig, &generic))) env->FatalError("Breakpoint: failed to obtain a class signature\n");
NSK_CPP_STUB2(FatalError, env,
"Breakpoint: failed to obtain a class signature\n");
if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n", NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n",
sig); sig);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) {
jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n"); NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n");
} }
@ -138,20 +128,17 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
NSK_DISPLAY0(">>>> SingleStep event received\n"); NSK_DISPLAY0(">>>> SingleStep event received\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
jvmti_env, method, &methNam, &methSig, NULL))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n");
return; return;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) {
jvmti_env, method, &klass))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n");
return; return;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) {
jvmti_env, klass, &sig, &generic))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n");
return; return;
@ -186,8 +173,7 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
if (i == (METH_NUM-1)) { if (i == (METH_NUM-1)) {
NSK_DISPLAY0("Disabling the single step event generation\n"); NSK_DISPLAY0("Disabling the single step event generation\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) {
jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n"); NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n");
} }
@ -196,13 +182,11 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
} }
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) {
jvmti_env, (unsigned char*) methNam))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
jvmti_env, (unsigned char*) methSig))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n"); NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n");
} }
@ -278,12 +262,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(jvmtiCapabilities)); memset(&caps, 0, sizeof(jvmtiCapabilities));
caps.can_generate_breakpoint_events = 1; caps.can_generate_breakpoint_events = 1;
caps.can_generate_single_step_events = 1; caps.can_generate_single_step_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
jvmti, &caps)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
jvmti, &caps)))
return JNI_ERR; return JNI_ERR;
if (!caps.can_generate_single_step_events) if (!caps.can_generate_single_step_events)
NSK_DISPLAY0("Warning: generation of single step events is not implemented\n"); NSK_DISPLAY0("Warning: generation of single step events is not implemented\n");
@ -294,16 +276,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
callbacks.ClassLoad = &ClassLoad; callbacks.ClassLoad = &ClassLoad;
callbacks.Breakpoint = &Breakpoint; callbacks.Breakpoint = &Breakpoint;
callbacks.SingleStep = &SingleStep; callbacks.SingleStep = &SingleStep;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("enabling the events done\n\n"); NSK_DISPLAY0("enabling the events done\n\n");

View File

@ -62,8 +62,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
NSK_DISPLAY0("Prepare: find tested threads\n"); NSK_DISPLAY0("Prepare: find tested threads\n");
/* get all live threads */ /* get all live threads */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@ -75,8 +74,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
return NSK_FALSE; return NSK_FALSE;
/* get thread information */ /* get thread information */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
return NSK_FALSE; return NSK_FALSE;
NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]);
@ -93,23 +91,19 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
} }
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
return NSK_FALSE; return NSK_FALSE;
NSK_DISPLAY0("Prepare: create new instance of ThreadDeath exception\n"); NSK_DISPLAY0("Prepare: create new instance of ThreadDeath exception\n");
if (!NSK_JNI_VERIFY(jni, (cls = if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL))
NSK_CPP_STUB2(FindClass, jni, THREAD_DEATH_CLASS_NAME)) != NULL))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JNI_VERIFY(jni, (ctor = if (!NSK_JNI_VERIFY(jni, (ctor =
NSK_CPP_STUB4(GetMethodID, jni, cls, jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JNI_VERIFY(jni, (threadDeath = if (!NSK_JNI_VERIFY(jni, (threadDeath = jni->NewObject(cls, ctor)) != NULL))
NSK_CPP_STUB3(NewObject, jni, cls, ctor)) != NULL))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -133,8 +127,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
if (!NSK_VERIFY(runningThread != NULL)) { if (!NSK_VERIFY(runningThread != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} else { } else {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(StopThread, if (!NSK_JVMTI_VERIFY(jvmti->StopThread(runningThread, threadDeath)))
jvmti, runningThread, threadDeath)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -142,8 +135,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
if (!NSK_VERIFY(waitingThread != NULL)) { if (!NSK_VERIFY(waitingThread != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} else { } else {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(StopThread, if (!NSK_JVMTI_VERIFY(jvmti->StopThread(waitingThread, threadDeath)))
jvmti, waitingThread, threadDeath)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -151,8 +143,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
if (!NSK_VERIFY(sleepingThread != NULL)) { if (!NSK_VERIFY(sleepingThread != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} else { } else {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(StopThread, if (!NSK_JVMTI_VERIFY(jvmti->StopThread(sleepingThread, threadDeath)))
jvmti, sleepingThread, threadDeath)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -194,7 +185,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_signal_thread = 1; caps.can_signal_thread = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }

View File

@ -58,8 +58,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread);
NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(testedThread))) {
NSK_CPP_STUB2(SuspendThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -72,8 +71,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
{ {
jint state = 0; jint state = 0;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(testedThread, &state))) {
NSK_CPP_STUB3(GetThreadState, jvmti, testedThread, &state))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
NSK_DISPLAY2(" ... got state vector: %s (%d)\n", NSK_DISPLAY2(" ... got state vector: %s (%d)\n",
@ -88,8 +86,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
} }
NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread); NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(testedThread))) {
NSK_CPP_STUB2(ResumeThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -98,7 +95,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY0("Delete thread reference\n"); NSK_DISPLAY0("Delete thread reference\n");
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedThread)); NSK_TRACE(jni->DeleteGlobalRef(testedThread));
} }
NSK_DISPLAY0("Let debugee to finish\n"); NSK_DISPLAY0("Let debugee to finish\n");
@ -139,8 +136,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiCapabilities suspendCaps; jvmtiCapabilities suspendCaps;
memset(&suspendCaps, 0, sizeof(suspendCaps)); memset(&suspendCaps, 0, sizeof(suspendCaps));
suspendCaps.can_suspend = 1; suspendCaps.can_suspend = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
return JNI_ERR; return JNI_ERR;
} }

View File

@ -75,8 +75,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(testedThread))) {
NSK_CPP_STUB2(SuspendThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -104,8 +103,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread); NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(testedThread))) {
NSK_CPP_STUB2(ResumeThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -114,7 +112,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY0("Delete thread reference\n"); NSK_DISPLAY0("Delete thread reference\n");
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedThread)); NSK_TRACE(jni->DeleteGlobalRef(testedThread));
} }
NSK_DISPLAY0("Let debugee to finish\n"); NSK_DISPLAY0("Let debugee to finish\n");
@ -129,7 +127,7 @@ JNIEXPORT void JNICALL
callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
/* check if event is for tested thread */ /* check if event is for tested thread */
if (thread != NULL && if (thread != NULL &&
NSK_CPP_STUB3(IsSameObject, jni, testedThread, thread)) { jni->IsSameObject(testedThread, thread)) {
NSK_DISPLAY1(" ... received THREAD_END event for tested thread: %p\n", (void*)thread); NSK_DISPLAY1(" ... received THREAD_END event for tested thread: %p\n", (void*)thread);
eventsReceived++; eventsReceived++;
} else { } else {
@ -170,8 +168,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiCapabilities suspendCaps; jvmtiCapabilities suspendCaps;
memset(&suspendCaps, 0, sizeof(suspendCaps)); memset(&suspendCaps, 0, sizeof(suspendCaps));
suspendCaps.can_suspend = 1; suspendCaps.can_suspend = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
return JNI_ERR; return JNI_ERR;
} }
@ -180,8 +177,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiEventCallbacks callbacks; jvmtiEventCallbacks callbacks;
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
callbacks.ThreadEnd = callbackThreadEnd; callbacks.ThreadEnd = callbackThreadEnd;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
} }

View File

@ -63,8 +63,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread);
NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(testedThread))) {
NSK_CPP_STUB2(SuspendThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -78,8 +77,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
{ {
jint state = 0; jint state = 0;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(testedThread, &state))) {
NSK_CPP_STUB3(GetThreadState, jvmti, testedThread, &state))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
NSK_DISPLAY2(" ... got state vector: %s (%d)\n", NSK_DISPLAY2(" ... got state vector: %s (%d)\n",
@ -94,8 +92,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
} }
NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread); NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(testedThread))) {
NSK_CPP_STUB2(ResumeThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
/* Original agentProc test block ends here. */ /* Original agentProc test block ends here. */
@ -107,7 +104,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
for (late_count = 0; late_count < N_LATE_CALLS; late_count++) { for (late_count = 0; late_count < N_LATE_CALLS; late_count++) {
jvmtiError l_err; jvmtiError l_err;
printf("INFO: Late suspend thread: %p\n", (void*)testedThread); printf("INFO: Late suspend thread: %p\n", (void*)testedThread);
l_err = NSK_CPP_STUB2(SuspendThread, jvmti, testedThread); l_err = jvmti->SuspendThread(testedThread);
if (l_err != JVMTI_ERROR_NONE) { if (l_err != JVMTI_ERROR_NONE) {
printf("INFO: Late suspend thread err: %d\n", l_err); printf("INFO: Late suspend thread err: %d\n", l_err);
// testedThread has exited so we're done with late calls // testedThread has exited so we're done with late calls
@ -117,8 +114,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
// Only resume a thread if suspend worked. Using NSK_DISPLAY1() // Only resume a thread if suspend worked. Using NSK_DISPLAY1()
// here because we want ResumeThread() to be faster. // here because we want ResumeThread() to be faster.
NSK_DISPLAY1("INFO: Late resume thread: %p\n", (void*)testedThread); NSK_DISPLAY1("INFO: Late resume thread: %p\n", (void*)testedThread);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(testedThread))) {
NSK_CPP_STUB2(ResumeThread, jvmti, testedThread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
} }
@ -137,7 +133,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY0("Delete thread reference\n"); NSK_DISPLAY0("Delete thread reference\n");
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedThread)); NSK_TRACE(jni->DeleteGlobalRef(testedThread));
} }
NSK_DISPLAY0("Let debugee to finish\n"); NSK_DISPLAY0("Let debugee to finish\n");
@ -180,8 +176,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiCapabilities suspendCaps; jvmtiCapabilities suspendCaps;
memset(&suspendCaps, 0, sizeof(suspendCaps)); memset(&suspendCaps, 0, sizeof(suspendCaps));
suspendCaps.can_suspend = 1; suspendCaps.can_suspend = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
return JNI_ERR; return JNI_ERR;
} }

View File

@ -62,18 +62,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
int i; int i;
NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount); NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((threadsCount * sizeof(jthread)),
NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jthread)), (unsigned char**)&threads))) {
(unsigned char**)&threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
NSK_DISPLAY1(" ... allocated array: %p\n", (void*)threads); NSK_DISPLAY1(" ... allocated array: %p\n", (void*)threads);
NSK_DISPLAY1("Allocate results array: %d threads\n", threadsCount); NSK_DISPLAY1("Allocate results array: %d threads\n", threadsCount);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((threadsCount * sizeof(jvmtiError)),
NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jvmtiError)), (unsigned char**)&results))) {
(unsigned char**)&results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -84,8 +82,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY0("Suspend threads list\n"); NSK_DISPLAY0("Suspend threads list\n");
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(threadsCount, threads, results))) {
NSK_CPP_STUB4(SuspendThreadList, jvmti, threadsCount, threads, results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -107,8 +104,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
jint state = 0; jint state = 0;
NSK_DISPLAY2(" thread #%d (%p):\n", i, (void*)threads[i]); NSK_DISPLAY2(" thread #%d (%p):\n", i, (void*)threads[i]);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threads[i], &state))) {
NSK_CPP_STUB3(GetThreadState, jvmti, threads[i], &state))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
NSK_DISPLAY2(" ... got state vector: %s (%d)\n", NSK_DISPLAY2(" ... got state vector: %s (%d)\n",
@ -123,8 +119,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
} }
NSK_DISPLAY0("Resume threads list\n"); NSK_DISPLAY0("Resume threads list\n");
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(threadsCount, threads, results))) {
NSK_CPP_STUB4(ResumeThreadList, jvmti, threadsCount, threads, results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -136,18 +131,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY0("Delete threads references\n"); NSK_DISPLAY0("Delete threads references\n");
for (i = 0; i < threadsCount; i++) { for (i = 0; i < threadsCount; i++) {
if (threads[i] != NULL) if (threads[i] != NULL)
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threads[i])); NSK_TRACE(jni->DeleteGlobalRef(threads[i]));
} }
NSK_DISPLAY1("Deallocate threads array: %p\n", (void*)threads); NSK_DISPLAY1("Deallocate threads array: %p\n", (void*)threads);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
NSK_DISPLAY1("Deallocate results array: %p\n", (void*)results); NSK_DISPLAY1("Deallocate results array: %p\n", (void*)results);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)results))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
} }
@ -173,8 +166,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
foundThreads[i] = NULL; foundThreads[i] = NULL;
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&count, &threads))) {
NSK_CPP_STUB3(GetAllThreads, jvmti, &count, &threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -183,8 +175,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
jvmtiThreadInfo info; jvmtiThreadInfo info;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info))) {
NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
break; break;
} }
@ -199,8 +190,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -218,7 +208,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount); NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount);
for (i = 0; i < foundCount; i++) { for (i = 0; i < foundCount; i++) {
if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread) if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread)
NSK_CPP_STUB2(NewGlobalRef, jni, foundThreads[i])) != NULL)) { jni->NewGlobalRef(foundThreads[i])) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -266,8 +256,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiCapabilities suspendCaps; jvmtiCapabilities suspendCaps;
memset(&suspendCaps, 0, sizeof(suspendCaps)); memset(&suspendCaps, 0, sizeof(suspendCaps));
suspendCaps.can_suspend = 1; suspendCaps.can_suspend = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
return JNI_ERR; return JNI_ERR;
} }

View File

@ -73,18 +73,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
int i; int i;
NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount); NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((threadsCount * sizeof(jthread)),
NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jthread)), (unsigned char**)&threads))) {
(unsigned char**)&threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
NSK_DISPLAY1(" ... allocated array: %p\n", (void*)threads); NSK_DISPLAY1(" ... allocated array: %p\n", (void*)threads);
NSK_DISPLAY1("Allocate results array: %d threads\n", threadsCount); NSK_DISPLAY1("Allocate results array: %d threads\n", threadsCount);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((threadsCount * sizeof(jvmtiError)),
NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jvmtiError)), (unsigned char**)&results))) {
(unsigned char**)&results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -95,8 +93,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY0("Suspend threads list\n"); NSK_DISPLAY0("Suspend threads list\n");
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(threadsCount, threads, results))) {
NSK_CPP_STUB4(SuspendThreadList, jvmti, threadsCount, threads, results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -138,8 +135,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
NSK_DISPLAY0("Resume threads list\n"); NSK_DISPLAY0("Resume threads list\n");
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(threadsCount, threads, results))) {
NSK_CPP_STUB4(ResumeThreadList, jvmti, threadsCount, threads, results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -151,18 +147,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY0("Delete threads references\n"); NSK_DISPLAY0("Delete threads references\n");
for (i = 0; i < threadsCount; i++) { for (i = 0; i < threadsCount; i++) {
if (threads[i] != NULL) if (threads[i] != NULL)
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threads[i])); NSK_TRACE(jni->DeleteGlobalRef(threads[i]));
} }
NSK_DISPLAY1("Deallocate threads array: %p\n", (void*)threads); NSK_DISPLAY1("Deallocate threads array: %p\n", (void*)threads);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
NSK_DISPLAY1("Deallocate results array: %p\n", (void*)results); NSK_DISPLAY1("Deallocate results array: %p\n", (void*)results);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)results))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)results))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
} }
@ -188,8 +182,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
foundThreads[i] = NULL; foundThreads[i] = NULL;
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&count, &threads))) {
NSK_CPP_STUB3(GetAllThreads, jvmti, &count, &threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -198,8 +191,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
jvmtiThreadInfo info; jvmtiThreadInfo info;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info))) {
NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
break; break;
} }
@ -214,8 +206,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -233,7 +224,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni,
NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount); NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount);
for (i = 0; i < foundCount; i++) { for (i = 0; i < foundCount; i++) {
if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread) if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread)
NSK_CPP_STUB2(NewGlobalRef, jni, foundThreads[i])) != NULL)) { jni->NewGlobalRef(foundThreads[i])) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -253,7 +244,7 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
/* check if event is for tested thread */ /* check if event is for tested thread */
for (i = 0; i < threadsCount; i++) { for (i = 0; i < threadsCount; i++) {
if (thread != NULL && if (thread != NULL &&
NSK_CPP_STUB3(IsSameObject, jni, threads[i], thread)) { jni->IsSameObject(threads[i], thread)) {
NSK_DISPLAY2(" ... received THREAD_END event for thread #%d: %p\n", NSK_DISPLAY2(" ... received THREAD_END event for thread #%d: %p\n",
i, (void*)thread); i, (void*)thread);
eventsReceived++; eventsReceived++;
@ -301,8 +292,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiCapabilities suspendCaps; jvmtiCapabilities suspendCaps;
memset(&suspendCaps, 0, sizeof(suspendCaps)); memset(&suspendCaps, 0, sizeof(suspendCaps));
suspendCaps.can_suspend = 1; suspendCaps.can_suspend = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
return JNI_ERR; return JNI_ERR;
} }
@ -311,8 +301,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiEventCallbacks callbacks; jvmtiEventCallbacks callbacks;
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
callbacks.ThreadEnd = callbackThreadEnd; callbacks.ThreadEnd = callbackThreadEnd;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
} }

View File

@ -57,9 +57,7 @@ enableEvent(jvmtiEventMode enable, jvmtiEvent event) {
NSK_DISPLAY1("disabling %s\n", TranslateEvent(event)); NSK_DISPLAY1("disabling %s\n", TranslateEvent(event));
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) {
NSK_CPP_STUB4(SetEventNotificationMode, jvmti, enable,
event, NULL))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -92,10 +90,7 @@ setCallBacks() {
eventCallbacks.ThreadEnd = cbThreadEnd; eventCallbacks.ThreadEnd = cbThreadEnd;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
NSK_CPP_STUB3(SetEventCallbacks, jvmti,
&eventCallbacks,
sizeof(eventCallbacks))))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;

View File

@ -119,17 +119,17 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
/* Notify VMInit callback as well as ThreadStart callback (if any) /* Notify VMInit callback as well as ThreadStart callback (if any)
* that agent thread has been started * that agent thread has been started
*/ */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(agent_start_lock))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("[agent] failed to acquire agent_start_lock\n"); NSK_COMPLAIN0("[agent] failed to acquire agent_start_lock\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorNotifyAll, jvmti, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorNotifyAll(agent_start_lock))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("[agent] failed to notify about agent_start_lock\n"); NSK_COMPLAIN0("[agent] failed to notify about agent_start_lock\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(agent_start_lock))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("[agent] failed to release agent_start_lock\n"); NSK_COMPLAIN0("[agent] failed to release agent_start_lock\n");
} }
@ -138,7 +138,7 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
debug_agent_started = JNI_TRUE; debug_agent_started = JNI_TRUE;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, thr_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(thr_start_lock))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("[agent] failed to enter thr_start_lock\n"); NSK_COMPLAIN0("[agent] failed to enter thr_start_lock\n");
} }
@ -147,7 +147,7 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
if (next_thread == NULL ) { if (next_thread == NULL ) {
/* wait till new thread will be created and started */ /* wait till new thread will be created and started */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait, jvmti, thr_start_lock, (jlong)0))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorWait(thr_start_lock, (jlong)0))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("[agent] Failed while waiting thr_start_lock\n"); NSK_COMPLAIN0("[agent] Failed while waiting thr_start_lock\n");
} }
@ -155,9 +155,9 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
if (next_thread != NULL) { if (next_thread != NULL) {
/* hmm, why NewGlobalRef is called one more time??? /* hmm, why NewGlobalRef is called one more time???
* next_thread = NSK_CPP_STUB2(NewGlobalRef, env, next_thread); * next_thread = env->NewGlobalRef(next_thread);
*/ */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(SuspendThread, jvmti, next_thread))) { if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(next_thread))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN1("[agent] Failed to suspend thread#%d\n", eventsCount); NSK_COMPLAIN1("[agent] Failed to suspend thread#%d\n", eventsCount);
} }
@ -165,17 +165,17 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
NSK_DISPLAY2(">>> [agent] thread#%d %s suspended ...\n", eventsCount, inf.name); NSK_DISPLAY2(">>> [agent] thread#%d %s suspended ...\n", eventsCount, inf.name);
/* these dummy calls provoke VM to hang */ /* these dummy calls provoke VM to hang */
temp = NSK_CPP_STUB2(NewGlobalRef, env, next_thread); temp = env->NewGlobalRef(next_thread);
NSK_CPP_STUB2(DeleteGlobalRef, env, temp); env->DeleteGlobalRef(temp);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(ResumeThread, jvmti, next_thread))) { if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(next_thread))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN1("[agent] Failed to resume thread#%d\n", eventsCount); NSK_COMPLAIN1("[agent] Failed to resume thread#%d\n", eventsCount);
} }
NSK_DISPLAY2(">>> [agent] thread#%d %s resumed ...\n", eventsCount, inf.name); NSK_DISPLAY2(">>> [agent] thread#%d %s resumed ...\n", eventsCount, inf.name);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadState, jvmti, next_thread, &thrStat))) { if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(next_thread, &thrStat))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN1("[agent] Failed to get thread state for thread#%d\n", eventsCount); NSK_COMPLAIN1("[agent] Failed to get thread state for thread#%d\n", eventsCount);
} }
@ -185,26 +185,26 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
if (thrStat & JVMTI_THREAD_STATE_SUSPENDED) { if (thrStat & JVMTI_THREAD_STATE_SUSPENDED) {
NSK_COMPLAIN1("[agent] \"%s\" was not resumed\n", inf.name); NSK_COMPLAIN1("[agent] \"%s\" was not resumed\n", inf.name);
NSK_CPP_STUB2(FatalError, env, "[agent] could not recover"); env->FatalError("[agent] could not recover");
} }
NSK_CPP_STUB2(DeleteGlobalRef, env, next_thread); env->DeleteGlobalRef(next_thread);
next_thread = NULL; next_thread = NULL;
/* Notify ThreadStart callback that thread has been resumed */ /* Notify ThreadStart callback that thread has been resumed */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, thr_resume_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(thr_resume_lock))) {
NSK_COMPLAIN0("[agent] Failed to acquire thr_resume_lock\n"); NSK_COMPLAIN0("[agent] Failed to acquire thr_resume_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
debug_agent_timed_out = JNI_FALSE; debug_agent_timed_out = JNI_FALSE;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorNotify, jvmti, thr_resume_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorNotify(thr_resume_lock))) {
NSK_COMPLAIN0("[agent] Failed to notifing about thr_resume_lock\n"); NSK_COMPLAIN0("[agent] Failed to notifing about thr_resume_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, thr_resume_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(thr_resume_lock))) {
NSK_COMPLAIN0("[agent] Failed to release thr_resume_lock\n"); NSK_COMPLAIN0("[agent] Failed to release thr_resume_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -215,7 +215,7 @@ debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
* We don't call RawMonitorExit(thr_start_lock) in the loop so we don't * We don't call RawMonitorExit(thr_start_lock) in the loop so we don't
* lose any notify calls. * lose any notify calls.
*/ */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, thr_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(thr_start_lock))) {
NSK_COMPLAIN0("[agent] Failed to release thr_start_lock\n"); NSK_COMPLAIN0("[agent] Failed to release thr_start_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -230,7 +230,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
NSK_DISPLAY0(">>> [ThreadStart hook] start\n"); NSK_DISPLAY0(">>> [ThreadStart hook] start\n");
/* skip if thread is 'agent thread' */ /* skip if thread is 'agent thread' */
if (NSK_CPP_STUB3(IsSameObject, env, agent_thread, thread) == JNI_TRUE) { if (env->IsSameObject(agent_thread, thread) == JNI_TRUE) {
NSK_DISPLAY0(">>> [ThreadStart hook] skip agent thread\n"); NSK_DISPLAY0(">>> [ThreadStart hook] skip agent thread\n");
NSK_DISPLAY0(">>> [ThreadStart hook] end\n"); NSK_DISPLAY0(">>> [ThreadStart hook] end\n");
return; return;
@ -240,7 +240,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
* (otherwise can fail while waiting on thr_resume_thread due to timeout) * (otherwise can fail while waiting on thr_resume_thread due to timeout)
*/ */
if (debug_agent_started != JNI_TRUE) { if (debug_agent_started != JNI_TRUE) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti_env, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(agent_start_lock))) {
NSK_COMPLAIN0("[ThreadStart hook] Failed to acquire agent_start_lock\n"); NSK_COMPLAIN0("[ThreadStart hook] Failed to acquire agent_start_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -248,14 +248,13 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
while (debug_agent_started != JNI_TRUE) { while (debug_agent_started != JNI_TRUE) {
NSK_DISPLAY1(">>> [ThreadStart hook] waiting %dms for agent thread to start\n", WAIT_TIME); NSK_DISPLAY1(">>> [ThreadStart hook] waiting %dms for agent thread to start\n", WAIT_TIME);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait, if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorWait(agent_start_lock, (jlong)WAIT_TIME))) {
jvmti_env, agent_start_lock, (jlong)WAIT_TIME))) {
NSK_COMPLAIN0("[ThreadStart hook] Failed to wait for agent_start_lock\n"); NSK_COMPLAIN0("[ThreadStart hook] Failed to wait for agent_start_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(agent_start_lock))) {
NSK_COMPLAIN0("[ThreadStart hook] Failed to release agent_start_lock\n"); NSK_COMPLAIN0("[ThreadStart hook] Failed to release agent_start_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -263,7 +262,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
/* get JVMTI phase */ /* get JVMTI phase */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti_env, &phase))) { if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
NSK_COMPLAIN0("[ThreadStart hook] Failed to get JVMTI phase\n"); NSK_COMPLAIN0("[ThreadStart hook] Failed to get JVMTI phase\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -271,7 +270,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
/* Acquire event lock, /* Acquire event lock,
* so only one StartThread callback could be proceeded at the time * so only one StartThread callback could be proceeded at the time
*/ */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti_env, thr_event_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_event_lock))) {
NSK_COMPLAIN0("[ThreadStart hook] Failed to acquire thr_event_lock\n"); NSK_COMPLAIN0("[ThreadStart hook] Failed to acquire thr_event_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -281,8 +280,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
inf.name = (char*) "UNKNOWN"; inf.name = (char*) "UNKNOWN";
if (phase == JVMTI_PHASE_LIVE) { if (phase == JVMTI_PHASE_LIVE) {
/* GetThreadInfo may only be called during the live phase */ /* GetThreadInfo may only be called during the live phase */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &inf))) {
NSK_CPP_STUB3(GetThreadInfo, jvmti_env, thread, &inf))) {
NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread infor for thread#%d\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread infor for thread#%d\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -291,7 +289,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
NSK_DISPLAY2(">>> [ThreadStart hook] thread#%d: %s\n", eventsCount, inf.name); NSK_DISPLAY2(">>> [ThreadStart hook] thread#%d: %s\n", eventsCount, inf.name);
/* Acquire thr_start_lock */ /* Acquire thr_start_lock */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti_env, thr_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_start_lock))) {
NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to acquire thr_start_lock\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to acquire thr_start_lock\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -299,46 +297,45 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
/* Acquire thr_resume_lock before we release thr_start_lock to prevent /* Acquire thr_resume_lock before we release thr_start_lock to prevent
* debug agent from notifying us before we are ready. * debug agent from notifying us before we are ready.
*/ */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti_env, thr_resume_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_resume_lock))) {
NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to acquire thr_resume_lock\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to acquire thr_resume_lock\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
/* Store thread */ /* Store thread */
next_thread = NSK_CPP_STUB2(NewGlobalRef, env, thread); next_thread = env->NewGlobalRef(thread);
debug_agent_timed_out = JNI_TRUE; debug_agent_timed_out = JNI_TRUE;
/* Notify agent thread about new started thread and let agent thread to work with it */ /* Notify agent thread about new started thread and let agent thread to work with it */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorNotify, jvmti_env, thr_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorNotify(thr_start_lock))) {
NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to notify about thr_start_lock\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to notify about thr_start_lock\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_start_lock))) {
NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_start_lock\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_start_lock\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
/* Wait till this started thread will be resumed by agent thread */ /* Wait till this started thread will be resumed by agent thread */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait, if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorWait(thr_resume_lock, (jlong)WAIT_TIME ))) {
jvmti_env, thr_resume_lock, (jlong)WAIT_TIME ))) {
NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed while waiting for thr_resume_lock\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed while waiting for thr_resume_lock\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
if (debug_agent_timed_out == JNI_TRUE) { if (debug_agent_timed_out == JNI_TRUE) {
NSK_COMPLAIN1("[ThreadStart hook] \"%s\": debug agent timed out\n", inf.name); NSK_COMPLAIN1("[ThreadStart hook] \"%s\": debug agent timed out\n", inf.name);
NSK_CPP_STUB2(FatalError, env, "[ThreadStart hook] could not recover"); env->FatalError("[ThreadStart hook] could not recover");
} }
/* Release thr_resume_lock lock */ /* Release thr_resume_lock lock */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_resume_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_resume_lock))) {
NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_resume_lock\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_resume_lock\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
/* check that thread is not in SUSPENDED state */ /* check that thread is not in SUSPENDED state */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadState, jvmti_env, thread, &thrStat))) { if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadState(thread, &thrStat))) {
NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread state for thread#%d\n", eventsCount); NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread state for thread#%d\n", eventsCount);
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -348,13 +345,13 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
if (thrStat & JVMTI_THREAD_STATE_SUSPENDED) { if (thrStat & JVMTI_THREAD_STATE_SUSPENDED) {
NSK_COMPLAIN1("[ThreadStart hook] \"%s\" was self-suspended\n", inf.name); NSK_COMPLAIN1("[ThreadStart hook] \"%s\" was self-suspended\n", inf.name);
NSK_CPP_STUB2(FatalError, env, "[ThreadStart hook] could not recover"); env->FatalError("[ThreadStart hook] could not recover");
} }
eventsCount++; eventsCount++;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, thr_event_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_event_lock))) {
NSK_COMPLAIN0("[ThreadStart hook] Failed to release thr_event_lock\n"); NSK_COMPLAIN0("[ThreadStart hook] Failed to release thr_event_lock\n");
result = STATUS_FAILED; result = STATUS_FAILED;
} }
@ -368,37 +365,33 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) {
NSK_DISPLAY0(">>> VMInit event: start\n"); NSK_DISPLAY0(">>> VMInit event: start\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) {
jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) {
NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_THREAD_START\n"); NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_THREAD_START\n");
return; return;
} }
/* Start agent thread */ /* Start agent thread */
if (!NSK_VERIFY((cls = if (!NSK_VERIFY((cls = env->FindClass("java/lang/Thread")) != NULL)) {
NSK_CPP_STUB2(FindClass, env, "java/lang/Thread")) != NULL)) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: Cannot start agent thread: FindClass() failed\n"); NSK_COMPLAIN0("TEST FAILED: Cannot start agent thread: FindClass() failed\n");
return; return;
} }
if (!NSK_VERIFY((mid = if (!NSK_VERIFY((mid = env->GetMethodID(cls, "<init>", "()V")) != NULL)) {
NSK_CPP_STUB4(GetMethodID, env, cls, "<init>", "()V")) != NULL)) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: Cannot start agent thread: GetMethodID() failed\n"); NSK_COMPLAIN0("TEST FAILED: Cannot start agent thread: GetMethodID() failed\n");
return; return;
} }
if (!NSK_VERIFY((agent_thread = if (!NSK_VERIFY((agent_thread = env->NewObject(cls, mid)) != NULL)) {
NSK_CPP_STUB3(NewObject, env, cls, mid)) != NULL)) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("Cannot start agent thread: NewObject() failed\n"); NSK_COMPLAIN0("Cannot start agent thread: NewObject() failed\n");
return; return;
} }
agent_thread = (jthread) NSK_CPP_STUB2(NewGlobalRef, env, agent_thread); agent_thread = (jthread) env->NewGlobalRef(agent_thread);
if (agent_thread == NULL) { if (agent_thread == NULL) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("Cannot create global reference for agent_thread\n"); NSK_COMPLAIN0("Cannot create global reference for agent_thread\n");
@ -410,23 +403,22 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) {
* debug_agent from notifying us before we are ready. * debug_agent from notifying us before we are ready.
*/ */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti_env, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(agent_start_lock))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: failed to enter agent_start_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to enter agent_start_lock\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(RunAgentThread, if (!NSK_JVMTI_VERIFY(jvmti_env->RunAgentThread(agent_thread, debug_agent, NULL, JVMTI_THREAD_NORM_PRIORITY))) {
jvmti_env, agent_thread, debug_agent, NULL, JVMTI_THREAD_NORM_PRIORITY))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: failed to create agent thread\n"); NSK_COMPLAIN0("TEST FAILED: failed to create agent thread\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RawMonitorWait, jvmti_env, agent_start_lock, (jlong)0))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorWait(agent_start_lock, (jlong)0))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: failed to wait agent_start_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to wait agent_start_lock\n");
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti_env, agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(agent_start_lock))) {
result = STATUS_FAILED; result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILED: failed to exit agent_start_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to exit agent_start_lock\n");
} }
@ -464,17 +456,17 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPotentialCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->GetPotentialCapabilities(&caps))) {
NSK_COMPLAIN0("TEST FAILED: failed to get potential capabilities\n"); NSK_COMPLAIN0("TEST FAILED: failed to get potential capabilities\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
NSK_COMPLAIN0("TEST FAILED: failed to add capabilities during agent load\n"); NSK_COMPLAIN0("TEST FAILED: failed to add capabilities during agent load\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps))) {
NSK_COMPLAIN0("TEST FAILED: failed to get capabilities\n"); NSK_COMPLAIN0("TEST FAILED: failed to get capabilities\n");
return JNI_ERR; return JNI_ERR;
} }
@ -484,22 +476,22 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
} }
/* create raw monitors */ /* create raw monitors */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "_agent_start_lock", &agent_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_agent_start_lock", &agent_start_lock))) {
NSK_COMPLAIN0("TEST FAILED: failed to create agent_start_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to create agent_start_lock\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "_thr_event_lock", &thr_event_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_thr_event_lock", &thr_event_lock))) {
NSK_COMPLAIN0("TEST FAILED: failed to create thr_event_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to create thr_event_lock\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "_thr_start_lock", &thr_start_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_thr_start_lock", &thr_start_lock))) {
NSK_COMPLAIN0("TEST FAILED: failed to create thr_start_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to create thr_start_lock\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, jvmti, "_thr_resume_lock", &thr_resume_lock))) { if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_thr_resume_lock", &thr_resume_lock))) {
NSK_COMPLAIN0("TEST FAILED: failed to create thr_resume_lock\n"); NSK_COMPLAIN0("TEST FAILED: failed to create thr_resume_lock\n");
return JNI_ERR; return JNI_ERR;
} }
@ -508,19 +500,17 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
callbacks.VMDeath = &VMDeath; callbacks.VMDeath = &VMDeath;
callbacks.ThreadStart = &ThreadStart; callbacks.ThreadStart = &ThreadStart;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, sizeof(callbacks)))) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)))) {
NSK_COMPLAIN0("TEST FAILED: failed to set event callbacks\n"); NSK_COMPLAIN0("TEST FAILED: failed to set event callbacks\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) {
jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) {
NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_VM_INIT\n"); NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_VM_INIT\n");
return JNI_ERR; return JNI_ERR;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) {
jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) {
NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_VM_DEATH\n"); NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_VM_DEATH\n");
return JNI_ERR; return JNI_ERR;
} }

View File

@ -48,8 +48,7 @@ VMDeath(jvmtiEnv *jvmti_env, JNIEnv *env) {
NSK_DISPLAY0("CHECK PASSED: VMDeath event received\n"); NSK_DISPLAY0("CHECK PASSED: VMDeath event received\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase)))
jvmti, &phase)))
exit(95 + STATUS_FAILED); exit(95 + STATUS_FAILED);
if (phase != JVMTI_PHASE_LIVE) { if (phase != JVMTI_PHASE_LIVE) {
@ -88,13 +87,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
NSK_DISPLAY0("setting event callbacks ...\n"); NSK_DISPLAY0("setting event callbacks ...\n");
(void) memset(&callbacks, 0, sizeof(callbacks)); (void) memset(&callbacks, 0, sizeof(callbacks));
callbacks.VMDeath = &VMDeath; callbacks.VMDeath = &VMDeath;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("setting event callbacks done\nenabling VMDeath event ...\n"); NSK_DISPLAY0("setting event callbacks done\nenabling VMDeath event ...\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
return JNI_ERR; return JNI_ERR;
NSK_DISPLAY0("enabling VMDeath event done\n"); NSK_DISPLAY0("enabling VMDeath event done\n");

View File

@ -61,8 +61,7 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object,
eventsCount++; eventsCount++;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(object_klass, &signature, &generic))) {
object_klass, &signature, &generic))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -70,10 +69,10 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object,
NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size); NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size);
if (signature != NULL) if (signature != NULL)
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature); jvmti->Deallocate((unsigned char*)signature);
if (generic != NULL) if (generic != NULL)
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)generic); jvmti->Deallocate((unsigned char*)generic);
} }
@ -130,21 +129,18 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_generate_vm_object_alloc_events = 1; caps.can_generate_vm_object_alloc_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
callbacks.VMObjectAlloc= &VMObjectAlloc; callbacks.VMObjectAlloc= &VMObjectAlloc;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
NSK_CPP_STUB3(SetEventCallbacks, jvmti,
&callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
/* enable VMObjectAlloc event */ /* enable VMObjectAlloc event */
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_ENABLE, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL)))
JVMTI_EVENT_VM_OBJECT_ALLOC, NULL)))
return JNI_ERR; return JNI_ERR;
/* register agent proc and arg */ /* register agent proc and arg */

View File

@ -142,10 +142,8 @@ static int initObjectDescList(jvmtiEnv* jvmti,
printf("Allocate memory for objects list: %d objects\n", *objectsCount); printf("Allocate memory for objects list: %d objects\n", *objectsCount);
fflush(0); fflush(0);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((*objectsCount * sizeof(ObjectDesc)),
NSK_CPP_STUB3(Allocate, jvmti, (unsigned char**) objectDescList))) {
(*objectsCount * sizeof(ObjectDesc)),
(unsigned char**) objectDescList))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -180,8 +178,7 @@ static int getAndTagClasses(jvmtiEnv* jvmti,
jclass* chainObjectClass) jclass* chainObjectClass)
{ {
if (!NSK_JNI_VERIFY(jni, (*debugeeClass = if (!NSK_JNI_VERIFY(jni, (*debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -190,14 +187,12 @@ static int getAndTagClasses(jvmtiEnv* jvmti,
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObjectClass = if (!NSK_JNI_VERIFY(jni, (*rootObjectClass =
NSK_CPP_STUB2(FindClass, jni, ROOT_OBJECT_CLASS_NAME)) != NULL)) { jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->SetTag(*rootObjectClass, ROOT_CLASS_TAG))) {
*rootObjectClass,
ROOT_CLASS_TAG))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -208,14 +203,12 @@ static int getAndTagClasses(jvmtiEnv* jvmti,
if (!NSK_JNI_VERIFY(jni, (*chainObjectClass = if (!NSK_JNI_VERIFY(jni, (*chainObjectClass =
NSK_CPP_STUB2(FindClass, jni, CHAIN_OBJECT_CLASS_NAME)) != NULL)) { jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->SetTag(*chainObjectClass, CHAIN_CLASS_TAG))) {
*chainObjectClass,
CHAIN_CLASS_TAG))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf("\nFound chain object class: 0x%p, tag=%ld\n %s\n", printf("\nFound chain object class: 0x%p, tag=%ld\n %s\n",
@ -241,10 +234,7 @@ static int getFieldsAndObjects(jvmtiEnv* jvmti,
jfieldID rootObjectField = NULL; jfieldID rootObjectField = NULL;
if (!NSK_JNI_VERIFY(jni, (rootObjectField = if (!NSK_JNI_VERIFY(jni, (rootObjectField =
NSK_CPP_STUB4(GetStaticFieldID, jni, jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) {
debugeeClass,
OBJECT_FIELD_NAME,
ROOT_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -253,9 +243,7 @@ static int getFieldsAndObjects(jvmtiEnv* jvmti,
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*reachableChainField = if (!NSK_JNI_VERIFY(jni, (*reachableChainField =
NSK_CPP_STUB4(GetFieldID, jni, rootObjectClass, jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
REACHABLE_CHAIN_FIELD_NAME,
CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -264,9 +252,7 @@ static int getFieldsAndObjects(jvmtiEnv* jvmti,
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*unreachableChainField = if (!NSK_JNI_VERIFY(jni, (*unreachableChainField =
NSK_CPP_STUB4(GetFieldID, jni, rootObjectClass, jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
UNREACHABLE_CHAIN_FIELD_NAME,
CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -276,8 +262,7 @@ static int getFieldsAndObjects(jvmtiEnv* jvmti,
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*nextField = if (!NSK_JNI_VERIFY(jni, (*nextField =
NSK_CPP_STUB4(GetFieldID, jni, chainObjectClass, jni->GetFieldID(chainObjectClass, NEXT_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
NEXT_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -286,16 +271,14 @@ static int getFieldsAndObjects(jvmtiEnv* jvmti,
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr = if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr =
NSK_CPP_STUB3(GetStaticObjectField, jni, jni->GetStaticObjectField(debugeeClass, rootObjectField)) != NULL)) {
debugeeClass, rootObjectField)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf("\nFound root object: 0x%p\n", (void*) *rootObjectPtr); printf("\nFound root object: 0x%p\n", (void*) *rootObjectPtr);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr = if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr = jni->NewGlobalRef(*rootObjectPtr)) != NULL)) {
NSK_CPP_STUB2(NewGlobalRef, jni, *rootObjectPtr)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -328,8 +311,7 @@ static int getAndTagChainObjects(
count--; count--;
tag++; tag++;
if (!NSK_JNI_VERIFY(jni, (nextObj = if (!NSK_JNI_VERIFY(jni, (nextObj = jni->GetObjectField(currObj, refField)) != NULL)) {
NSK_CPP_STUB3(GetObjectField, jni, currObj, refField)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -339,7 +321,7 @@ static int getAndTagChainObjects(
objectDescList[count].exp_found++; objectDescList[count].exp_found++;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, nextObj, objTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(nextObj, objTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld object=0x%p\n", (long)objTag, (void*)nextObj); printf(" tag=%-5ld object=0x%p\n", (long)objTag, (void*)nextObj);
@ -359,7 +341,7 @@ static int getAndTagChainObjects(
return NSK_FALSE; return NSK_FALSE;
} }
NSK_TRACE(NSK_CPP_STUB2(DeleteLocalRef, jni, nextObj)); NSK_TRACE(jni->DeleteLocalRef(nextObj));
return NSK_TRUE; return NSK_TRUE;
} /* getAndTagChainObjects */ } /* getAndTagChainObjects */
@ -411,9 +393,7 @@ static int getAndTagTestedObjects(
printf("\nObtain and tag chain objects:\n"); printf("\nObtain and tag chain objects:\n");
printf(" root tested object:\n"); printf(" root tested object:\n");
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->SetTag(*rootObjectPtr, ROOT_OBJECT_TAG))
*rootObjectPtr,
ROOT_OBJECT_TAG))
) { ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -531,13 +511,12 @@ static int releaseTestedObjects(jvmtiEnv* jvmti,
{ {
if (rootObject != NULL) { if (rootObject != NULL) {
printf("Release object reference to root tested object: 0x%p\n", rootObject); printf("Release object reference to root tested object: 0x%p\n", rootObject);
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, rootObject)); NSK_TRACE(jni->DeleteGlobalRef(rootObject));
} }
if (objectDescList != NULL) { if (objectDescList != NULL) {
printf("Deallocate objects list: 0x%p\n", (void*)objectDescList); printf("Deallocate objects list: 0x%p\n", (void*)objectDescList);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)objectDescList))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
} }
@ -786,14 +765,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
printf(">>> Start iteration from root tested object: 0x%p\n\n", rootObject); printf(">>> Start iteration from root tested object: 0x%p\n\n", rootObject);
fflush(0); fflush(0);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences((jint) 0, /* heap_filter */
NSK_CPP_STUB6(FollowReferences, jvmti, (jclass) NULL, /* class */
(jint) 0, /* heap_filter */ rootObject, /* initial_object */
(jclass) NULL, /* class */ &heapCallbacks,
rootObject, /* initial_object */ (const void *) &fakeUserData))) {
&heapCallbacks,
(const void *) &fakeUserData))
) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -856,7 +832,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_tag_objects = 1; caps.can_tag_objects = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -119,8 +119,7 @@ static int getAndTagChainObjects(
count--; count--;
tag++; tag++;
if (!NSK_JNI_VERIFY(jni, (obj = if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != NULL)) {
NSK_CPP_STUB3(GetObjectField, jni, firstObject, firstField)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -130,7 +129,7 @@ static int getAndTagChainObjects(
objectDescList[count].exp_found++; objectDescList[count].exp_found++;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, obj, objTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(obj, objTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld object=0x%p\n", (long)objTag, (void*)obj); printf(" tag=%-5ld object=0x%p\n", (long)objTag, (void*)obj);
@ -147,7 +146,7 @@ static int getAndTagChainObjects(
return NSK_FALSE; return NSK_FALSE;
} }
NSK_TRACE(NSK_CPP_STUB2(DeleteLocalRef, jni, obj)); NSK_TRACE(jni->DeleteLocalRef(obj));
return NSK_TRUE; return NSK_TRUE;
} /* getAndTagChainObjects */ } /* getAndTagChainObjects */
@ -174,9 +173,8 @@ static int getAndTagTestedObjects(
printf("Allocate memory for objects list: %d objects\n", *objectsCount); printf("Allocate memory for objects list: %d objects\n", *objectsCount);
fflush(0); fflush(0);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((*objectsCount * sizeof(ObjectDesc)),
NSK_CPP_STUB3(Allocate, jvmti, (*objectsCount * sizeof(ObjectDesc)), (unsigned char**)objectDescList))) {
(unsigned char**)objectDescList))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -196,8 +194,7 @@ static int getAndTagTestedObjects(
printf("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); printf("Find debugee class: %s\n", DEBUGEE_CLASS_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (debugeeClass = if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -205,14 +202,13 @@ static int getAndTagTestedObjects(
printf("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); printf("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (rootObjectClass = if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni, ROOT_OBJECT_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf(" ... found class: 0x%p\n", (void*)rootObjectClass); printf(" ... found class: 0x%p\n", (void*)rootObjectClass);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, rootObjectClass, rootClassTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(rootObjectClass, rootClassTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld rootClass=0x%p\n", (long)rootClassTag, (void*)rootObjectClass); printf(" tag=%-5ld rootClass=0x%p\n", (long)rootClassTag, (void*)rootObjectClass);
@ -220,13 +216,13 @@ static int getAndTagTestedObjects(
printf("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); printf("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (chainObjectClass = if (!NSK_JNI_VERIFY(jni, (chainObjectClass =
NSK_CPP_STUB2(FindClass, jni, CHAIN_OBJECT_CLASS_NAME)) != NULL)) { jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf(" ... found class: 0x%p\n", (void*)chainObjectClass); printf(" ... found class: 0x%p\n", (void*)chainObjectClass);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, chainObjectClass, chainClassTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(chainObjectClass, chainClassTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld chainClass=0x%p\n", (long)chainClassTag, (void*)chainObjectClass); printf(" tag=%-5ld chainClass=0x%p\n", (long)chainClassTag, (void*)chainObjectClass);
@ -234,8 +230,7 @@ static int getAndTagTestedObjects(
printf("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); printf("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (objectField = if (!NSK_JNI_VERIFY(jni, (objectField =
NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass, jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) {
OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -244,8 +239,7 @@ static int getAndTagTestedObjects(
printf("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); printf("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (reachableChainField = if (!NSK_JNI_VERIFY(jni, (reachableChainField =
NSK_CPP_STUB4(GetFieldID, jni, rootObjectClass, jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -254,8 +248,7 @@ static int getAndTagTestedObjects(
printf("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); printf("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (unreachableChainField = if (!NSK_JNI_VERIFY(jni, (unreachableChainField =
NSK_CPP_STUB4(GetFieldID, jni, rootObjectClass, jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -264,8 +257,7 @@ static int getAndTagTestedObjects(
printf("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); printf("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (tailField = if (!NSK_JNI_VERIFY(jni, (tailField =
NSK_CPP_STUB4(GetFieldID, jni, chainObjectClass, jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -274,16 +266,14 @@ static int getAndTagTestedObjects(
printf("Get root object from static field: %s\n", OBJECT_FIELD_NAME); printf("Get root object from static field: %s\n", OBJECT_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObject = if (!NSK_JNI_VERIFY(jni, (*rootObject =
NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) {
objectField)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf(" ... got object: 0x%p\n", (void*)*rootObject); printf(" ... got object: 0x%p\n", (void*)*rootObject);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObject = if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != NULL)) {
NSK_CPP_STUB2(NewGlobalRef, jni, *rootObject)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -293,7 +283,7 @@ static int getAndTagTestedObjects(
printf(" root tested object:\n"); printf(" root tested object:\n");
fflush(0); fflush(0);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, *rootObject, rootObjectTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(*rootObject, rootObjectTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld object=0x%p\n", (long)rootObjectTag, (void*)*rootObject); printf(" tag=%-5ld object=0x%p\n", (long)rootObjectTag, (void*)*rootObject);
@ -406,13 +396,12 @@ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
ObjectDesc* objectDescList, jobject rootObject) { ObjectDesc* objectDescList, jobject rootObject) {
if (rootObject != NULL) { if (rootObject != NULL) {
printf("Release object reference to root tested object: 0x%p\n", rootObject); printf("Release object reference to root tested object: 0x%p\n", rootObject);
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, rootObject)); NSK_TRACE(jni->DeleteGlobalRef(rootObject));
} }
if (objectDescList != NULL) { if (objectDescList != NULL) {
printf("Deallocate objects list: 0x%p\n", (void*)objectDescList); printf("Deallocate objects list: 0x%p\n", (void*)objectDescList);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)objectDescList))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
} }
@ -645,14 +634,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
fflush(0); fflush(0);
{ {
jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED; jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences(heap_filter,
NSK_CPP_STUB6(FollowReferences, jvmti, (jclass) NULL, /* class */
heap_filter, rootObject, /* initial_object */
(jclass) NULL, /* class */ &heapCallbacks,
rootObject, /* initial_object */ (const void *) &fakeUserData))) {
&heapCallbacks,
(const void *) &fakeUserData)))
{
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -681,14 +667,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
/* This time everythig is filtered out */ /* This time everythig is filtered out */
jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED | jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED |
JVMTI_HEAP_FILTER_TAGGED | JVMTI_HEAP_FILTER_CLASS_TAGGED; JVMTI_HEAP_FILTER_TAGGED | JVMTI_HEAP_FILTER_CLASS_TAGGED;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences(heap_filter,
NSK_CPP_STUB6(FollowReferences, jvmti, (jclass) NULL, /* class */
heap_filter, rootObject, /* initial_object */
(jclass) NULL, /* class */ &heapCallbacks,
rootObject, /* initial_object */ (const void *) &fakeUserData))) {
&heapCallbacks,
(const void *) &fakeUserData)))
{
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -751,7 +734,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_tag_objects = 1; caps.can_tag_objects = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -138,15 +138,14 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject,
count--; count--;
tag++; tag++;
if (!NSK_JNI_VERIFY(jni, (obj = if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != NULL)) {
NSK_CPP_STUB3(GetObjectField, jni, firstObject, firstField)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
objectDescList[count].tag = objTag; objectDescList[count].tag = objTag;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, obj, objTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(obj, objTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld object=0x%p\n", (long)objTag, (void*)obj); printf(" tag=%-5ld object=0x%p\n", (long)objTag, (void*)obj);
@ -157,7 +156,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject,
return NSK_FALSE; return NSK_FALSE;
} }
NSK_TRACE(NSK_CPP_STUB2(DeleteLocalRef, jni, obj)); NSK_TRACE(jni->DeleteLocalRef(obj));
return NSK_TRUE; return NSK_TRUE;
} }
@ -178,9 +177,8 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Allocate memory for objects list: %d objects\n", *objectsCount); printf("Allocate memory for objects list: %d objects\n", *objectsCount);
fflush(0); fflush(0);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Allocate((*objectsCount * sizeof(ObjectDesc)),
NSK_CPP_STUB3(Allocate, jvmti, (*objectsCount * sizeof(ObjectDesc)), (unsigned char**)objectDescList))) {
(unsigned char**)objectDescList))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -200,8 +198,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); printf("Find debugee class: %s\n", DEBUGEE_CLASS_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (debugeeClass = if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -209,14 +206,13 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); printf("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (rootObjectClass = if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni, ROOT_OBJECT_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf(" ... found class: 0x%p\n", (void*)rootObjectClass); printf(" ... found class: 0x%p\n", (void*)rootObjectClass);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, rootObjectClass, rootClassTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(rootObjectClass, rootClassTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld rootClass=0x%p\n", printf(" tag=%-5ld rootClass=0x%p\n",
@ -225,14 +221,14 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); printf("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (chainObjectClass = if (!NSK_JNI_VERIFY(jni, (chainObjectClass =
NSK_CPP_STUB2(FindClass, jni, CHAIN_OBJECT_CLASS_NAME)) != NULL)) { jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf(" ... found class: 0x%p\n", printf(" ... found class: 0x%p\n",
(void*)chainObjectClass); (void*)chainObjectClass);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, chainObjectClass, chainClassTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(chainObjectClass, chainClassTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld chainClass=0x%p\n", printf(" tag=%-5ld chainClass=0x%p\n",
@ -241,8 +237,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); printf("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (objectField = if (!NSK_JNI_VERIFY(jni, (objectField =
NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass, jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) {
OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -251,8 +246,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); printf("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (reachableChainField = if (!NSK_JNI_VERIFY(jni, (reachableChainField =
NSK_CPP_STUB4(GetFieldID, jni, rootObjectClass, jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -261,8 +255,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); printf("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (unreachableChainField = if (!NSK_JNI_VERIFY(jni, (unreachableChainField =
NSK_CPP_STUB4(GetFieldID, jni, rootObjectClass, jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -271,8 +264,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); printf("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (tailField = if (!NSK_JNI_VERIFY(jni, (tailField =
NSK_CPP_STUB4(GetFieldID, jni, chainObjectClass, jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -281,16 +273,14 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf("Get root object from static field: %s\n", OBJECT_FIELD_NAME); printf("Get root object from static field: %s\n", OBJECT_FIELD_NAME);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObject = if (!NSK_JNI_VERIFY(jni, (*rootObject =
NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) {
objectField)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
printf(" ... got object: 0x%p\n", (void*)*rootObject); printf(" ... got object: 0x%p\n", (void*)*rootObject);
fflush(0); fflush(0);
if (!NSK_JNI_VERIFY(jni, (*rootObject = if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != NULL)) {
NSK_CPP_STUB2(NewGlobalRef, jni, *rootObject)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -300,7 +290,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
printf(" root tested object\n"); printf(" root tested object\n");
fflush(0); fflush(0);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, *rootObject, rootObjectTag))) { if (!NSK_JVMTI_VERIFY(jvmti->SetTag(*rootObject, rootObjectTag))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
printf(" tag=%-5ld object=0x%p\n", printf(" tag=%-5ld object=0x%p\n",
@ -406,13 +396,12 @@ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength,
ObjectDesc* objectDescList, jobject rootObject) { ObjectDesc* objectDescList, jobject rootObject) {
if (rootObject != NULL) { if (rootObject != NULL) {
printf("Release object reference to root tested object: 0x%p\n", rootObject); printf("Release object reference to root tested object: 0x%p\n", rootObject);
NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, rootObject)); NSK_TRACE(jni->DeleteGlobalRef(rootObject));
} }
if (objectDescList != NULL) { if (objectDescList != NULL) {
printf("Deallocate objects list: 0x%p\n", (void*)objectDescList); printf("Deallocate objects list: 0x%p\n", (void*)objectDescList);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) {
NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)objectDescList))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
} }
@ -949,14 +938,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
printf("\n\n>>> Start 1-st iteration starting from the heap root\n"); printf("\n\n>>> Start 1-st iteration starting from the heap root\n");
fflush(0); fflush(0);
{ {
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences((jint) 0, /* heap_filter */
NSK_CPP_STUB6(FollowReferences, jvmti, (jclass) NULL, /* class */
(jint) 0, /* heap_filter */ (jobject) NULL, /* initial_object */
(jclass) NULL, /* class */ &heapCallbacks,
(jobject) NULL, /* initial_object */ (const void *) &fakeUserData))) {
&heapCallbacks,
(const void *) &fakeUserData)))
{
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -990,14 +976,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
{ {
jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED
| JVMTI_HEAP_FILTER_CLASS_UNTAGGED; | JVMTI_HEAP_FILTER_CLASS_UNTAGGED;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences(heap_filter,
NSK_CPP_STUB6(FollowReferences, jvmti, (jclass) NULL, /* class */
heap_filter, (jobject) NULL, /* initial_object */
(jclass) NULL, /* class */ &heapCallbacks,
(jobject) NULL, /* initial_object */ (const void *) &fakeUserData))) {
&heapCallbacks,
(const void *) &fakeUserData)))
{
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -1086,7 +1069,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_tag_objects = 1; caps.can_tag_objects = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -146,16 +146,16 @@ static void createGlobalRefs(JNIEnv * jni)
{ {
jclass klass; jclass klass;
if ( ! NSK_JNI_VERIFY(jni, (klass = NSK_CPP_STUB2(FindClass, jni, JAVA_LANG_STRING_CLASS_NAME)) != NULL) ) { if ( ! NSK_JNI_VERIFY(jni, (klass = jni->FindClass(JAVA_LANG_STRING_CLASS_NAME)) != NULL) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
if ( ! NSK_JNI_VERIFY(jni, (g_jniGlobalRef = NSK_CPP_STUB2(NewGlobalRef, jni, klass)) != NULL) ) { if ( ! NSK_JNI_VERIFY(jni, (g_jniGlobalRef = jni->NewGlobalRef(klass)) != NULL) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
if ( ! NSK_JNI_VERIFY(jni, (g_jniWeakGlobalRef = NSK_CPP_STUB2(NewWeakGlobalRef, jni, klass)) != NULL) ) { if ( ! NSK_JNI_VERIFY(jni, (g_jniWeakGlobalRef = jni->NewWeakGlobalRef(klass)) != NULL) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -179,13 +179,11 @@ static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg)
createGlobalRefs(jni); createGlobalRefs(jni);
retCode = NSK_CPP_STUB6(FollowReferences, retCode = jvmti->FollowReferences((jint) 0, /* heap filter */
jvmti, NULL, /* class */
(jint) 0, /* heap filter */ NULL, /* inital object */
NULL, /* class */ &g_heapCallbacks,
NULL, /* inital object */ (const void *) &g_fakeUserData);
&g_heapCallbacks,
(const void *) &g_fakeUserData);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NONE) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NONE) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -247,7 +245,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved)
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_tag_objects = 1; caps.can_tag_objects = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -45,58 +45,42 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
printf(">>> Check that FollowReferences(), IterateThroughHeap(), GetTag(), SetTag() and GetObjectsWithTags() \n" printf(">>> Check that FollowReferences(), IterateThroughHeap(), GetTag(), SetTag() and GetObjectsWithTags() \n"
" return an error if env. doesn't possess can_tag_objects capability\n"); " return an error if env. doesn't possess can_tag_objects capability\n");
retCode = NSK_CPP_STUB6(FollowReferences, retCode = jvmti->FollowReferences((jint) 0, /* heap filter */
jvmti, NULL, /* class */
(jint) 0, /* heap filter */ NULL, /* inital object */
NULL, /* class */ &g_wrongHeapCallbacks,
NULL, /* inital object */ (const void *) &g_fakeUserData);
&g_wrongHeapCallbacks,
(const void *) &g_fakeUserData);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
NSK_COMPLAIN1("FollowReferences() returned %i", retCode); NSK_COMPLAIN1("FollowReferences() returned %i", retCode);
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
retCode = NSK_CPP_STUB5(IterateThroughHeap, retCode = jvmti->IterateThroughHeap((jint) 0, /* heap filter */
jvmti, NULL, /* class */
(jint) 0, /* heap filter */ &g_wrongHeapCallbacks,
NULL, /* class */ (const void *) &g_fakeUserData);
&g_wrongHeapCallbacks,
(const void *) &g_fakeUserData);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
NSK_COMPLAIN1("IterateThroughHeap() returned %i", retCode); NSK_COMPLAIN1("IterateThroughHeap() returned %i", retCode);
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
retCode = NSK_CPP_STUB3(GetTag, retCode = jvmti->GetTag((jobject) &g_wrongHeapCallbacks, &tag);
jvmti,
(jobject) &g_wrongHeapCallbacks,
&tag);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
NSK_COMPLAIN1("GetTag() returned %i", retCode); NSK_COMPLAIN1("GetTag() returned %i", retCode);
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
retCode = NSK_CPP_STUB3(SetTag, retCode = jvmti->SetTag((jobject) &g_wrongHeapCallbacks, tag);
jvmti,
(jobject) &g_wrongHeapCallbacks,
tag);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
NSK_COMPLAIN1("SetTag() returned %i", retCode); NSK_COMPLAIN1("SetTag() returned %i", retCode);
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
retCode = NSK_CPP_STUB6(GetObjectsWithTags, retCode = jvmti->GetObjectsWithTags(1, &tag, &cnt, &pObjs, &pObjTags);
jvmti,
1,
&tag,
&cnt,
&pObjs,
&pObjTags);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
NSK_COMPLAIN1("GetObjectsWithTags() returned %i", retCode); NSK_COMPLAIN1("GetObjectsWithTags() returned %i", retCode);
@ -148,7 +132,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
/* Don't add can_tag_objects capability */ /* Don't add can_tag_objects capability */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -49,13 +49,11 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("FollowReferences: Invalid class:"); NSK_DISPLAY0("FollowReferences: Invalid class:");
retCode = NSK_CPP_STUB6(FollowReferences, retCode = jvmti->FollowReferences((jint) 0, /* heap filter */
jvmti, (jclass) &g_wrongHeapCallbacks , /* invalid class, but valid memory address */
(jint) 0, /* heap filter */ NULL, /* inital object */
(jclass) &g_wrongHeapCallbacks , /* invalid class, but valid memory address */ &g_wrongHeapCallbacks,
NULL, /* inital object */ (const void *) &g_fakeUserData);
&g_wrongHeapCallbacks,
(const void *) &g_fakeUserData);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_CLASS ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_CLASS ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -75,13 +73,11 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
emptyHeapCallbacks.primitive_field_callback = NULL; emptyHeapCallbacks.primitive_field_callback = NULL;
emptyHeapCallbacks.array_primitive_value_callback = NULL; emptyHeapCallbacks.array_primitive_value_callback = NULL;
emptyHeapCallbacks.string_primitive_value_callback = NULL; emptyHeapCallbacks.string_primitive_value_callback = NULL;
retCode = NSK_CPP_STUB6(FollowReferences, retCode = jvmti->FollowReferences((jint) 0, // heap filter
jvmti, NULL, // class
(jint) 0, // heap filter (jobject) &g_wrongHeapCallbacks, // invalid inital object
NULL, // class &emptyHeapCallbacks, // No callbacks
(jobject) &g_wrongHeapCallbacks, // invalid inital object (const void *) &g_fakeUserData);
&emptyHeapCallbacks, // No callbacks
(const void *) &g_fakeUserData);
// Accept both JVMTI_ERROR_INVALID_OBJECT and JVMTI_ERROR_NONE // Accept both JVMTI_ERROR_INVALID_OBJECT and JVMTI_ERROR_NONE
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT || retCode == JVMTI_ERROR_NONE ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT || retCode == JVMTI_ERROR_NONE ) ) {
@ -90,13 +86,11 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("FollowReferences: Invalid callbacks:"); NSK_DISPLAY0("FollowReferences: Invalid callbacks:");
retCode = NSK_CPP_STUB6(FollowReferences, retCode = jvmti->FollowReferences((jint) 0, /* heap filter */
jvmti, NULL, /* class */
(jint) 0, /* heap filter */ NULL, /* inital object */
NULL, /* class */ NULL,
NULL, /* inital object */ (const void *) &g_fakeUserData);
NULL,
(const void *) &g_fakeUserData);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NULL_POINTER ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NULL_POINTER ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -104,10 +98,8 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("GetTag: Invalid object:"); NSK_DISPLAY0("GetTag: Invalid object:");
retCode = NSK_CPP_STUB3(GetTag, retCode = jvmti->GetTag((jobject) &g_wrongHeapCallbacks, /* invalid inital object */
jvmti, &tag);
(jobject) &g_wrongHeapCallbacks, /* invalid inital object */
&tag);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -115,10 +107,7 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("GetTag: NULL object pointer:"); NSK_DISPLAY0("GetTag: NULL object pointer:");
retCode = NSK_CPP_STUB3(GetTag, retCode = jvmti->GetTag(NULL, &tag);
jvmti,
NULL,
&tag);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -126,10 +115,7 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("GetTag: NULL tag pointer:"); NSK_DISPLAY0("GetTag: NULL tag pointer:");
retCode = NSK_CPP_STUB3(GetTag, retCode = jvmti->GetTag((jobject) &g_wrongHeapCallbacks, NULL);
jvmti,
(jobject) &g_wrongHeapCallbacks,
NULL);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NULL_POINTER ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NULL_POINTER ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -138,10 +124,8 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("SetTag: Invalid object:"); NSK_DISPLAY0("SetTag: Invalid object:");
tag = 1; tag = 1;
retCode = NSK_CPP_STUB3(SetTag, retCode = jvmti->SetTag((jobject) &g_wrongHeapCallbacks, /* invalid inital object */
jvmti, tag);
(jobject) &g_wrongHeapCallbacks, /* invalid inital object */
tag);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -149,10 +133,7 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti)
NSK_DISPLAY0("SetTag: NULL object pointer:"); NSK_DISPLAY0("SetTag: NULL object pointer:");
retCode = NSK_CPP_STUB3(GetTag, retCode = jvmti->GetTag(NULL, &tag);
jvmti,
NULL,
&tag);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -170,19 +151,16 @@ static void checkNoObjIterated(JNIEnv* jni, jvmtiEnv* jvmti, const char * szClas
jclass klass; jclass klass;
NSK_DISPLAY1("Verify, that no objects are returned if initial object is %s", szClassName); NSK_DISPLAY1("Verify, that no objects are returned if initial object is %s", szClassName);
if (!NSK_JNI_VERIFY(jni, (klass = if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass(szClassName)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni, szClassName)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
retCode = NSK_CPP_STUB6(FollowReferences, retCode = jvmti->FollowReferences((jint) 0, /* heap filter */
jvmti, klass, /* class */
(jint) 0, /* heap filter */ NULL, /* inital object */
klass, /* class */ &g_wrongHeapCallbacks,
NULL, /* inital object */ (const void *) &g_fakeUserData);
&g_wrongHeapCallbacks,
(const void *) &g_fakeUserData);
if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NONE ) ) { if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_NONE ) ) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
@ -252,7 +230,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved)
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_tag_objects = 1; caps.can_tag_objects = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -715,7 +715,7 @@ static int doHotSwap(JNIEnv *jni_env, jclass redefCls, jint bCount,
"#### JVMTIagent: >>>>>>>> Invoke RedefineClasses():\n" "#### JVMTIagent: >>>>>>>> Invoke RedefineClasses():\n"
"<JVMTIagent>\tnew class byte count=%d\n", "<JVMTIagent>\tnew class byte count=%d\n",
classDef.class_byte_count); classDef.class_byte_count);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(jvmti->RedefineClasses(1, &classDef))) if (!NSK_JVMTI_VERIFY(jvmti->RedefineClasses(1, &classDef)))
return 1; return 1;
display(0, "#### JVMTIagent: <<<<<<<< RedefineClasses() is successfully done ####\n"); display(0, "#### JVMTIagent: <<<<<<<< RedefineClasses() is successfully done ####\n");

View File

@ -41,7 +41,7 @@ and checking JNI errors and pending exceptions:
NSK_JNI_VERIFY(jni, action) NSK_JNI_VERIFY(jni, action)
NSK_JNI_VERIFY_NEGATIVE(jni, action) NSK_JNI_VERIFY_NEGATIVE(jni, action)
Typical example of usage of NSK_JNI_VERIFY and NSK_CPP_STUB macroses Typical example of usage of the NSK_JNI_VERIFY macro
for invokation of JNI functions: for invokation of JNI functions:
// jni->FindClass(jni, class_name) // jni->FindClass(jni, class_name)

View File

@ -51,8 +51,7 @@ jvmtiPhase jvmti_phase_to_check = JVMTI_PHASE_ONLOAD;
*/ */
static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[]) { static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[]) {
NSK_DISPLAY1("Add segment: \"%s\"\n", segment); NSK_DISPLAY1("Add segment: \"%s\"\n", segment);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddToBootstrapClassLoaderSearch(segment))) {
NSK_CPP_STUB2(AddToBootstrapClassLoaderSearch, jvmti, segment))) {
NSK_COMPLAIN1("TEST FAILURE: failed to add segment %s\n", segment); NSK_COMPLAIN1("TEST FAILURE: failed to add segment %s\n", segment);
return NSK_FALSE; return NSK_FALSE;
} }
@ -68,8 +67,7 @@ static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[])
*/ */
static int addIllegalSegment(jvmtiEnv* jvmti, const char segment[], const char where[], jvmtiError expectedError) { static int addIllegalSegment(jvmtiEnv* jvmti, const char segment[], const char where[], jvmtiError expectedError) {
NSK_DISPLAY1("Add illegal segment: \"%s\"\n", segment); NSK_DISPLAY1("Add illegal segment: \"%s\"\n", segment);
if (!NSK_JVMTI_VERIFY_CODE(expectedError, if (!NSK_JVMTI_VERIFY_CODE(expectedError, jvmti->AddToBootstrapClassLoaderSearch(segment))) {
NSK_CPP_STUB2(AddToBootstrapClassLoaderSearch, jvmti, segment))) {
NSK_COMPLAIN2("TEST FAILURE: got wrong error when tried to add segment %s (expected error=%s)\n", NSK_COMPLAIN2("TEST FAILURE: got wrong error when tried to add segment %s (expected error=%s)\n",
segment, TranslateError(expectedError)); segment, TranslateError(expectedError));
@ -123,7 +121,7 @@ void JNICALL
callbackVMDeath(jvmtiEnv *jvmti, JNIEnv* jni) { callbackVMDeath(jvmtiEnv *jvmti, JNIEnv* jni) {
jvmtiPhase phase; jvmtiPhase phase;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti, &phase))) { if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase))) {
NSK_COMPLAIN0("TEST FAILURE: unable to get phase\n"); NSK_COMPLAIN0("TEST FAILURE: unable to get phase\n");
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
NSK_BEFORE_TRACE(exit(nsk_jvmti_getStatus())); NSK_BEFORE_TRACE(exit(nsk_jvmti_getStatus()));
@ -218,8 +216,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
eventCallbacks.VMInit = callbackVMInit; eventCallbacks.VMInit = callbackVMInit;
eventCallbacks.VMDeath = callbackVMDeath; eventCallbacks.VMDeath = callbackVMDeath;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
&eventCallbacks, sizeof(eventCallbacks)))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -51,8 +51,7 @@ jvmtiPhase jvmti_phase_to_check = JVMTI_PHASE_ONLOAD;
*/ */
static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[]) { static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[]) {
NSK_DISPLAY1("Add segment: \"%s\"\n", segment); NSK_DISPLAY1("Add segment: \"%s\"\n", segment);
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->AddToSystemClassLoaderSearch(segment))) {
NSK_CPP_STUB2(AddToSystemClassLoaderSearch, jvmti, segment))) {
NSK_COMPLAIN1("TEST FAILURE: failed to add segment %s\n", segment); NSK_COMPLAIN1("TEST FAILURE: failed to add segment %s\n", segment);
return NSK_FALSE; return NSK_FALSE;
} }
@ -68,8 +67,7 @@ static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[])
*/ */
static int addIllegalSegment(jvmtiEnv* jvmti, const char segment[], const char where[], jvmtiError expectedError) { static int addIllegalSegment(jvmtiEnv* jvmti, const char segment[], const char where[], jvmtiError expectedError) {
NSK_DISPLAY1("Add illegal segment: \"%s\"\n", segment); NSK_DISPLAY1("Add illegal segment: \"%s\"\n", segment);
if (!NSK_JVMTI_VERIFY_CODE(expectedError, if (!NSK_JVMTI_VERIFY_CODE(expectedError, jvmti->AddToSystemClassLoaderSearch(segment))) {
NSK_CPP_STUB2(AddToSystemClassLoaderSearch, jvmti, segment))) {
NSK_COMPLAIN2("TEST FAILURE: got wrong error when tried to add segment %s (expected error=%s)\n", NSK_COMPLAIN2("TEST FAILURE: got wrong error when tried to add segment %s (expected error=%s)\n",
segment, TranslateError(expectedError)); segment, TranslateError(expectedError));
@ -123,7 +121,7 @@ void JNICALL
callbackVMDeath(jvmtiEnv *jvmti, JNIEnv* jni) { callbackVMDeath(jvmtiEnv *jvmti, JNIEnv* jni) {
jvmtiPhase phase; jvmtiPhase phase;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti, &phase))) { if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase))) {
NSK_COMPLAIN0("TEST FAILURE: unable to get phase\n"); NSK_COMPLAIN0("TEST FAILURE: unable to get phase\n");
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
NSK_BEFORE_TRACE(exit(nsk_jvmti_getStatus())); NSK_BEFORE_TRACE(exit(nsk_jvmti_getStatus()));
@ -218,8 +216,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
eventCallbacks.VMInit = callbackVMInit; eventCallbacks.VMInit = callbackVMInit;
eventCallbacks.VMDeath = callbackVMDeath; eventCallbacks.VMDeath = callbackVMDeath;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
&eventCallbacks, sizeof(eventCallbacks)))) {
return JNI_ERR; return JNI_ERR;
} }
} }

View File

@ -117,20 +117,18 @@ Also provides functions for running JVMTI agent:
--------------------------------------------------------------------------------- ---------------------------------------------------------------------------------
Typical example of usage of NSK_JVMTI_VERIFY and NSK_CPP_STUB macroses Typical example of usage of the NSK_JVMTI_VERIFY macro
for invocation of JVMTI functions: for invocation of JVMTI functions:
// jvmti->GetVersion(jvmti, &version) // jvmti->GetVersion(jvmti, &version)
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->GetVersion(&version) != NULL)) {
NSK_CPP_STUB2(GetVersion, jvmti, &version) != NULL)) {
return JNI_ERR; return JNI_ERR;
} }
or with saving error code: or with saving error code:
// err = jvmti->GetVersion(jvmti, &version) // err = jvmti->GetVersion(jvmti, &version)
if (!NSK_JVMTI_VERIFY(err = if (!NSK_JVMTI_VERIFY(err = jvmti->GetVersion(&version))) {
NSK_CPP_STUB2(GetVersion, jvmti, &version))) {
return err; return err;
} }
functions: nsk_jvmti_* functions: nsk_jvmti_*

View File

@ -77,7 +77,7 @@ static jvmtiError init_agent_data(jvmtiEnv *jvmti_env, agent_data_t *data) {
data->thread_state = NEW; data->thread_state = NEW;
data->last_debuggee_status = NSK_STATUS_PASSED; data->last_debuggee_status = NSK_STATUS_PASSED;
return NSK_CPP_STUB3(CreateRawMonitor, jvmti_env, "agent_data_monitor", &data->monitor); return jvmti_env->CreateRawMonitor("agent_data_monitor", &data->monitor);
} }
/** Reset agent data to prepare for another run. */ /** Reset agent data to prepare for another run. */
@ -93,14 +93,13 @@ void nsk_jvmti_resetAgentData() {
} }
static jvmtiError free_agent_data(jvmtiEnv *jvmti_env, agent_data_t *data) { static jvmtiError free_agent_data(jvmtiEnv *jvmti_env, agent_data_t *data) {
return NSK_CPP_STUB2(DestroyRawMonitor, jvmti_env, data->monitor); return jvmti_env->DestroyRawMonitor(data->monitor);
} }
/** Create JVMTI environment. */ /** Create JVMTI environment. */
jvmtiEnv* nsk_jvmti_createJVMTIEnv(JavaVM* javaVM, void* reserved) { jvmtiEnv* nsk_jvmti_createJVMTIEnv(JavaVM* javaVM, void* reserved) {
jvm = javaVM; jvm = javaVM;
if (!NSK_VERIFY( if (!NSK_VERIFY(javaVM->GetEnv((void **)&jvmti_env, JVMTI_VERSION_1_1) == JNI_OK)) {
NSK_CPP_STUB3(GetEnv, javaVM, (void **)&jvmti_env, JVMTI_VERSION_1_1) == JNI_OK)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
@ -116,8 +115,7 @@ jvmtiEnv* nsk_jvmti_createJVMTIEnv(JavaVM* javaVM, void* reserved) {
/** Dispose JVMTI environment */ /** Dispose JVMTI environment */
static int nsk_jvmti_disposeJVMTIEnv(jvmtiEnv* jvmti_env) { static int nsk_jvmti_disposeJVMTIEnv(jvmtiEnv* jvmti_env) {
if (jvmti_env != NULL) { if (jvmti_env != NULL) {
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->DisposeEnvironment())) {
NSK_CPP_STUB1(DisposeEnvironment, jvmti_env))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -165,7 +163,7 @@ agentThreadWrapper(jvmtiEnv* jvmti_env, JNIEnv* agentJNI, void* arg) {
/* finalize agent thread */ /* finalize agent thread */
{ {
/* gelete global ref for agent thread */ /* gelete global ref for agent thread */
NSK_CPP_STUB2(DeleteGlobalRef, agentJNI, agentThread); agentJNI->DeleteGlobalRef(agentThread);
agentThread = NULL; agentThread = NULL;
} }
} }
@ -184,35 +182,32 @@ static jthread startAgentThreadWrapper(JNIEnv *jni_env, jvmtiEnv* jvmti_env) {
jobject threadObject = NULL; jobject threadObject = NULL;
jobject threadGlobalRef = NULL; jobject threadGlobalRef = NULL;
if (!NSK_JNI_VERIFY(jni_env, (threadClass = if (!NSK_JNI_VERIFY(jni_env, (threadClass = jni_env->FindClass(THREAD_CLASS_NAME)) != NULL)) {
NSK_CPP_STUB2(FindClass, jni_env, THREAD_CLASS_NAME)) != NULL)) {
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni_env, (threadCtor = if (!NSK_JNI_VERIFY(jni_env, (threadCtor =
NSK_CPP_STUB4(GetMethodID, jni_env, threadClass, THREAD_CTOR_NAME, THREAD_CTOR_SIGNATURE)) != NULL)) jni_env->GetMethodID(threadClass, THREAD_CTOR_NAME, THREAD_CTOR_SIGNATURE)) != NULL))
return NULL; return NULL;
if (!NSK_JNI_VERIFY(jni_env, (threadName = if (!NSK_JNI_VERIFY(jni_env, (threadName = jni_env->NewStringUTF(THREAD_NAME)) != NULL))
NSK_CPP_STUB2(NewStringUTF, jni_env, THREAD_NAME)) != NULL))
return NULL; return NULL;
if (!NSK_JNI_VERIFY(jni_env, (threadObject = if (!NSK_JNI_VERIFY(jni_env, (threadObject =
NSK_CPP_STUB4(NewObject, jni_env, threadClass, threadCtor, threadName)) != NULL)) jni_env->NewObject(threadClass, threadCtor, threadName)) != NULL))
return NULL; return NULL;
if (!NSK_JNI_VERIFY(jni_env, (threadGlobalRef = if (!NSK_JNI_VERIFY(jni_env, (threadGlobalRef =
NSK_CPP_STUB2(NewGlobalRef, jni_env, threadObject)) != NULL)) { jni_env->NewGlobalRef(threadObject)) != NULL)) {
NSK_CPP_STUB2(DeleteLocalRef, jni_env, threadObject); jni_env->DeleteLocalRef(threadObject);
return NULL; return NULL;
} }
agentThread = (jthread)threadGlobalRef; agentThread = (jthread)threadGlobalRef;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB5(RunAgentThread, jvmti_env, agentThread, jvmti_env->RunAgentThread(agentThread, &agentThreadWrapper, agentThreadArg, THREAD_PRIORITY))) {
&agentThreadWrapper, agentThreadArg, THREAD_PRIORITY))) { jni_env->DeleteGlobalRef(threadGlobalRef);
NSK_CPP_STUB2(DeleteGlobalRef, jni_env, threadGlobalRef); jni_env->DeleteLocalRef(threadObject);
NSK_CPP_STUB2(DeleteLocalRef, jni_env, threadObject);
return NULL; return NULL;
} }
return agentThread; return agentThread;
@ -395,8 +390,7 @@ jclass nsk_jvmti_classBySignature(const char signature[]) {
return NULL; return NULL;
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->GetLoadedClasses(&count, &classes))) {
NSK_CPP_STUB3(GetLoadedClasses, jvmti_env, &count, &classes))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
@ -405,8 +399,7 @@ jclass nsk_jvmti_classBySignature(const char signature[]) {
char* sig = NULL; char* sig = NULL;
char* generic = NULL; char* generic = NULL;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(classes[i], &sig, &generic))) {
NSK_CPP_STUB4(GetClassSignature, jvmti_env, classes[i], &sig, &generic))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
break; break;
} }
@ -415,10 +408,8 @@ jclass nsk_jvmti_classBySignature(const char signature[]) {
foundClass = classes[i]; foundClass = classes[i];
} }
if (!(NSK_JVMTI_VERIFY( if (!(NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sig))
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)sig)) && NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic)))) {
&& NSK_JVMTI_VERIFY(
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)generic)))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
break; break;
} }
@ -427,14 +418,13 @@ jclass nsk_jvmti_classBySignature(const char signature[]) {
break; break;
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)classes))) {
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)classes))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni_env, (foundClass = (jclass) if (!NSK_JNI_VERIFY(jni_env, (foundClass = (jclass)
NSK_CPP_STUB2(NewGlobalRef, jni_env, foundClass)) != NULL)) { jni_env->NewGlobalRef(foundClass)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
@ -454,8 +444,7 @@ jthread nsk_jvmti_threadByName(const char name[]) {
return NULL; return NULL;
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->GetAllThreads(&count, &threads))) {
NSK_CPP_STUB3(GetAllThreads, jvmti_env, &count, &threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
@ -463,8 +452,7 @@ jthread nsk_jvmti_threadByName(const char name[]) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
jvmtiThreadInfo info; jvmtiThreadInfo info;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(threads[i], &info))) {
NSK_CPP_STUB3(GetThreadInfo, jvmti_env, threads[i], &info))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
break; break;
} }
@ -475,14 +463,13 @@ jthread nsk_jvmti_threadByName(const char name[]) {
} }
} }
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)threads))) {
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)threads))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni_env, (foundThread = (jthread) if (!NSK_JNI_VERIFY(jni_env, (foundThread = (jthread)
NSK_CPP_STUB2(NewGlobalRef, jni_env, foundThread)) != NULL)) { jni_env->NewGlobalRef(foundThread)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NULL; return NULL;
} }
@ -499,8 +486,7 @@ int nsk_jvmti_addLocationCapabilities() {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_get_line_numbers = 1; caps.can_get_line_numbers = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->AddCapabilities(&caps)))
NSK_CPP_STUB2(AddCapabilities, jvmti_env, &caps)))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -515,8 +501,7 @@ int nsk_jvmti_addBreakpointCapabilities() {
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_generate_breakpoint_events = 1; caps.can_generate_breakpoint_events = 1;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->AddCapabilities(&caps)))
NSK_CPP_STUB2(AddCapabilities, jvmti_env, &caps)))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -529,7 +514,7 @@ jlocation nsk_jvmti_getLineLocation(jclass cls, jmethodID method, int line) {
jlocation location = NSK_JVMTI_INVALID_JLOCATION; jlocation location = NSK_JVMTI_INVALID_JLOCATION;
int i; int i;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetLineNumberTable, jvmti_env, method, &count, &table))) if (!NSK_JVMTI_VERIFY(jvmti_env->GetLineNumberTable(method, &count, &table)))
return NSK_JVMTI_INVALID_JLOCATION; return NSK_JVMTI_INVALID_JLOCATION;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@ -539,7 +524,7 @@ jlocation nsk_jvmti_getLineLocation(jclass cls, jmethodID method, int line) {
} }
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)table))) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)table)))
return NSK_JVMTI_INVALID_JLOCATION; return NSK_JVMTI_INVALID_JLOCATION;
return location; return location;
@ -553,7 +538,7 @@ jlocation nsk_jvmti_setLineBreakpoint(jclass cls, jmethodID method, int line) {
nsk_jvmti_getLineLocation(cls, method, line)) != NSK_JVMTI_INVALID_JLOCATION)) nsk_jvmti_getLineLocation(cls, method, line)) != NSK_JVMTI_INVALID_JLOCATION))
return NSK_JVMTI_INVALID_JLOCATION; return NSK_JVMTI_INVALID_JLOCATION;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetBreakpoint, jvmti_env, method, location))) if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(method, location)))
return NSK_JVMTI_INVALID_JLOCATION; return NSK_JVMTI_INVALID_JLOCATION;
return location; return location;
@ -567,7 +552,7 @@ jlocation nsk_jvmti_clearLineBreakpoint(jclass cls, jmethodID method, int line)
nsk_jvmti_getLineLocation(cls, method, line)) != NSK_JVMTI_INVALID_JLOCATION)) nsk_jvmti_getLineLocation(cls, method, line)) != NSK_JVMTI_INVALID_JLOCATION))
return NSK_JVMTI_INVALID_JLOCATION; return NSK_JVMTI_INVALID_JLOCATION;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(ClearBreakpoint, jvmti_env, method, location))) if (!NSK_JVMTI_VERIFY(jvmti_env->ClearBreakpoint(method, location)))
return NSK_JVMTI_INVALID_JLOCATION; return NSK_JVMTI_INVALID_JLOCATION;
return location; return location;
@ -580,9 +565,7 @@ int nsk_jvmti_enableEvents(jvmtiEventMode enable, int size, jvmtiEvent list[], j
int i; int i;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(enable, list[i], thread))) {
NSK_CPP_STUB4(SetEventNotificationMode, jvmti_env, enable,
list[i], thread))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return NSK_FALSE; return NSK_FALSE;
} }
@ -624,7 +607,7 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env,
char *name = NULL; char *name = NULL;
char *sig = NULL; char *sig = NULL;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPhase, jvmti_env, &phase))) { if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
@ -632,15 +615,12 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env,
if (phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE) if (phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE)
return; return;
if (NSK_JVMTI_VERIFY( if (NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(mid, &name, &sig, NULL))) {
NSK_CPP_STUB5(GetMethodName, jvmti_env, mid, &name, &sig, NULL))) {
if (strcmp(name, BIND_METHOD_NAME) == 0 && if (strcmp(name, BIND_METHOD_NAME) == 0 &&
strcmp(sig, BIND_METHOD_SIGNATURE) == 0) { strcmp(sig, BIND_METHOD_SIGNATURE) == 0) {
if (NSK_JVMTI_VERIFY( if (NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(mid, &cls))
NSK_CPP_STUB3(GetMethodDeclaringClass, jvmti_env, mid, &cls)) && NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(cls, &class_sig, NULL))
&& NSK_JVMTI_VERIFY(
NSK_CPP_STUB4(GetClassSignature, jvmti_env, cls, &class_sig, NULL))
&& strcmp(class_sig, BIND_CLASS_NAME) == 0 && strcmp(class_sig, BIND_CLASS_NAME) == 0
&& address != (void*)Java_nsk_share_jvmti_DebugeeClass_checkStatus) { && address != (void*)Java_nsk_share_jvmti_DebugeeClass_checkStatus) {
checkStatus_func = (checkStatus_type)address; checkStatus_func = (checkStatus_type)address;
@ -650,13 +630,13 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env,
} }
if (name != NULL) if (name != NULL)
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name); jvmti_env->Deallocate((unsigned char*)name);
if (sig != NULL) if (sig != NULL)
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)sig); jvmti_env->Deallocate((unsigned char*)sig);
if (class_sig != NULL) if (class_sig != NULL)
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)class_sig); jvmti_env->Deallocate((unsigned char*)class_sig);
} }
/** /**
@ -681,19 +661,16 @@ int nsk_jvmti_init_MA(jvmtiEventCallbacks* callbacks) {
jvmtiCapabilities caps; jvmtiCapabilities caps;
memset(&caps, 0, sizeof(caps)); memset(&caps, 0, sizeof(caps));
caps.can_generate_native_method_bind_events = 1; caps.can_generate_native_method_bind_events = 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti_env, &caps))) if (!NSK_JVMTI_VERIFY(jvmti_env->AddCapabilities(&caps)))
return NSK_FALSE; return NSK_FALSE;
} }
callbacks->NativeMethodBind = nativeMethodBind; callbacks->NativeMethodBind = nativeMethodBind;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventCallbacks(callbacks, sizeof(jvmtiEventCallbacks))))
NSK_CPP_STUB3(SetEventCallbacks, jvmti_env, callbacks,
sizeof(jvmtiEventCallbacks))))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(
NSK_CPP_STUB4(SetEventNotificationMode, jvmti_env, JVMTI_ENABLE, jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL)))
JVMTI_EVENT_NATIVE_METHOD_BIND, NULL)))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -731,7 +708,7 @@ void nsk_jvmti_showPossessedCapabilities(jvmtiEnv *jvmti_env) {
jvmtiCapabilities caps; jvmtiCapabilities caps;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti_env, &caps))) { if (!NSK_JVMTI_VERIFY(jvmti_env->GetCapabilities(&caps))) {
return; return;
} }

View File

@ -87,7 +87,7 @@ Options* nsk_jvmti_aod_getMultiagentsOptions(jvmtiEnv *jvmti) {
*/ */
void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem) { void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, jvmti, mem))) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate(mem))) {
NSK_COMPLAIN0("Deallocate failed\n"); NSK_COMPLAIN0("Deallocate failed\n");
/* /*
@ -101,7 +101,7 @@ void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem) {
int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuffer[]) { int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuffer[]) {
char* className; char* className;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti, klass, &className, NULL))) { if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &className, NULL))) {
NSK_COMPLAIN0("Failed to get class name\n"); NSK_COMPLAIN0("Failed to get class name\n");
classNameBuffer[0] = '\0'; classNameBuffer[0] = '\0';
return NSK_FALSE; return NSK_FALSE;
@ -116,7 +116,7 @@ int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuff
int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNameBuffer[]) { int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNameBuffer[]) {
jvmtiThreadInfo info; jvmtiThreadInfo info;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info))){ if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))){
NSK_COMPLAIN0("Failed to get thread info\n"); NSK_COMPLAIN0("Failed to get thread info\n");
threadNameBuffer[0] = '\0'; threadNameBuffer[0] = '\0';
return NSK_FALSE; return NSK_FALSE;
@ -161,25 +161,23 @@ jthread nsk_jvmti_aod_createThread(JNIEnv *jni) {
jmethodID threadConstructor; jmethodID threadConstructor;
jthread thread; jthread thread;
if (!NSK_JNI_VERIFY(jni, if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL )) {
(klass = NSK_CPP_STUB2(FindClass, jni, "java/lang/Thread")) != NULL )) {
NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n");
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni, if (!NSK_JNI_VERIFY(jni,
(threadConstructor = NSK_CPP_STUB4(GetMethodID, jni, klass, "<init>", "()V") ) != NULL )) { (threadConstructor = jni->GetMethodID(klass, "<init>", "()V") ) != NULL )) {
NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n");
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY (jni, if (!NSK_JNI_VERIFY (jni,
(thread = NSK_CPP_STUB4(NewObject, jni, klass, threadConstructor, NULL)) != NULL ) ) { (thread = jni->NewObject(klass, threadConstructor, NULL)) != NULL ) ) {
NSK_COMPLAIN0("Failed to create Thread object\n"); NSK_COMPLAIN0("Failed to create Thread object\n");
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni, (thread = if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) {
NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL)) {
NSK_COMPLAIN0("Failed to create global reference\n"); NSK_COMPLAIN0("Failed to create global reference\n");
return NULL; return NULL;
} }
@ -193,29 +191,26 @@ jthread nsk_jvmti_aod_createThreadWithName(JNIEnv *jni, const char* threadName)
jthread thread; jthread thread;
jstring threadNameString; jstring threadNameString;
if (!NSK_JNI_VERIFY(jni, (threadNameString = if (!NSK_JNI_VERIFY(jni, (threadNameString = jni->NewStringUTF(threadName)) != NULL))
NSK_CPP_STUB2(NewStringUTF, jni, threadName)) != NULL))
return NULL; return NULL;
if (!NSK_JNI_VERIFY(jni, if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL )) {
(klass = NSK_CPP_STUB2(FindClass, jni, "java/lang/Thread")) != NULL )) {
NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n");
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni, if (!NSK_JNI_VERIFY(jni,
(threadConstructor = NSK_CPP_STUB4(GetMethodID, jni, klass, "<init>", "(Ljava/lang/String;)V") ) != NULL )) { (threadConstructor = jni->GetMethodID(klass, "<init>", "(Ljava/lang/String;)V") ) != NULL )) {
NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n");
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni, if (!NSK_JNI_VERIFY(jni,
(thread = NSK_CPP_STUB4(NewObject, jni, klass, threadConstructor, threadNameString)) != NULL ) ) { (thread = jni->NewObject(klass, threadConstructor, threadNameString)) != NULL ) ) {
NSK_COMPLAIN0("Failed to create Thread object\n"); NSK_COMPLAIN0("Failed to create Thread object\n");
return NULL; return NULL;
} }
if (!NSK_JNI_VERIFY(jni, (thread = if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) {
NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL)) {
NSK_COMPLAIN0("Failed to create global reference\n"); NSK_COMPLAIN0("Failed to create global reference\n");
return NULL; return NULL;
} }

View File

@ -68,8 +68,8 @@ int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNam
// events enabling/disabling // events enabling/disabling
#define nsk_jvmti_aod_enableEvent(X,Y) NSK_JVMTI_VERIFY( NSK_CPP_STUB4(SetEventNotificationMode, X, JVMTI_ENABLE, Y, NULL)) #define nsk_jvmti_aod_enableEvent(X,Y) NSK_JVMTI_VERIFY(X->SetEventNotificationMode(JVMTI_ENABLE, Y, NULL))
#define nsk_jvmti_aod_disableEvent(X,Y) NSK_JVMTI_VERIFY( NSK_CPP_STUB4(SetEventNotificationMode, X, JVMTI_DISABLE, Y, NULL)) #define nsk_jvmti_aod_disableEvent(X,Y) NSK_JVMTI_VERIFY(X->SetEventNotificationMode(JVMTI_DISABLE, Y, NULL))
int nsk_jvmti_aod_enableEvents(jvmtiEnv* jvmti, jvmtiEvent events[], int eventsNumber); int nsk_jvmti_aod_enableEvents(jvmtiEnv* jvmti, jvmtiEvent events[], int eventsNumber);
int nsk_jvmti_aod_disableEvents(jvmtiEnv* jvmti, jvmtiEvent events[], int eventsNumber); int nsk_jvmti_aod_disableEvents(jvmtiEnv* jvmti, jvmtiEvent events[], int eventsNumber);

View File

@ -78,8 +78,7 @@ static int redefine(jvmtiEnv* jvmti, jvmtiClassDefinition* class_def) {
NSK_DISPLAY1("Redefining %d classes...\n", classCount); NSK_DISPLAY1("Redefining %d classes...\n", classCount);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(RedefineClasses, if (!NSK_JVMTI_VERIFY(jvmti->RedefineClasses(classCount, class_def)))
jvmti, classCount, class_def)))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -103,14 +102,12 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
(strncmp(name, package_name, package_name_length) == 0)) { (strncmp(name, package_name, package_name_length) == 0)) {
NSK_DISPLAY1("ClassFileLoadHook: %s\n", name); NSK_DISPLAY1("ClassFileLoadHook: %s\n", name);
name_len = (jint) strlen(name) + 1; name_len = (jint) strlen(name) + 1;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(Allocate, jvmti_env, if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(name_len, (unsigned char**) &names[classCount]))) {
name_len, (unsigned char**) &names[classCount]))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
memcpy(names[classCount], name, name_len); memcpy(names[classCount], name, name_len);
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(Allocate, if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(class_data_len, (unsigned char**)
jvmti_env, class_data_len, (unsigned char**)
&old_class_def[classCount].class_bytes))) { &old_class_def[classCount].class_bytes))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
@ -133,17 +130,16 @@ CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method,
CompiledMethodLoadEventsCount++; CompiledMethodLoadEventsCount++;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
jvmti_env, method, &name, &signature, NULL))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n", NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
name, signature, code_addr); name, signature, code_addr);
if (name != NULL) if (name != NULL)
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name); jvmti_env->Deallocate((unsigned char*)name);
if (signature != NULL) if (signature != NULL)
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature); jvmti_env->Deallocate((unsigned char*)signature);
} }
static int SingleStepEventsCount = 0; static int SingleStepEventsCount = 0;
@ -168,20 +164,18 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
jclass klass = NULL; jclass klass = NULL;
char *signature = NULL; char *signature = NULL;
if (!NSK_JNI_VERIFY(jni_env, (klass = if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {
NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env, if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {
klass, &signature, NULL))) {
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return; return;
} }
NSK_DISPLAY2("Exception event %d: %s\n", NSK_DISPLAY2("Exception event %d: %s\n",
ExceptionEventsCount, signature); ExceptionEventsCount, signature);
if (signature != NULL) if (signature != NULL)
NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature); jvmti_env->Deallocate((unsigned char*)signature);
} }
if (!redefine(jvmti_env, (bci_mode != BCI_MODE_EMCP && newFlag) ? if (!redefine(jvmti_env, (bci_mode != BCI_MODE_EMCP && newFlag) ?
@ -190,15 +184,14 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
NSK_DISPLAY1("SingleStepEventsCount: %d\n", SingleStepEventsCount); NSK_DISPLAY1("SingleStepEventsCount: %d\n", SingleStepEventsCount);
if (vm_mode == VM_MODE_MIXED) { if (vm_mode == VM_MODE_MIXED) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(
jvmti_env, ((newFlag) ? JVMTI_DISABLE : JVMTI_ENABLE), ((newFlag) ? JVMTI_DISABLE : JVMTI_ENABLE),
JVMTI_EVENT_SINGLE_STEP, NULL))) JVMTI_EVENT_SINGLE_STEP, NULL)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
if (nsk_getVerboseMode() && bci_mode != BCI_MODE_EMCP) { if (nsk_getVerboseMode() && bci_mode != BCI_MODE_EMCP) {
jint profileCount = NSK_CPP_STUB3(GetStaticIntField, jni_env, jint profileCount = jni_env->GetStaticIntField(profile_klass, count_field);
profile_klass, count_field);
NSK_DISPLAY1("profileCount: %d\n", profileCount); NSK_DISPLAY1("profileCount: %d\n", profileCount);
} }
@ -215,50 +208,43 @@ static jrawMonitorID waitLock = NULL;
static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
int i; int i;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)))
jvmti, JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)))
return NSK_FALSE; return NSK_FALSE;
if (vm_mode != VM_MODE_COMPILED) { if (vm_mode != VM_MODE_COMPILED) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
return NSK_FALSE; return NSK_FALSE;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(CreateRawMonitor, if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("waitLock", &waitLock)))
jvmti, "waitLock", &waitLock)))
return NSK_FALSE; return NSK_FALSE;
for (i = 0; i < classCount; i++) { for (i = 0; i < classCount; i++) {
NSK_DISPLAY1("Find class: %s\n", names[i]); NSK_DISPLAY1("Find class: %s\n", names[i]);
if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = jni->FindClass(names[i])) != NULL))
NSK_CPP_STUB2(FindClass, jni, names[i])) != NULL))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = (jclass) if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = (jclass)
NSK_CPP_STUB2(NewGlobalRef, jni, jni->NewGlobalRef(old_class_def[i].klass)) != NULL))
old_class_def[i].klass)) != NULL))
return NSK_FALSE; return NSK_FALSE;
} }
if (bci_mode != BCI_MODE_EMCP) { if (bci_mode != BCI_MODE_EMCP) {
NSK_DISPLAY1("Find class: %s\n", PROFILE_CLASS_NAME); NSK_DISPLAY1("Find class: %s\n", PROFILE_CLASS_NAME);
if (!NSK_JNI_VERIFY(jni, (profile_klass = if (!NSK_JNI_VERIFY(jni, (profile_klass = jni->FindClass(PROFILE_CLASS_NAME)) != NULL))
NSK_CPP_STUB2(FindClass, jni, PROFILE_CLASS_NAME)) != NULL))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JNI_VERIFY(jni, (profile_klass = (jclass) if (!NSK_JNI_VERIFY(jni, (profile_klass = (jclass)
NSK_CPP_STUB2(NewGlobalRef, jni, profile_klass)) != NULL)) jni->NewGlobalRef(profile_klass)) != NULL))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JNI_VERIFY(jni, (count_field = if (!NSK_JNI_VERIFY(jni, (count_field =
NSK_CPP_STUB4(GetStaticFieldID, jni, profile_klass, jni->GetStaticFieldID(profile_klass,
(bci_mode == BCI_MODE_CALL) ? "callCount" : "allocCount", (bci_mode == BCI_MODE_CALL) ? "callCount" : "allocCount",
"I")) != NULL)) "I")) != NULL))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(Allocate, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->Allocate(classCount * sizeof(jvmtiClassDefinition),
classCount * sizeof(jvmtiClassDefinition),
(unsigned char**) &new_class_def))) (unsigned char**) &new_class_def)))
return NSK_FALSE; return NSK_FALSE;
@ -273,8 +259,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
} }
if (sync_freq) { if (sync_freq) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
return NSK_FALSE; return NSK_FALSE;
} }
@ -285,14 +270,13 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
static int wait_for(jvmtiEnv* jvmti, jlong millis) { static int wait_for(jvmtiEnv* jvmti, jlong millis) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, waitLock))) if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(waitLock)))
return NSK_FALSE; return NSK_FALSE;
if (!NSK_JVMTI_VERIFY( if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorWait(waitLock, millis)))
NSK_CPP_STUB3(RawMonitorWait, jvmti, waitLock, millis)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, waitLock))) if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(waitLock)))
return NSK_FALSE; return NSK_FALSE;
return NSK_TRUE; return NSK_TRUE;
@ -320,8 +304,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
return; return;
if (sync_freq) { if (sync_freq) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
jvmti, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} else { } else {
@ -334,15 +317,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
NSK_DISPLAY1("SingleStepEventsCount: %d\n", SingleStepEventsCount); NSK_DISPLAY1("SingleStepEventsCount: %d\n", SingleStepEventsCount);
if (vm_mode == VM_MODE_MIXED) { if (vm_mode == VM_MODE_MIXED) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(
jvmti, (((i % 2)==0) ? JVMTI_DISABLE : JVMTI_ENABLE), (((i % 2)==0) ? JVMTI_DISABLE : JVMTI_ENABLE),
JVMTI_EVENT_SINGLE_STEP, NULL))) JVMTI_EVENT_SINGLE_STEP, NULL)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
if (nsk_getVerboseMode() && bci_mode != BCI_MODE_EMCP) { if (nsk_getVerboseMode() && bci_mode != BCI_MODE_EMCP) {
jint profileCount = NSK_CPP_STUB3(GetStaticIntField, jni, jint profileCount = jni->GetStaticIntField(profile_klass, count_field);
profile_klass, count_field);
NSK_DISPLAY1("profileCount: %d\n", profileCount); NSK_DISPLAY1("profileCount: %d\n", profileCount);
} }
@ -352,8 +334,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
} }
if (vm_mode != VM_MODE_COMPILED) { if (vm_mode != VM_MODE_COMPILED) {
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
jvmti, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
} }
@ -446,12 +427,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_ERR; return JNI_ERR;
/* allocate tables for classes */ /* allocate tables for classes */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(Allocate, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->Allocate(max_classes * sizeof(char*), (unsigned char**) &names)))
max_classes * sizeof(char*), (unsigned char**) &names)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(Allocate, jvmti, if (!NSK_JVMTI_VERIFY(jvmti->Allocate(max_classes * sizeof(jvmtiClassDefinition),
max_classes * sizeof(jvmtiClassDefinition),
(unsigned char**) &old_class_def))) (unsigned char**) &old_class_def)))
return JNI_ERR; return JNI_ERR;
@ -465,7 +444,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (sync_freq) { if (sync_freq) {
caps.can_generate_exception_events = 1; caps.can_generate_exception_events = 1;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
return JNI_ERR; return JNI_ERR;
if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
@ -481,16 +460,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (sync_freq) { if (sync_freq) {
callbacks.Exception = &Exception; callbacks.Exception = &Exception;
} }
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
jvmti, &callbacks, sizeof(callbacks))))
return JNI_ERR; return JNI_ERR;
/* enable events */ /* enable events */
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)))
return JNI_ERR; return JNI_ERR;
if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)))
jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)))
return JNI_ERR; return JNI_ERR;
return JNI_OK; return JNI_OK;

View File

@ -115,12 +115,12 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
jvmtiEnv * jvmti = nsk_jvmti_getAgentJVMTIEnv(); jvmtiEnv * jvmti = nsk_jvmti_getAgentJVMTIEnv();
jint hashCode; jint hashCode;
if ( ! NSK_VERIFY(NSK_CPP_STUB3(SetTag, jvmti, o, tag) == JVMTI_ERROR_NONE) ) { if ( ! NSK_VERIFY(jvmti->SetTag(o, tag) == JVMTI_ERROR_NONE) ) {
NSK_COMPLAIN2("Can't set tag %li for object %lx\n", tag, o); NSK_COMPLAIN2("Can't set tag %li for object %lx\n", tag, o);
return JNI_FALSE; return JNI_FALSE;
} }
if ( ! NSK_VERIFY(NSK_CPP_STUB3(GetObjectHashCode, jvmti, o, &hashCode) == JVMTI_ERROR_NONE) ) { if ( ! NSK_VERIFY(jvmti->GetObjectHashCode(o, &hashCode) == JVMTI_ERROR_NONE) ) {
NSK_COMPLAIN1("Can't get hash object %lx\n", o); NSK_COMPLAIN1("Can't get hash object %lx\n", o);
return JNI_FALSE; return JNI_FALSE;
} }
@ -131,7 +131,7 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
jboolean fCopy; jboolean fCopy;
const char * s; const char * s;
if ( ! NSK_VERIFY((s = NSK_CPP_STUB3(GetStringUTFChars, jni, sInfo, &fCopy)) != NULL) ) { if ( ! NSK_VERIFY((s = jni->GetStringUTFChars(sInfo, &fCopy)) != NULL) ) {
NSK_COMPLAIN1("Can't get string at %#p\n", sInfo); NSK_COMPLAIN1("Can't get string at %#p\n", sInfo);
return JNI_FALSE; return JNI_FALSE;
} }
@ -143,7 +143,7 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
g_szTagInfo[tag] = strdup(s); g_szTagInfo[tag] = strdup(s);
NSK_CPP_STUB3(ReleaseStringUTFChars, jni, sInfo, s); jni->ReleaseStringUTFChars(sInfo, s);
NSK_DISPLAY1(" // %s", g_szTagInfo[tag]); NSK_DISPLAY1(" // %s", g_szTagInfo[tag]);
@ -160,7 +160,7 @@ JNIEXPORT jlong JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects_ge
jlong tag; jlong tag;
jvmtiError r; jvmtiError r;
if ( ! NSK_VERIFY((r = NSK_CPP_STUB3(GetTag, jvmti, o, &tag)) == JVMTI_ERROR_NONE) ) { if ( ! NSK_VERIFY((r = jvmti->GetTag(o, &tag)) == JVMTI_ERROR_NONE) ) {
NSK_COMPLAIN2("Can't GetTag for object %lx. Return code: %i\n", o, r); NSK_COMPLAIN2("Can't GetTag for object %lx. Return code: %i\n", o, r);
return -1; return -1;
} }
@ -224,14 +224,14 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
jlong tagFrom, tagTo; jlong tagFrom, tagTo;
RefToVerify * pRefRec; RefToVerify * pRefRec;
if ( ! NSK_VERIFY((r = NSK_CPP_STUB3(GetTag, jvmti, from, &tagFrom)) == JVMTI_ERROR_NONE) ) { if ( ! NSK_VERIFY((r = jvmti->GetTag(from, &tagFrom)) == JVMTI_ERROR_NONE) ) {
NSK_COMPLAIN2("TEST_BUG: Can't GetTag for object %lx. Return code: %i\n", from, r); NSK_COMPLAIN2("TEST_BUG: Can't GetTag for object %lx. Return code: %i\n", from, r);
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return JNI_FALSE; return JNI_FALSE;
} }
if ( ! NSK_VERIFY((r = NSK_CPP_STUB3(GetTag, jvmti, to, &tagTo)) == JVMTI_ERROR_NONE) ) { if ( ! NSK_VERIFY((r = jvmti->GetTag(to, &tagTo)) == JVMTI_ERROR_NONE) ) {
NSK_COMPLAIN2("TEST_BUG: Can't GetTag for object %lx. Return code: %i\n", to, r); NSK_COMPLAIN2("TEST_BUG: Can't GetTag for object %lx. Return code: %i\n", to, r);
nsk_jvmti_setFailStatus(); nsk_jvmti_setFailStatus();
return JNI_FALSE; return JNI_FALSE;

View File

@ -452,8 +452,7 @@ JNIEXPORT jstring JNICALL
Java_nsk_share_jvmti_ArgumentHandler_getAgentOptionsString(JNIEnv *jni, jobject obj) { Java_nsk_share_jvmti_ArgumentHandler_getAgentOptionsString(JNIEnv *jni, jobject obj) {
jstring str_obj = NULL; jstring str_obj = NULL;
if (!NSK_JNI_VERIFY(jni, (str_obj = if (!NSK_JNI_VERIFY(jni, (str_obj = jni->NewStringUTF(context.options.string)) != NULL)) {
NSK_CPP_STUB2(NewStringUTF, jni, context.options.string)) != NULL)) {
return NULL; return NULL;
} }
return str_obj; return str_obj;
@ -637,7 +636,7 @@ int isThreadExpected(jvmtiEnv *jvmti, jthread thread) {
} }
jint createRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor) { jint createRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor) {
jvmtiError error = NSK_CPP_STUB3(CreateRawMonitor, env, name, monitor); jvmtiError error = env->CreateRawMonitor(name, monitor);
if (!NSK_JVMTI_VERIFY(error)) { if (!NSK_JVMTI_VERIFY(error)) {
return JNI_ERR; return JNI_ERR;
} }
@ -651,27 +650,27 @@ void exitOnError(jvmtiError error) {
} }
void rawMonitorEnter(jvmtiEnv *env, jrawMonitorID monitor) { void rawMonitorEnter(jvmtiEnv *env, jrawMonitorID monitor) {
jvmtiError error = NSK_CPP_STUB2(RawMonitorEnter, env, monitor); jvmtiError error = env->RawMonitorEnter(monitor);
exitOnError(error); exitOnError(error);
} }
void rawMonitorExit(jvmtiEnv *env, jrawMonitorID monitor) { void rawMonitorExit(jvmtiEnv *env, jrawMonitorID monitor) {
jvmtiError error = NSK_CPP_STUB2(RawMonitorExit, env, monitor); jvmtiError error = env->RawMonitorExit(monitor);
exitOnError(error); exitOnError(error);
} }
void rawMonitorNotify(jvmtiEnv *env, jrawMonitorID monitor) { void rawMonitorNotify(jvmtiEnv *env, jrawMonitorID monitor) {
jvmtiError error = NSK_CPP_STUB2(RawMonitorNotify, env, monitor); jvmtiError error = env->RawMonitorNotify(monitor);
exitOnError(error); exitOnError(error);
} }
void rawMonitorWait(jvmtiEnv *env, jrawMonitorID monitor, jlong millis) { void rawMonitorWait(jvmtiEnv *env, jrawMonitorID monitor, jlong millis) {
jvmtiError error = NSK_CPP_STUB3(RawMonitorWait, env, monitor, millis); jvmtiError error = env->RawMonitorWait(monitor, millis);
exitOnError(error); exitOnError(error);
} }
void getPhase(jvmtiEnv *env, jvmtiPhase *phase) { void getPhase(jvmtiEnv *env, jvmtiPhase *phase) {
jvmtiError error = NSK_CPP_STUB2(GetPhase, env, phase); jvmtiError error = env->GetPhase(phase);
exitOnError(error); exitOnError(error);
} }

View File

@ -57,10 +57,6 @@ nsk_tools.h
Provides functions and macroses for the most usefull actions: Provides functions and macroses for the most usefull actions:
- access native JVM environment in a compiler independent manner
NSK_CPP_STUBn(function, env, arg1, ..., argn)
- print error message with arguments - print error message with arguments
NSK_COMPLAINn(format, arg1, ..., argn) NSK_COMPLAINn(format, arg1, ..., argn)
@ -89,7 +85,7 @@ Provides functions and macroses for the most usefull actions:
- miscelaneous functions for printing messages - miscelaneous functions for printing messages
(hidden by above mentioned macroses) (hidden by above mentioned macroses)
Typical example of using macroses NSK_CPP_STUB and NSK_VERIFY Typical example of using the NSK_VERIFY macro
for accesing JVM native environment: for accesing JVM native environment:
// jvm->GetEnv(jvm, &env, version) // jvm->GetEnv(jvm, &env, version)

View File

@ -38,25 +38,6 @@
#endif // _LP64 && __APPLE__ #endif // _LP64 && __APPLE__
/**
* Use examples:
*
* jfieldID id = NSK_CPP_STUB3(jni,GetFieldID,clazz,name,sig);
*
* jvmtiError code = NSK_CPP_STUB0(jvmti,DisposeEnvironment);
*
*/
#define NSK_CPP_STUB1(Func,env) env->Func()
#define NSK_CPP_STUB2(Func,env,a) env->Func(a)
#define NSK_CPP_STUB3(Func,env,a,b) env->Func(a,b)
#define NSK_CPP_STUB4(Func,env,a,b,c) env->Func(a,b,c)
#define NSK_CPP_STUB5(Func,env,a,b,c,d) env->Func(a,b,c,d)
#define NSK_CPP_STUB6(Func,env,a,b,c,d,e) env->Func(a,b,c,d,e)
#define NSK_CPP_STUB7(Func,env,a,b,c,d,e,f) env->Func(a,b,c,d,e,f)
#define NSK_CPP_STUB8(Func,env,a,b,c,d,e,f,g) env->Func(a,b,c,d,e,f,g)
#define NSK_CPP_STUB9(Func,env,a,b,c,d,e,f,g,h) env->Func(a,b,c,d,e,f,g,h)
/*************************************************************/ /*************************************************************/
/** /**

View File

@ -88,22 +88,22 @@ static void popFrameLogic(jvmtiEnv * jvmti_env, jthread thread) {
if ( tls->countOfFramesToPop <= 0 ) { if ( tls->countOfFramesToPop <= 0 ) {
NSK_DISPLAY0("Disabling single step\n"); NSK_DISPLAY0("Disabling single step\n");
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)) ) if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)) )
gIsErrorOccured = JNI_TRUE; gIsErrorOccured = JNI_TRUE;
} else { } else {
NSK_DISPLAY0("Enabling single step\n"); NSK_DISPLAY0("Enabling single step\n");
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)) ) if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)) )
gIsErrorOccured = JNI_TRUE; gIsErrorOccured = JNI_TRUE;
if ( tls->countOfFramesToPop == 1 ) { if ( tls->countOfFramesToPop == 1 ) {
NSK_DISPLAY0("Popping a frame\n"); NSK_DISPLAY0("Popping a frame\n");
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB2(PopFrame, jvmti_env, thread)) ) if ( ! NSK_JVMTI_VERIFY(jvmti_env->PopFrame(thread)) )
gIsErrorOccured = JNI_TRUE; gIsErrorOccured = JNI_TRUE;
} else { } else {
NSK_DISPLAY0("Forcing early return\n"); NSK_DISPLAY0("Forcing early return\n");
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB2(ForceEarlyReturnVoid, jvmti_env, thread)) ) if ( ! NSK_JVMTI_VERIFY(jvmti_env->ForceEarlyReturnVoid(thread)) )
gIsErrorOccured = JNI_TRUE; gIsErrorOccured = JNI_TRUE;
} }
@ -141,7 +141,7 @@ MethodEntry(jvmtiEnv *jvmti_env,
NSK_DISPLAY1("Redefining class %s\n", gszRedefinedClassFileName); NSK_DISPLAY1("Redefining class %s\n", gszRedefinedClassFileName);
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetMethodDeclaringClass, jvmti_env, method, &clazz)) ) if ( ! NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &clazz)) )
return; return;
if ( ! NSK_VERIFY(nsk_jvmti_redefineClass(jvmti_env, clazz, gszRedefinedClassFileName)) ) { if ( ! NSK_VERIFY(nsk_jvmti_redefineClass(jvmti_env, clazz, gszRedefinedClassFileName)) ) {
@ -200,20 +200,20 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
caps.can_force_early_return = 1; caps.can_force_early_return = 1;
caps.can_redefine_classes = 1; caps.can_redefine_classes = 1;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, gJvmtiEnv, &caps)) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->AddCapabilities(&caps)) )
return JNI_ERR; return JNI_ERR;
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
callbacks.MethodEntry = &MethodEntry; callbacks.MethodEntry = &MethodEntry;
callbacks.SingleStep = &SingleStep; callbacks.SingleStep = &SingleStep;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, gJvmtiEnv, &callbacks, sizeof(callbacks))) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks))) )
return JNI_ERR; return JNI_ERR;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, gJvmtiEnv, JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL) ) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL) ) )
return JNI_ERR; return JNI_ERR;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, gJvmtiEnv, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL) ) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL) ) )
return JNI_ERR; return JNI_ERR;
return JNI_OK; return JNI_OK;

View File

@ -89,7 +89,7 @@ MethodEntry(jvmtiEnv *jvmti_env,
gIsMethodEntryWorking = JNI_TRUE; gIsMethodEntryWorking = JNI_TRUE;
if ( ! gIsBreakpointSet ) if ( ! gIsBreakpointSet )
NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
} }
} }
@ -116,21 +116,21 @@ SingleStep(jvmtiEnv *jvmti_env,
free(locStr); free(locStr);
} }
NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, gJvmtiEnv, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
if ( ! gIsDebuggerCompatible ) { if ( ! gIsDebuggerCompatible ) {
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetBreakpoint, jvmti_env, method, location)) ) if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(method, location)) )
return; return;
NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, gJvmtiEnv, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)); NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL));
gIsBreakpointSet = JNI_TRUE; gIsBreakpointSet = JNI_TRUE;
NSK_DISPLAY0("Pop a frame\n"); NSK_DISPLAY0("Pop a frame\n");
NSK_JVMTI_VERIFY(NSK_CPP_STUB2(PopFrame, gJvmtiEnv, thread)); NSK_JVMTI_VERIFY(gJvmtiEnv->PopFrame(thread));
} else { } else {
if ( gIsFirstCall ) { if ( gIsFirstCall ) {
NSK_DISPLAY0("Pop a frame\n"); NSK_DISPLAY0("Pop a frame\n");
NSK_JVMTI_VERIFY(NSK_CPP_STUB2(PopFrame, gJvmtiEnv, thread)); NSK_JVMTI_VERIFY(gJvmtiEnv->PopFrame(thread));
gIsFirstCall = JNI_FALSE; gIsFirstCall = JNI_FALSE;
} else { } else {
gIsFirstCall = JNI_TRUE; gIsFirstCall = JNI_TRUE;
@ -158,12 +158,12 @@ Breakpoint(jvmtiEnv *jvmti_env,
free(locStr); free(locStr);
} }
NSK_JVMTI_VERIFY(NSK_CPP_STUB3(ClearBreakpoint, jvmti_env, method, location)); NSK_JVMTI_VERIFY(jvmti_env->ClearBreakpoint(method, location));
NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, gJvmtiEnv, JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, NULL)); NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, NULL));
gIsBreakpointSet = JNI_FALSE; gIsBreakpointSet = JNI_FALSE;
NSK_DISPLAY0("Forcing early return.\n"); NSK_DISPLAY0("Forcing early return.\n");
NSK_JVMTI_VERIFY(NSK_CPP_STUB3(ForceEarlyReturnInt, jvmti_env, thread, 0)); NSK_JVMTI_VERIFY(jvmti_env->ForceEarlyReturnInt(thread, 0));
} }
jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) { jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
@ -187,7 +187,7 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
caps.can_pop_frame = 1; caps.can_pop_frame = 1;
caps.can_force_early_return = 1; caps.can_force_early_return = 1;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, gJvmtiEnv, &caps)) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->AddCapabilities(&caps)) )
return JNI_ERR; return JNI_ERR;
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
@ -195,10 +195,10 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
callbacks.SingleStep = &SingleStep; callbacks.SingleStep = &SingleStep;
callbacks.Breakpoint = &Breakpoint; callbacks.Breakpoint = &Breakpoint;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks, gJvmtiEnv, &callbacks, sizeof(callbacks))) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks))) )
return JNI_ERR; return JNI_ERR;
if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode, gJvmtiEnv, JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL) ) ) if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL) ) )
return JNI_ERR; return JNI_ERR;
return JNI_OK; return JNI_OK;