< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp

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


  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  41 static int CompiledMethodLoadEventsCount = 0;
  42 static int CompiledMethodUnloadEventsCount = 0;
  43 
  44 /* ========================================================================== */
  45 
  46 /** callback functions **/
  47 
  48 static void JNICALL
  49 CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method,
  50         jint code_size, const void* code_addr, jint map_length,
  51         const jvmtiAddrLocationMap* map, const void* compile_info) {
  52     char *name = NULL;
  53     char *signature = NULL;
  54 
  55     CompiledMethodLoadEventsCount++;
  56 
  57     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
  58             jvmti_env, method, &name, &signature, NULL))) {
  59         nsk_jvmti_setFailStatus();
  60         return;
  61     }
  62     NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
  63         name, signature, code_addr);
  64     if (name != NULL)
  65         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
  66     if (signature != NULL)
  67         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
  68 }
  69 
  70 static void JNICALL
  71 CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method,
  72         const void* code_addr) {
  73     char *name = NULL;
  74     char *sig = NULL;
  75     jvmtiError err;
  76 
  77     CompiledMethodUnloadEventsCount++;
  78 
  79     NSK_DISPLAY0("CompiledMethodUnload event received\n");
  80     // Check for the case that the class has been unloaded
  81     err = jvmti_env->GetMethodName(method, &name, &sig, NULL);
  82     if (err == JVMTI_ERROR_NONE) {
  83         NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n",
  84           name, sig, code_addr);
  85         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
  86         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)sig);
  87     }
  88 }
  89 
  90 /* ========================================================================== */
  91 
  92 /** Agent algorithm. */
  93 static void JNICALL
  94 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  95 
  96     if (!nsk_jvmti_waitForSync(timeout))
  97         return;
  98 
  99     NSK_DISPLAY1("CompiledMethodLoad events received: %d\n",
 100         CompiledMethodLoadEventsCount);
 101     if (!NSK_VERIFY(CompiledMethodLoadEventsCount == 0))
 102         nsk_jvmti_setFailStatus();
 103 
 104     NSK_DISPLAY1("CompiledMethodUnload events received: %d\n",
 105         CompiledMethodUnloadEventsCount);
 106     if (!NSK_VERIFY(CompiledMethodUnloadEventsCount == 0))


 128     jvmtiEnv* jvmti = NULL;
 129     jvmtiCapabilities caps;
 130     jvmtiEventCallbacks callbacks;
 131 
 132     NSK_DISPLAY0("Agent_OnLoad\n");
 133 
 134     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 135         return JNI_ERR;
 136 
 137     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 138 
 139     if (!NSK_VERIFY((jvmti =
 140             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 141         return JNI_ERR;
 142 
 143     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 144         return JNI_ERR;
 145 
 146     memset(&caps, 0, sizeof(caps));
 147     caps.can_generate_compiled_method_load_events = 1;
 148     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
 149         return JNI_ERR;
 150     }
 151 
 152     memset(&callbacks, 0, sizeof(callbacks));
 153     callbacks.CompiledMethodLoad = &CompiledMethodLoad;
 154     callbacks.CompiledMethodUnload = &CompiledMethodUnload;
 155     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 156         return JNI_ERR;
 157 
 158     return JNI_OK;
 159 }
 160 
 161 /* ========================================================================== */
 162 
 163 }


  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  41 static int CompiledMethodLoadEventsCount = 0;
  42 static int CompiledMethodUnloadEventsCount = 0;
  43 
  44 /* ========================================================================== */
  45 
  46 /** callback functions **/
  47 
  48 static void JNICALL
  49 CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method,
  50         jint code_size, const void* code_addr, jint map_length,
  51         const jvmtiAddrLocationMap* map, const void* compile_info) {
  52     char *name = NULL;
  53     char *signature = NULL;
  54 
  55     CompiledMethodLoadEventsCount++;
  56 
  57     if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {

  58         nsk_jvmti_setFailStatus();
  59         return;
  60     }
  61     NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
  62         name, signature, code_addr);
  63     if (name != NULL)
  64         jvmti_env->Deallocate((unsigned char*)name);
  65     if (signature != NULL)
  66         jvmti_env->Deallocate((unsigned char*)signature);
  67 }
  68 
  69 static void JNICALL
  70 CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method,
  71         const void* code_addr) {
  72     char *name = NULL;
  73     char *sig = NULL;
  74     jvmtiError err;
  75 
  76     CompiledMethodUnloadEventsCount++;
  77 
  78     NSK_DISPLAY0("CompiledMethodUnload event received\n");
  79     // Check for the case that the class has been unloaded
  80     err = jvmti_env->GetMethodName(method, &name, &sig, NULL);
  81     if (err == JVMTI_ERROR_NONE) {
  82         NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n",
  83           name, sig, code_addr);
  84         jvmti_env->Deallocate((unsigned char*)name);
  85         jvmti_env->Deallocate((unsigned char*)sig);
  86     }
  87 }
  88 
  89 /* ========================================================================== */
  90 
  91 /** Agent algorithm. */
  92 static void JNICALL
  93 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  94 
  95     if (!nsk_jvmti_waitForSync(timeout))
  96         return;
  97 
  98     NSK_DISPLAY1("CompiledMethodLoad events received: %d\n",
  99         CompiledMethodLoadEventsCount);
 100     if (!NSK_VERIFY(CompiledMethodLoadEventsCount == 0))
 101         nsk_jvmti_setFailStatus();
 102 
 103     NSK_DISPLAY1("CompiledMethodUnload events received: %d\n",
 104         CompiledMethodUnloadEventsCount);
 105     if (!NSK_VERIFY(CompiledMethodUnloadEventsCount == 0))


 127     jvmtiEnv* jvmti = NULL;
 128     jvmtiCapabilities caps;
 129     jvmtiEventCallbacks callbacks;
 130 
 131     NSK_DISPLAY0("Agent_OnLoad\n");
 132 
 133     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 134         return JNI_ERR;
 135 
 136     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 137 
 138     if (!NSK_VERIFY((jvmti =
 139             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 140         return JNI_ERR;
 141 
 142     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 143         return JNI_ERR;
 144 
 145     memset(&caps, 0, sizeof(caps));
 146     caps.can_generate_compiled_method_load_events = 1;
 147     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
 148         return JNI_ERR;
 149     }
 150 
 151     memset(&callbacks, 0, sizeof(callbacks));
 152     callbacks.CompiledMethodLoad = &CompiledMethodLoad;
 153     callbacks.CompiledMethodUnload = &CompiledMethodUnload;
 154     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 155         return JNI_ERR;
 156 
 157     return JNI_OK;
 158 }
 159 
 160 /* ========================================================================== */
 161 
 162 }
< prev index next >