< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp

Print this page
rev 52100 : 8212082: Remove the NSK_CPP_STUB macros for remaining vmTestbase/jvmti/[sS]*
Summary:
Reviewed-by:


  34 
  35 /* ========================================================================== */
  36 
  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  41 static int MethodEntryEventsCount = 0;
  42 
  43 /* ========================================================================== */
  44 
  45 /** callback functions **/
  46 
  47 static void JNICALL
  48 MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
  49         jthread thread, jmethodID method) {
  50     char *name = NULL;
  51     char *signature = NULL;
  52 
  53     MethodEntryEventsCount++;
  54     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
  55             jvmti_env, method, &name, &signature, NULL))) {
  56         nsk_jvmti_setFailStatus();
  57         return;
  58     }
  59     NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature);
  60     if (name != NULL)
  61         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
  62     if (signature != NULL)
  63         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
  64 }
  65 
  66 /* ========================================================================== */
  67 
  68 /** Agent algorithm. */
  69 static void JNICALL
  70 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  71 
  72     if (!nsk_jvmti_waitForSync(timeout))
  73         return;
  74 
  75     /* resume debugee and wait for sync */
  76     if (!nsk_jvmti_resumeSync())
  77         return;
  78     if (!nsk_jvmti_waitForSync(timeout))
  79         return;
  80 
  81     NSK_DISPLAY1("MethodEntry events received: %d\n",
  82         MethodEntryEventsCount);
  83     if (!NSK_VERIFY(MethodEntryEventsCount == 0))


 105     jvmtiEnv* jvmti = NULL;
 106     jvmtiCapabilities caps;
 107     jvmtiEventCallbacks callbacks;
 108 
 109     NSK_DISPLAY0("Agent_OnLoad\n");
 110 
 111     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 112         return JNI_ERR;
 113 
 114     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 115 
 116     if (!NSK_VERIFY((jvmti =
 117             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 118         return JNI_ERR;
 119 
 120     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 121         return JNI_ERR;
 122 
 123     memset(&caps, 0, sizeof(caps));
 124     caps.can_generate_method_entry_events = 1;
 125     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
 126         return JNI_ERR;
 127     }
 128 
 129     memset(&callbacks, 0, sizeof(callbacks));
 130     callbacks.MethodEntry = &MethodEntry;
 131     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 132         return JNI_ERR;
 133 
 134     return JNI_OK;
 135 }
 136 
 137 /* ========================================================================== */
 138 
 139 }


  34 
  35 /* ========================================================================== */
  36 
  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  41 static int MethodEntryEventsCount = 0;
  42 
  43 /* ========================================================================== */
  44 
  45 /** callback functions **/
  46 
  47 static void JNICALL
  48 MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
  49         jthread thread, jmethodID method) {
  50     char *name = NULL;
  51     char *signature = NULL;
  52 
  53     MethodEntryEventsCount++;
  54     if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {

  55         nsk_jvmti_setFailStatus();
  56         return;
  57     }
  58     NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature);
  59     if (name != NULL)
  60         jvmti_env->Deallocate((unsigned char*)name);
  61     if (signature != NULL)
  62         jvmti_env->Deallocate((unsigned char*)signature);
  63 }
  64 
  65 /* ========================================================================== */
  66 
  67 /** Agent algorithm. */
  68 static void JNICALL
  69 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  70 
  71     if (!nsk_jvmti_waitForSync(timeout))
  72         return;
  73 
  74     /* resume debugee and wait for sync */
  75     if (!nsk_jvmti_resumeSync())
  76         return;
  77     if (!nsk_jvmti_waitForSync(timeout))
  78         return;
  79 
  80     NSK_DISPLAY1("MethodEntry events received: %d\n",
  81         MethodEntryEventsCount);
  82     if (!NSK_VERIFY(MethodEntryEventsCount == 0))


 104     jvmtiEnv* jvmti = NULL;
 105     jvmtiCapabilities caps;
 106     jvmtiEventCallbacks callbacks;
 107 
 108     NSK_DISPLAY0("Agent_OnLoad\n");
 109 
 110     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 111         return JNI_ERR;
 112 
 113     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 114 
 115     if (!NSK_VERIFY((jvmti =
 116             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 117         return JNI_ERR;
 118 
 119     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 120         return JNI_ERR;
 121 
 122     memset(&caps, 0, sizeof(caps));
 123     caps.can_generate_method_entry_events = 1;
 124     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
 125         return JNI_ERR;
 126     }
 127 
 128     memset(&callbacks, 0, sizeof(callbacks));
 129     callbacks.MethodEntry = &MethodEntry;
 130     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 131         return JNI_ERR;
 132 
 133     return JNI_OK;
 134 }
 135 
 136 /* ========================================================================== */
 137 
 138 }
< prev index next >