< prev index next >

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

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


 103                             THREAD_NAME,
 104                             eventsStart, eventsEnd);
 105             nsk_jvmti_setFailStatus();
 106         }
 107     }
 108 
 109     NSK_DISPLAY0("Let debugee to finish\n");
 110     if (!nsk_jvmti_resumeSync())
 111         return;
 112 }
 113 
 114 /* ============================================================================= */
 115 
 116 /** THREAD_START callback. */
 117 JNIEXPORT void JNICALL
 118 callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
 119     /* check if event is for tested thread */
 120     if (thread != NULL) {
 121         jvmtiThreadInfo info;
 122 
 123         if (!NSK_JVMTI_VERIFY(
 124                 NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info))) {
 125             nsk_jvmti_setFailStatus();
 126             return;
 127         }
 128 
 129         if (info.name != NULL && strcmp(info.name, THREAD_NAME) == 0) {
 130             NSK_DISPLAY2("  ... received THREAD_START event for tested thread: %p (%s)\n",
 131                                                             (void*)thread, info.name);
 132             eventsStart++;
 133 
 134             NSK_DISPLAY1("SetThreadLocalStorage() for current thread with pointer: %p\n",
 135                                                                 (void*)initialStorage);
 136             if (!NSK_JVMTI_VERIFY(
 137                     NSK_CPP_STUB3(SetThreadLocalStorage, jvmti,
 138                                         NULL, (void*)initialStorage))) {
 139                 nsk_jvmti_setFailStatus();
 140                 return;
 141             }
 142         }
 143     }
 144 }
 145 
 146 
 147 /** THREAD_END callback. */
 148 JNIEXPORT void JNICALL
 149 callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
 150     /* check if event is for tested thread */
 151     if (thread != NULL) {
 152         jvmtiThreadInfo info;
 153 
 154         if (!NSK_JVMTI_VERIFY(
 155                 NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info))) {
 156             nsk_jvmti_setFailStatus();
 157             return;
 158         }
 159 
 160         if (info.name != NULL && strcmp(info.name, THREAD_NAME) == 0) {
 161             NSK_DISPLAY2("  ... received THREAD_END event for tested thread: %p (%s)\n",
 162                                                             (void*)thread, info.name);
 163             eventsEnd++;
 164 
 165             /* get storage data */
 166             {
 167                 StorageStructure* obtainedStorage = NULL;
 168 
 169                 NSK_DISPLAY0("GetThreadLocalStorage() for current thread\n");
 170                 if (!NSK_JVMTI_VERIFY(
 171                         NSK_CPP_STUB3(GetThreadLocalStorage, jvmti,
 172                                             NULL, (void**)&obtainedStorage))) {
 173                     nsk_jvmti_setFailStatus();
 174                     return;
 175                 }
 176                 NSK_DISPLAY1("  ... got pointer: %p\n", (void*)obtainedStorage);
 177 
 178                 NSK_DISPLAY0("Check storage data obtained for current thread\n");
 179                 if (obtainedStorage != initialStorage) {
 180                     NSK_COMPLAIN3("Wrong storage pointer returned for current thread:\n"
 181                                   "#   thread:      %p\n"
 182                                   "#   got pointer: %p\n"
 183                                   "#   expected:    %p\n",
 184                                     (void*)thread,
 185                                     (void*)obtainedStorage, (void*)initialStorage);
 186                     nsk_jvmti_setFailStatus();
 187                 } else {
 188                     int changed = 0;
 189                     int i;
 190 
 191                     for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 192                         if (obtainedStorage->data[i] != STORAGE_DATA_CHAR) {


 226 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 227     jvmtiEnv* jvmti = NULL;
 228 
 229     /* init framework and parse options */
 230     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 231         return JNI_ERR;
 232 
 233     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 234 
 235     /* create JVMTI environment */
 236     if (!NSK_VERIFY((jvmti =
 237             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 238         return JNI_ERR;
 239 
 240     /* set callbacks for thread events */
 241     {
 242         jvmtiEventCallbacks callbacks;
 243         memset(&callbacks, 0, sizeof(callbacks));
 244         callbacks.ThreadStart = callbackThreadStart;
 245         callbacks.ThreadEnd = callbackThreadEnd;
 246         if (!NSK_JVMTI_VERIFY(
 247                 NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, sizeof(callbacks))))
 248         return JNI_ERR;
 249     }
 250 
 251     /* register agent proc and arg */
 252     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 253         return JNI_ERR;
 254 
 255     return JNI_OK;
 256 }
 257 
 258 /* ============================================================================= */
 259 
 260 }


 103                             THREAD_NAME,
 104                             eventsStart, eventsEnd);
 105             nsk_jvmti_setFailStatus();
 106         }
 107     }
 108 
 109     NSK_DISPLAY0("Let debugee to finish\n");
 110     if (!nsk_jvmti_resumeSync())
 111         return;
 112 }
 113 
 114 /* ============================================================================= */
 115 
 116 /** THREAD_START callback. */
 117 JNIEXPORT void JNICALL
 118 callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
 119     /* check if event is for tested thread */
 120     if (thread != NULL) {
 121         jvmtiThreadInfo info;
 122 
 123         if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) {

 124             nsk_jvmti_setFailStatus();
 125             return;
 126         }
 127 
 128         if (info.name != NULL && strcmp(info.name, THREAD_NAME) == 0) {
 129             NSK_DISPLAY2("  ... received THREAD_START event for tested thread: %p (%s)\n",
 130                                                             (void*)thread, info.name);
 131             eventsStart++;
 132 
 133             NSK_DISPLAY1("SetThreadLocalStorage() for current thread with pointer: %p\n",
 134                                                                 (void*)initialStorage);
 135             if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(NULL, (void*)initialStorage))) {


 136                 nsk_jvmti_setFailStatus();
 137                 return;
 138             }
 139         }
 140     }
 141 }
 142 
 143 
 144 /** THREAD_END callback. */
 145 JNIEXPORT void JNICALL
 146 callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
 147     /* check if event is for tested thread */
 148     if (thread != NULL) {
 149         jvmtiThreadInfo info;
 150 
 151         if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) {

 152             nsk_jvmti_setFailStatus();
 153             return;
 154         }
 155 
 156         if (info.name != NULL && strcmp(info.name, THREAD_NAME) == 0) {
 157             NSK_DISPLAY2("  ... received THREAD_END event for tested thread: %p (%s)\n",
 158                                                             (void*)thread, info.name);
 159             eventsEnd++;
 160 
 161             /* get storage data */
 162             {
 163                 StorageStructure* obtainedStorage = NULL;
 164 
 165                 NSK_DISPLAY0("GetThreadLocalStorage() for current thread\n");
 166                 if (!NSK_JVMTI_VERIFY(
 167                         jvmti->GetThreadLocalStorage(NULL, (void**)&obtainedStorage))) {

 168                     nsk_jvmti_setFailStatus();
 169                     return;
 170                 }
 171                 NSK_DISPLAY1("  ... got pointer: %p\n", (void*)obtainedStorage);
 172 
 173                 NSK_DISPLAY0("Check storage data obtained for current thread\n");
 174                 if (obtainedStorage != initialStorage) {
 175                     NSK_COMPLAIN3("Wrong storage pointer returned for current thread:\n"
 176                                   "#   thread:      %p\n"
 177                                   "#   got pointer: %p\n"
 178                                   "#   expected:    %p\n",
 179                                     (void*)thread,
 180                                     (void*)obtainedStorage, (void*)initialStorage);
 181                     nsk_jvmti_setFailStatus();
 182                 } else {
 183                     int changed = 0;
 184                     int i;
 185 
 186                     for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 187                         if (obtainedStorage->data[i] != STORAGE_DATA_CHAR) {


 221 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 222     jvmtiEnv* jvmti = NULL;
 223 
 224     /* init framework and parse options */
 225     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 226         return JNI_ERR;
 227 
 228     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 229 
 230     /* create JVMTI environment */
 231     if (!NSK_VERIFY((jvmti =
 232             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 233         return JNI_ERR;
 234 
 235     /* set callbacks for thread events */
 236     {
 237         jvmtiEventCallbacks callbacks;
 238         memset(&callbacks, 0, sizeof(callbacks));
 239         callbacks.ThreadStart = callbackThreadStart;
 240         callbacks.ThreadEnd = callbackThreadEnd;
 241         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))

 242         return JNI_ERR;
 243     }
 244 
 245     /* register agent proc and arg */
 246     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 247         return JNI_ERR;
 248 
 249     return JNI_OK;
 250 }
 251 
 252 /* ============================================================================= */
 253 
 254 }
< prev index next >