test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp
changeset 53518 2181425e0460
parent 52114 3b8994cb4481
equal deleted inserted replaced
53517:20ba6a7f897a 53518:2181425e0460
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    63 };
    63 };
    64 
    64 
    65 /* references to tested threads */
    65 /* references to tested threads */
    66 static jthread threadsList[THREADS_COUNT];
    66 static jthread threadsList[THREADS_COUNT];
    67 
    67 
    68 /* events conunts */
    68 /* events counts */
    69 static volatile int eventsStart = 0;
    69 static volatile int eventsStart = 0;
    70 static volatile int eventsEnd   = 0;
    70 static volatile int eventsEnd   = 0;
    71 
    71 
    72 /* ============================================================================= */
    72 /* ============================================================================= */
    73 
    73 
   369     }
   369     }
   370 
   370 
   371     /* check if event is for tested thread */
   371     /* check if event is for tested thread */
   372     for (i = 0; i < THREADS_COUNT; i++) {
   372     for (i = 0; i < THREADS_COUNT; i++) {
   373         if (jni->IsSameObject(threadsList[i], thread)) {
   373         if (jni->IsSameObject(threadsList[i], thread)) {
   374                 NSK_DISPLAY0("SUCCESS: expected THREAD_START event\n");
   374             NSK_DISPLAY0("SUCCESS: expected THREAD_START event\n");
   375 
   375 
   376             /* suspend thread */
   376             /* suspend thread */
   377             NSK_DISPLAY3("  suspend starting thread #%d (%s): %p\n",
   377             NSK_DISPLAY3("  suspend starting thread #%d (%s): %p\n",
   378                                 i, threadsName[i], (void*)thread);
   378                                 i, threadsName[i], (void*)thread);
       
   379             /* must bump the count before we suspend */
       
   380             eventsStart++;
   379 
   381 
   380             if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread))) {
   382             if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread))) {
   381                 nsk_jvmti_setFailStatus();
   383                 nsk_jvmti_setFailStatus();
   382                 return;
   384                 return;
   383             }
   385             }
   384             eventsStart++;
       
   385 
   386 
   386             break;
   387             break;
   387         }
   388         }
   388     }
   389     }
   389 }
   390 }
   404 
   405 
   405     /* check if event is for tested thread */
   406     /* check if event is for tested thread */
   406     for (i = 0; i < THREADS_COUNT; i++) {
   407     for (i = 0; i < THREADS_COUNT; i++) {
   407         if (jni->IsSameObject(threadsList[i], thread)) {
   408         if (jni->IsSameObject(threadsList[i], thread)) {
   408                 NSK_DISPLAY0("SUCCESS: expected THREAD_END event\n");
   409                 NSK_DISPLAY0("SUCCESS: expected THREAD_END event\n");
       
   410             /* must bump the count before we suspend */
       
   411             eventsEnd++;
   409 
   412 
   410             /* suspend thread */
   413             /* suspend thread */
   411             NSK_DISPLAY3("  suspend finishing thread #%d (%s): %p\n",
   414             NSK_DISPLAY3("  suspend finishing thread #%d (%s): %p\n",
   412                                 i, threadsName[i], (void*)thread);
   415                                 i, threadsName[i], (void*)thread);
   413 
   416 
   414             if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread))) {
   417             if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread))) {
   415                 nsk_jvmti_setFailStatus();
   418                 nsk_jvmti_setFailStatus();
   416                 return;
   419                 return;
   417             }
   420             }
   418             eventsEnd++;
       
   419 
   421 
   420             break;
   422             break;
   421         }
   423         }
   422     }
   424     }
   423 }
   425 }