test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp
author jcbeyler
Wed, 12 Sep 2018 10:27:03 -0700
changeset 51715 13a63d4a3f8d
parent 51551 e409244ce72e
child 52642 9cfc8b0c45fd
permissions -rw-r--r--
8210593: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti[N-R] tests Summary: Remove JNI_ENV/JVMTI_ENV macros from N to R jvmti tests Reviewed-by: amenkov, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     1
/*
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     4
 *
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     8
 *
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    14
 *
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    18
 *
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    21
 * questions.
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    22
 */
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    23
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    24
#include <stdio.h>
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    25
#include <stdlib.h>
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    26
#include "jvmti.h"
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    27
#include "agent_common.h"
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    28
#include "JVMTITools.h"
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    29
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    30
extern "C" {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    31
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    32
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    33
#define STATUS_FAILED 2
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    34
#define PASSED 0
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    35
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    36
static jvmtiEnv *jvmti;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    37
static jvmtiCapabilities caps;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    38
static jvmtiEventCallbacks callbacks;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    39
static int watch_ev = 0;        /* ignore JVMTI events by default */
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    40
static int gen_ev = 0;          /* number of generated events */
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    41
static int tot_result = PASSED; /* total result of the test */
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    42
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    43
static jrawMonitorID watch_ev_monitor;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    44
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    45
static void set_watch_ev(int value) {
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    46
    jvmti->RawMonitorEnter(watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    47
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    48
    watch_ev = value;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    49
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    50
    jvmti->RawMonitorExit(watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    51
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    52
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    53
void JNICALL
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    54
FramePop(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread,
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    55
        jmethodID method, jboolean wasPopedByException) {
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    56
    jvmti->RawMonitorEnter(watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    57
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    58
    if (watch_ev) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    59
        printf("#### FramePop event occurred ####\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    60
        gen_ev++;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    61
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    62
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    63
    jvmti->RawMonitorExit(watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    64
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    65
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    66
void JNICALL
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    67
MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr,
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    68
        jmethodID method, jboolean was_poped_by_exc, jvalue return_value) {
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    69
    jvmti->RawMonitorEnter(watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    70
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    71
    if (watch_ev) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    72
        printf("#### MethodExit event occurred ####\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    73
        gen_ev++;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    74
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    75
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    76
    jvmti->RawMonitorExit(watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    77
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    78
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    79
JNIEXPORT jint JNICALL
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    80
Java_nsk_jvmti_PopFrame_popframe003_suspThread(JNIEnv *env,
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    81
        jclass cls, jint vrb, jobject susThr) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    82
    jvmtiError err;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    83
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    84
    if (!caps.can_pop_frame || !caps.can_suspend) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    85
        return PASSED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    86
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    87
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    88
    if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    89
        printf(">>>>>>>> Invoke SuspendThread()\n");
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
    90
    if ((err = (jvmti->SuspendThread(susThr))) != JVMTI_ERROR_NONE) {
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    91
        printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    92
            __FILE__, err, TranslateError(err));
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    93
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    94
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    95
    if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    96
        printf("<<<<<<<< SuspendThread() is successfully done\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    97
    return PASSED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    98
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
    99
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   100
JNIEXPORT jint JNICALL
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   101
Java_nsk_jvmti_PopFrame_popframe003_resThread(JNIEnv *env, jclass cls, jint vrb,
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   102
        jobject susThr) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   103
    jvmtiError err;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   104
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   105
    if (!caps.can_pop_frame || !caps.can_suspend) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   106
        return PASSED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   107
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   108
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   109
    if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   110
        printf(">>>>>>>> Invoke ResumeThread()\n");
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   111
    if ((err = (jvmti->ResumeThread(susThr))) != JVMTI_ERROR_NONE) {
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   112
        printf("%s: Failed to call ResumeThread(): error=%d: %s\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   113
            __FILE__, err, TranslateError(err));
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   114
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   115
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   116
    if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   117
        printf("<<<<<<<< ResumeThread() is successfully done\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   118
    return PASSED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   119
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   120
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   121
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   122
JNIEXPORT jint JNICALL
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   123
Java_nsk_jvmti_PopFrame_popframe003_doPopFrame(JNIEnv *env, jclass cls, jint vrb,
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   124
        jobject frameThr) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   125
    jvmtiError err;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   126
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   127
    if (!caps.can_pop_frame || !caps.can_suspend) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   128
        return PASSED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   129
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   130
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   131
    err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   132
        JVMTI_EVENT_METHOD_EXIT, frameThr);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   133
    if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   134
        printf("Failed to enable METHOD_EXIT event: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   135
               TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   136
        tot_result = STATUS_FAILED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   137
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   138
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   139
    err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   140
        JVMTI_EVENT_FRAME_POP, frameThr);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   141
    if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   142
        printf("Failed to enable FRAME_POP event: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   143
               TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   144
        tot_result = STATUS_FAILED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   145
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   146
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   147
    if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   148
        printf(">>>>>>>> Invoke PopFrame()\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   149
    set_watch_ev(1); /* watch JVMTI events */
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   150
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   151
    if ((err = (jvmti->PopFrame(frameThr))) != JVMTI_ERROR_NONE) {
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   152
        printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   153
            err, TranslateError(err));
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   154
        printf("\tFor more info about this error see the JVMTI spec.\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   155
        tot_result = STATUS_FAILED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   156
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   157
    else if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   158
        printf("Check #1 PASSED: PopFrame() is successfully done\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   159
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   160
    set_watch_ev(0); /* ignore again JVMTI events */
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   161
    if (gen_ev) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   162
        printf("TEST FAILED: %d JVMTI events were generated by the function PopFrame()\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   163
            gen_ev);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   164
        tot_result = STATUS_FAILED;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   165
    } else if (vrb == 1)
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   166
        printf("Check #2 PASSED: No JVMTI events were generated by the function PopFrame()\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   167
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   168
    return(tot_result);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   169
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   170
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   171
#ifdef STATIC_BUILD
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   172
JNIEXPORT jint JNICALL Agent_OnLoad_popframe003(JavaVM *jvm, char *options, void *reserved) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   173
    return Agent_Initialize(jvm, options, reserved);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   174
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   175
JNIEXPORT jint JNICALL Agent_OnAttach_popframe003(JavaVM *jvm, char *options, void *reserved) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   176
    return Agent_Initialize(jvm, options, reserved);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   177
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   178
JNIEXPORT jint JNI_OnLoad_popframe003(JavaVM *jvm, char *options, void *reserved) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   179
    return JNI_VERSION_1_8;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   180
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   181
#endif
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   182
jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   183
    jint res;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   184
    jvmtiError err;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   185
51715
13a63d4a3f8d 8210593: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti[N-R] tests
jcbeyler
parents: 51551
diff changeset
   186
    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   187
    if (res != JNI_OK || jvmti == NULL) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   188
        printf("Wrong result of a valid call to GetEnv!\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   189
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   190
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   191
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   192
    err = jvmti->GetPotentialCapabilities(&caps);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   193
    if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   194
        printf("(GetPotentialCapabilities) unexpected error: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   195
               TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   196
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   197
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   198
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   199
    err = jvmti->AddCapabilities(&caps);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   200
    if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   201
        printf("(AddCapabilities) unexpected error: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   202
               TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   203
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   204
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   205
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   206
    err = jvmti->GetCapabilities(&caps);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   207
    if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   208
        printf("(GetCapabilities) unexpected error: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   209
               TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   210
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   211
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   212
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   213
    if (!caps.can_pop_frame) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   214
        printf("Warning: PopFrame is not implemented\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   215
        return JNI_OK;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   216
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   217
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   218
    if (!caps.can_suspend) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   219
        printf("Warning: suspend/resume is not implemented\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   220
        return JNI_OK;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   221
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   222
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   223
    if (caps.can_generate_frame_pop_events &&
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   224
            caps.can_generate_method_exit_events) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   225
        callbacks.MethodExit = &MethodExit;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   226
        callbacks.FramePop = &FramePop;
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   227
        err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   228
        if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   229
            printf("(SetEventCallbacks) unexpected error: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   230
                   TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   231
            return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   232
        }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   233
    } else {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   234
        printf("Warning: FramePop or MethodExit event is not implemented\n");
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   235
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   236
51551
e409244ce72e 8209611: use C++ compiler for hotspot tests
iignatyev
parents: 50260
diff changeset
   237
    err = jvmti->CreateRawMonitor("watch_ev_monitor", &watch_ev_monitor);
50260
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   238
    if (err != JVMTI_ERROR_NONE) {
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   239
        printf("(CreateRawMonitor) unexpected error: %s (%d)\n",
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   240
               TranslateError(err), err);
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   241
        return JNI_ERR;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   242
    }
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   243
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   244
    return JNI_OK;
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   245
}
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   246
46c67f5e27c2 8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff changeset
   247
}