< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.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++;


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


  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++;


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


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