< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp

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


  56 static StorageStructure storageData;
  57 static StorageStructure* initialStorage = &storageData;
  58 
  59 /* ============================================================================= */
  60 
  61 /** Fill storage data with given char */
  62 static void fillEnvStorage(StorageStructure* storage) {
  63     NSK_DISPLAY2("Fill storage data with char %c for size: %d bytes\n",
  64                 (char)STORAGE_DATA_CHAR, (int)STORAGE_DATA_SIZE);
  65     memset(storage->data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  66     NSK_DISPLAY0("  ... ok\n");
  67 }
  68 
  69 /**
  70  * Set JVMTI environment local storage with given pinter.
  71  * @returns NSK_FALSE if any error occured.
  72  */
  73 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
  74 
  75     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
  76     if (!NSK_JVMTI_VERIFY(
  77             NSK_CPP_STUB2(SetEnvironmentLocalStorage, jvmti, storage))) {
  78         return NSK_FALSE;
  79     }
  80     NSK_DISPLAY0("  ... ok\n");
  81     return NSK_TRUE;
  82 }
  83 
  84 /**
  85  * Check JVMTI environment local storage.
  86  * @returns NSK_FALSE if any error occured.
  87  */
  88 static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) {
  89     StorageStructure* storage = NULL;
  90 
  91     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
  92     if (!NSK_JVMTI_VERIFY(
  93             NSK_CPP_STUB2(GetEnvironmentLocalStorage, jvmti, (void**)&storage))) {
  94         return NSK_FALSE;
  95     }
  96     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
  97 
  98     if (storage != initialStorage) {
  99         NSK_COMPLAIN3("Wrong storage pointer returned for current JVMTI env in %s:\n"
 100                       "#   got pointer: %p\n"
 101                       "#   expected:    %p\n",
 102                         where,
 103                         (void*)storage, (void*)initialStorage);
 104         return NSK_FALSE;
 105     }
 106 
 107     {
 108         int changed = 0;
 109         int i;
 110 
 111         for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 112             if (storage->data[i] != STORAGE_DATA_CHAR) {
 113                 changed++;


 207 }
 208 #endif
 209 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 210     jvmtiEnv* jvmti = NULL;
 211 
 212     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 213         return JNI_ERR;
 214 
 215     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 216 
 217     if (!NSK_VERIFY((jvmti =
 218             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 219         return JNI_ERR;
 220 
 221     {
 222         jvmtiEventCallbacks eventCallbacks;
 223 
 224         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
 225         eventCallbacks.VMInit = callbackVMInit;
 226         eventCallbacks.VMDeath = callbackVMDeath;
 227         if (!NSK_JVMTI_VERIFY(
 228                 NSK_CPP_STUB3(SetEventCallbacks, jvmti,
 229                                     &eventCallbacks, sizeof(eventCallbacks)))) {
 230             return JNI_ERR;
 231         }
 232 
 233     }
 234 
 235     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 236         return JNI_ERR;
 237 
 238     NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage);
 239     fillEnvStorage(initialStorage);
 240 
 241     NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT);
 242     if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) {
 243         NSK_DISPLAY0("  ... enabled\n");
 244     }
 245 
 246     return JNI_OK;
 247 }
 248 
 249 /* ============================================================================= */


  56 static StorageStructure storageData;
  57 static StorageStructure* initialStorage = &storageData;
  58 
  59 /* ============================================================================= */
  60 
  61 /** Fill storage data with given char */
  62 static void fillEnvStorage(StorageStructure* storage) {
  63     NSK_DISPLAY2("Fill storage data with char %c for size: %d bytes\n",
  64                 (char)STORAGE_DATA_CHAR, (int)STORAGE_DATA_SIZE);
  65     memset(storage->data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  66     NSK_DISPLAY0("  ... ok\n");
  67 }
  68 
  69 /**
  70  * Set JVMTI environment local storage with given pinter.
  71  * @returns NSK_FALSE if any error occured.
  72  */
  73 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
  74 
  75     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
  76     if (!NSK_JVMTI_VERIFY(jvmti->SetEnvironmentLocalStorage(storage))) {

  77         return NSK_FALSE;
  78     }
  79     NSK_DISPLAY0("  ... ok\n");
  80     return NSK_TRUE;
  81 }
  82 
  83 /**
  84  * Check JVMTI environment local storage.
  85  * @returns NSK_FALSE if any error occured.
  86  */
  87 static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) {
  88     StorageStructure* storage = NULL;
  89 
  90     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
  91     if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) {

  92         return NSK_FALSE;
  93     }
  94     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
  95 
  96     if (storage != initialStorage) {
  97         NSK_COMPLAIN3("Wrong storage pointer returned for current JVMTI env in %s:\n"
  98                       "#   got pointer: %p\n"
  99                       "#   expected:    %p\n",
 100                         where,
 101                         (void*)storage, (void*)initialStorage);
 102         return NSK_FALSE;
 103     }
 104 
 105     {
 106         int changed = 0;
 107         int i;
 108 
 109         for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 110             if (storage->data[i] != STORAGE_DATA_CHAR) {
 111                 changed++;


 205 }
 206 #endif
 207 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 208     jvmtiEnv* jvmti = NULL;
 209 
 210     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 211         return JNI_ERR;
 212 
 213     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 214 
 215     if (!NSK_VERIFY((jvmti =
 216             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 217         return JNI_ERR;
 218 
 219     {
 220         jvmtiEventCallbacks eventCallbacks;
 221 
 222         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
 223         eventCallbacks.VMInit = callbackVMInit;
 224         eventCallbacks.VMDeath = callbackVMDeath;
 225         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {


 226             return JNI_ERR;
 227         }
 228 
 229     }
 230 
 231     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 232         return JNI_ERR;
 233 
 234     NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage);
 235     fillEnvStorage(initialStorage);
 236 
 237     NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT);
 238     if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) {
 239         NSK_DISPLAY0("  ... enabled\n");
 240     }
 241 
 242     return JNI_OK;
 243 }
 244 
 245 /* ============================================================================= */
< prev index next >