< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp

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


  56     if (!nsk_jvmti_waitForSync(timeout))
  57         return;
  58 
  59     /* perform testing */
  60     {
  61         jthread testedThread = NULL;
  62         StorageStructure storageData;
  63         StorageStructure* initialStorage = &storageData;
  64         StorageStructure* obtainedStorage = NULL;
  65 
  66         memset(storageData.data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  67 
  68         NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME);
  69         if (!NSK_VERIFY((testedThread =
  70                 nsk_jvmti_threadByName(THREAD_NAME)) != NULL))
  71             return;
  72         NSK_DISPLAY1("  ... found thread: %p\n", (void*)testedThread);
  73 
  74         NSK_DISPLAY1("SetThreadLocalStorage() for tested thread with pointer: %p\n",
  75                                                     (void*)initialStorage);
  76         if (!NSK_JVMTI_VERIFY(
  77                 NSK_CPP_STUB3(SetThreadLocalStorage, jvmti,
  78                                         testedThread, (void*)initialStorage))) {
  79             nsk_jvmti_setFailStatus();
  80             return;
  81         }
  82 
  83         NSK_DISPLAY0("Let tested thread to run\n");
  84         if (!nsk_jvmti_resumeSync())
  85             return;
  86 
  87         NSK_DISPLAY0("Wait for thread to run\n");
  88         if (!nsk_jvmti_waitForSync(timeout))
  89             return;
  90 
  91         NSK_DISPLAY0("GetThreadLocalStorage() for tested thread\n");
  92         if (!NSK_JVMTI_VERIFY(
  93                 NSK_CPP_STUB3(GetThreadLocalStorage, jvmti,
  94                                         testedThread, (void**)&obtainedStorage))) {
  95             nsk_jvmti_setFailStatus();
  96             return;
  97         }
  98         NSK_DISPLAY1("  ... got storage: %p\n", (void*)obtainedStorage);
  99 
 100         NSK_DISPLAY0("Check storage data obtained for tested thread\n");
 101         if (obtainedStorage != initialStorage) {
 102             NSK_COMPLAIN3("Wrong storage pointer returned for tested thread:\n"
 103                           "#   thread:      %p\n"
 104                           "#   got pointer: %p\n"
 105                           "#   expected:    %p\n",
 106                             (void*)testedThread,
 107                             (void*)obtainedStorage, (void*)initialStorage);
 108             nsk_jvmti_setFailStatus();
 109         } else {
 110             int changed = 0;
 111             int i;
 112 
 113             for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 114                 if (obtainedStorage->data[i] != STORAGE_DATA_CHAR) {
 115                     changed++;
 116                 }
 117             }
 118 
 119             if (changed > 0) {
 120                 NSK_COMPLAIN3("Data changed in returned storage for tested thread:\n"
 121                           "#   thread:        %p\n"
 122                           "#   changed bytes: %d\n"
 123                           "#   total bytes:   %d\n",
 124                             (void*)testedThread,
 125                             changed, STORAGE_DATA_SIZE);
 126                 nsk_jvmti_setFailStatus();
 127             }
 128         }
 129 
 130         NSK_DISPLAY0("Delete thread reference\n");
 131         NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedThread));
 132     }
 133 
 134     NSK_DISPLAY0("Let debugee to finish\n");
 135     if (!nsk_jvmti_resumeSync())
 136         return;
 137 }
 138 
 139 /* ============================================================================= */
 140 
 141 /** Agent library initialization. */
 142 #ifdef STATIC_BUILD
 143 JNIEXPORT jint JNICALL Agent_OnLoad_setthrdstor001(JavaVM *jvm, char *options, void *reserved) {
 144     return Agent_Initialize(jvm, options, reserved);
 145 }
 146 JNIEXPORT jint JNICALL Agent_OnAttach_setthrdstor001(JavaVM *jvm, char *options, void *reserved) {
 147     return Agent_Initialize(jvm, options, reserved);
 148 }
 149 JNIEXPORT jint JNI_OnLoad_setthrdstor001(JavaVM *jvm, char *options, void *reserved) {
 150     return JNI_VERSION_1_8;
 151 }




  56     if (!nsk_jvmti_waitForSync(timeout))
  57         return;
  58 
  59     /* perform testing */
  60     {
  61         jthread testedThread = NULL;
  62         StorageStructure storageData;
  63         StorageStructure* initialStorage = &storageData;
  64         StorageStructure* obtainedStorage = NULL;
  65 
  66         memset(storageData.data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  67 
  68         NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME);
  69         if (!NSK_VERIFY((testedThread =
  70                 nsk_jvmti_threadByName(THREAD_NAME)) != NULL))
  71             return;
  72         NSK_DISPLAY1("  ... found thread: %p\n", (void*)testedThread);
  73 
  74         NSK_DISPLAY1("SetThreadLocalStorage() for tested thread with pointer: %p\n",
  75                                                     (void*)initialStorage);
  76         if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(testedThread, (void*)initialStorage))) {


  77             nsk_jvmti_setFailStatus();
  78             return;
  79         }
  80 
  81         NSK_DISPLAY0("Let tested thread to run\n");
  82         if (!nsk_jvmti_resumeSync())
  83             return;
  84 
  85         NSK_DISPLAY0("Wait for thread to run\n");
  86         if (!nsk_jvmti_waitForSync(timeout))
  87             return;
  88 
  89         NSK_DISPLAY0("GetThreadLocalStorage() for tested thread\n");
  90         if (!NSK_JVMTI_VERIFY(
  91                 jvmti->GetThreadLocalStorage(testedThread, (void**)&obtainedStorage))) {

  92             nsk_jvmti_setFailStatus();
  93             return;
  94         }
  95         NSK_DISPLAY1("  ... got storage: %p\n", (void*)obtainedStorage);
  96 
  97         NSK_DISPLAY0("Check storage data obtained for tested thread\n");
  98         if (obtainedStorage != initialStorage) {
  99             NSK_COMPLAIN3("Wrong storage pointer returned for tested thread:\n"
 100                           "#   thread:      %p\n"
 101                           "#   got pointer: %p\n"
 102                           "#   expected:    %p\n",
 103                             (void*)testedThread,
 104                             (void*)obtainedStorage, (void*)initialStorage);
 105             nsk_jvmti_setFailStatus();
 106         } else {
 107             int changed = 0;
 108             int i;
 109 
 110             for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 111                 if (obtainedStorage->data[i] != STORAGE_DATA_CHAR) {
 112                     changed++;
 113                 }
 114             }
 115 
 116             if (changed > 0) {
 117                 NSK_COMPLAIN3("Data changed in returned storage for tested thread:\n"
 118                           "#   thread:        %p\n"
 119                           "#   changed bytes: %d\n"
 120                           "#   total bytes:   %d\n",
 121                             (void*)testedThread,
 122                             changed, STORAGE_DATA_SIZE);
 123                 nsk_jvmti_setFailStatus();
 124             }
 125         }
 126 
 127         NSK_DISPLAY0("Delete thread reference\n");
 128         NSK_TRACE(jni->DeleteGlobalRef(testedThread));
 129     }
 130 
 131     NSK_DISPLAY0("Let debugee to finish\n");
 132     if (!nsk_jvmti_resumeSync())
 133         return;
 134 }
 135 
 136 /* ============================================================================= */
 137 
 138 /** Agent library initialization. */
 139 #ifdef STATIC_BUILD
 140 JNIEXPORT jint JNICALL Agent_OnLoad_setthrdstor001(JavaVM *jvm, char *options, void *reserved) {
 141     return Agent_Initialize(jvm, options, reserved);
 142 }
 143 JNIEXPORT jint JNICALL Agent_OnAttach_setthrdstor001(JavaVM *jvm, char *options, void *reserved) {
 144     return Agent_Initialize(jvm, options, reserved);
 145 }
 146 JNIEXPORT jint JNI_OnLoad_setthrdstor001(JavaVM *jvm, char *options, void *reserved) {
 147     return JNI_VERSION_1_8;
 148 }


< prev index next >