test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp
changeset 53074 1e213c37befa
parent 52642 9cfc8b0c45fd
equal deleted inserted replaced
53073:11033c4ada54 53074:1e213c37befa
    75 
    75 
    76     jvmti->RawMonitorExit(watch_ev_monitor);
    76     jvmti->RawMonitorExit(watch_ev_monitor);
    77 }
    77 }
    78 
    78 
    79 JNIEXPORT jint JNICALL
    79 JNIEXPORT jint JNICALL
    80 Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env,
    80 Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env, jclass cls, jobject susThr) {
    81         jclass cls, jint vrb, jobject susThr) {
       
    82     jvmtiError err;
       
    83 
       
    84     if (!caps.can_pop_frame || !caps.can_suspend) {
    81     if (!caps.can_pop_frame || !caps.can_suspend) {
    85         return PASSED;
    82         return PASSED;
    86     }
    83     }
    87 
    84 
    88     if (vrb == 1)
    85     printf(">>>>>>>> Invoke SuspendThread()\n");
    89         printf(">>>>>>>> Invoke SuspendThread()\n");
    86     jvmtiError err = jvmti->SuspendThread(susThr);
    90     err = jvmti->SuspendThread(susThr);
       
    91     if (err != JVMTI_ERROR_NONE) {
    87     if (err != JVMTI_ERROR_NONE) {
    92         printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
    88         printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
    93             __FILE__, err, TranslateError(err));
    89             __FILE__, err, TranslateError(err));
    94         return JNI_ERR;
    90         return JNI_ERR;
    95     }
    91     }
    96     if (vrb == 1)
    92     printf("<<<<<<<< SuspendThread() is successfully done\n");
    97         printf("<<<<<<<< SuspendThread() is successfully done\n");
       
    98     return PASSED;
    93     return PASSED;
    99 }
    94 }
   100 
    95 
   101 JNIEXPORT jint JNICALL
    96 JNIEXPORT jint JNICALL
   102 Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jint vrb,
    97 Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jobject susThr) {
   103         jobject susThr) {
       
   104     jvmtiError err;
       
   105 
       
   106     if (!caps.can_pop_frame || !caps.can_suspend) {
    98     if (!caps.can_pop_frame || !caps.can_suspend) {
   107         return PASSED;
    99         return PASSED;
   108     }
   100     }
   109 
   101 
   110     if (vrb == 1)
   102     printf(">>>>>>>> Invoke ResumeThread()\n");
   111         printf(">>>>>>>> Invoke ResumeThread()\n");
   103     jvmtiError err = jvmti->ResumeThread(susThr);
   112     err = jvmti->ResumeThread(susThr);
       
   113     if (err != JVMTI_ERROR_NONE) {
   104     if (err != JVMTI_ERROR_NONE) {
   114         printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
   105         printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
   115             __FILE__, err, TranslateError(err));
   106             __FILE__, err, TranslateError(err));
   116         return JNI_ERR;
   107         return JNI_ERR;
   117     }
   108     }
   118     if (vrb == 1)
   109     printf("<<<<<<<< ResumeThread() is successfully done\n");
   119         printf("<<<<<<<< ResumeThread() is successfully done\n");
       
   120     return PASSED;
   110     return PASSED;
   121 }
   111 }
   122 
   112 
   123 
   113 
   124 JNIEXPORT jint JNICALL
   114 JNIEXPORT jint JNICALL
   125 Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jint vrb,
   115 Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jobject frameThr) {
   126         jobject frameThr) {
       
   127     jvmtiError err;
   116     jvmtiError err;
   128 
   117 
   129     if (!caps.can_pop_frame || !caps.can_suspend) {
   118     if (!caps.can_pop_frame || !caps.can_suspend) {
   130         return PASSED;
   119         return PASSED;
   131     }
   120     }
   144         printf("Failed to enable FRAME_POP event: %s (%d)\n",
   133         printf("Failed to enable FRAME_POP event: %s (%d)\n",
   145                TranslateError(err), err);
   134                TranslateError(err), err);
   146         tot_result = STATUS_FAILED;
   135         tot_result = STATUS_FAILED;
   147     }
   136     }
   148 
   137 
   149     if (vrb == 1)
   138     printf(">>>>>>>> Invoke PopFrame()\n");
   150         printf(">>>>>>>> Invoke PopFrame()\n");
       
   151     set_watch_ev(1); /* watch JVMTI events */
   139     set_watch_ev(1); /* watch JVMTI events */
   152 
   140 
   153     err = jvmti->PopFrame(frameThr);
   141     err = jvmti->PopFrame(frameThr);
   154     if (err != JVMTI_ERROR_NONE) {
   142     if (err != JVMTI_ERROR_NONE) {
   155         printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n",
   143         printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n",
   156             err, TranslateError(err));
   144             err, TranslateError(err));
   157         printf("\tFor more info about this error see the JVMTI spec.\n");
   145         printf("\tFor more info about this error see the JVMTI spec.\n");
   158         tot_result = STATUS_FAILED;
   146         tot_result = STATUS_FAILED;
   159     }
   147     }
   160     else if (vrb == 1)
   148     else {
   161         printf("Check #1 PASSED: PopFrame() is successfully done\n");
   149         printf("Check #1 PASSED: PopFrame() is successfully done\n");
       
   150     }
   162 
   151 
   163     set_watch_ev(0); /* ignore again JVMTI events */
   152     set_watch_ev(0); /* ignore again JVMTI events */
   164     if (gen_ev) {
   153     if (gen_ev) {
   165         printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n",
   154         printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n",
   166             gen_ev);
   155             gen_ev);
   167         tot_result = STATUS_FAILED;
   156         tot_result = STATUS_FAILED;
   168     } else if (vrb == 1)
   157     } else {
   169         printf("Check #2 PASSED: No JVMTI events were generated by the function PopFrame()\n");
   158         printf("Check #2 PASSED: No JVMTI events were generated by the function PopFrame()\n");
       
   159     }
   170 
   160 
   171     return(tot_result);
   161     return(tot_result);
   172 }
   162 }
   173 
   163 
   174 #ifdef STATIC_BUILD
   164 #ifdef STATIC_BUILD