< prev index next >

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

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


  49 /* ============================================================================= */
  50 
  51 /** Agent algorithm. */
  52 static void JNICALL
  53 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  54 
  55     NSK_DISPLAY0("Wait for thread to start\n");
  56     if (!nsk_jvmti_waitForSync(timeout))
  57         return;
  58 
  59     /* perform testing */
  60     {
  61         StorageStructure storageData;
  62         StorageStructure* initialStorage = &storageData;
  63         StorageStructure* obtainedStorage = NULL;
  64 
  65         memset(storageData.data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  66 
  67         NSK_DISPLAY1("SetThreadLocalStorage() for current agent thread with pointer: %p\n",
  68                                                     (void*)initialStorage);
  69         if (!NSK_JVMTI_VERIFY(
  70                 NSK_CPP_STUB3(SetThreadLocalStorage, jvmti,
  71                                         NULL, (void*)initialStorage))) {
  72             nsk_jvmti_setFailStatus();
  73             return;
  74         }
  75 
  76         NSK_DISPLAY0("Let debuggee to run\n");
  77         if (!nsk_jvmti_resumeSync())
  78             return;
  79 
  80         NSK_DISPLAY0("Wait for debuggee to run\n");
  81         if (!nsk_jvmti_waitForSync(timeout))
  82             return;
  83 
  84         NSK_DISPLAY0("GetThreadLocalStorage() for current agent thread\n");
  85         if (!NSK_JVMTI_VERIFY(
  86                 NSK_CPP_STUB3(GetThreadLocalStorage, jvmti,
  87                                         NULL, (void**)&obtainedStorage))) {
  88             nsk_jvmti_setFailStatus();
  89             return;
  90         }
  91         NSK_DISPLAY1("  ... got storage: %p\n", (void*)obtainedStorage);
  92 
  93         NSK_DISPLAY0("Check storage data obtained for current agent thread\n");
  94         if (obtainedStorage != initialStorage) {
  95             NSK_COMPLAIN2("Wrong storage pointer returned for tested thread:\n"
  96                           "#   got pointer: %p\n"
  97                           "#   expected:    %p\n",
  98                             (void*)obtainedStorage, (void*)initialStorage);
  99             nsk_jvmti_setFailStatus();
 100         } else {
 101             int changed = 0;
 102             int i;
 103 
 104             for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 105                 if (obtainedStorage->data[i] != STORAGE_DATA_CHAR) {
 106                     changed++;
 107                 }




  49 /* ============================================================================= */
  50 
  51 /** Agent algorithm. */
  52 static void JNICALL
  53 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  54 
  55     NSK_DISPLAY0("Wait for thread to start\n");
  56     if (!nsk_jvmti_waitForSync(timeout))
  57         return;
  58 
  59     /* perform testing */
  60     {
  61         StorageStructure storageData;
  62         StorageStructure* initialStorage = &storageData;
  63         StorageStructure* obtainedStorage = NULL;
  64 
  65         memset(storageData.data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  66 
  67         NSK_DISPLAY1("SetThreadLocalStorage() for current agent thread with pointer: %p\n",
  68                                                     (void*)initialStorage);
  69         if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(NULL, (void*)initialStorage))) {


  70             nsk_jvmti_setFailStatus();
  71             return;
  72         }
  73 
  74         NSK_DISPLAY0("Let debuggee to run\n");
  75         if (!nsk_jvmti_resumeSync())
  76             return;
  77 
  78         NSK_DISPLAY0("Wait for debuggee to run\n");
  79         if (!nsk_jvmti_waitForSync(timeout))
  80             return;
  81 
  82         NSK_DISPLAY0("GetThreadLocalStorage() for current agent thread\n");
  83         if (!NSK_JVMTI_VERIFY(jvmti->GetThreadLocalStorage(NULL, (void**)&obtainedStorage))) {


  84             nsk_jvmti_setFailStatus();
  85             return;
  86         }
  87         NSK_DISPLAY1("  ... got storage: %p\n", (void*)obtainedStorage);
  88 
  89         NSK_DISPLAY0("Check storage data obtained for current agent thread\n");
  90         if (obtainedStorage != initialStorage) {
  91             NSK_COMPLAIN2("Wrong storage pointer returned for tested thread:\n"
  92                           "#   got pointer: %p\n"
  93                           "#   expected:    %p\n",
  94                             (void*)obtainedStorage, (void*)initialStorage);
  95             nsk_jvmti_setFailStatus();
  96         } else {
  97             int changed = 0;
  98             int i;
  99 
 100             for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 101                 if (obtainedStorage->data[i] != STORAGE_DATA_CHAR) {
 102                     changed++;
 103                 }


< prev index next >