Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/nsk_strace.h
41155 views
/*1* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#include <stdlib.h>24#include "jni_tools.h"2526#ifndef _IS_NSK_STRACE_DEFINED_27#define _IS_NSK_STRACE_DEFINED_2829#define JNI_VERSION JNI_VERSION_1_13031#define EXCEPTION_CLEAR env->ExceptionClear()32#define EXCEPTION_OCCURRED env->ExceptionOccurred()3334// Check for pending exception of the specified type35// If it's present, then clear it36#define EXCEPTION_CHECK(exceptionClass, recurDepth) \37if (EXCEPTION_OCCURRED != NULL) { \38jobject exception = EXCEPTION_OCCURRED; \39if (env->IsInstanceOf(exception, exceptionClass) == JNI_TRUE) { \40EXCEPTION_CLEAR; \41NSK_DISPLAY1("StackOverflowError occurred at depth %d\n", recurDepth); \42} \43}4445#define FIND_CLASS(_class, _className)\46if (!NSK_JNI_VERIFY(env, (_class = \47env->FindClass(_className)) != NULL))\48exit(1)4950#define GET_OBJECT_CLASS(_class, _obj)\51if (!NSK_JNI_VERIFY(env, (_class = \52env->GetObjectClass(_obj)) != NULL))\53exit(1)5455#define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\56if (!NSK_JNI_VERIFY(env, (_fieldID = \57env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\58exit(1)5960#define GET_STATIC_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\61if (!NSK_JNI_VERIFY(env, (_fieldID = \62env->GetStaticFieldID(_class, _fieldName, _fieldSig)) != NULL))\63exit(1)6465#define GET_STATIC_BOOL_FIELD(_value, _class, _fieldName)\66GET_STATIC_FIELD_ID(field, _class, _fieldName, "Z");\67_value = env->GetStaticBooleanField(_class, field)6869#define GET_STATIC_INT_FIELD(_value, _class, _fieldName)\70GET_STATIC_FIELD_ID(field, _class, _fieldName, "I");\71_value = env->GetStaticIntField(_class, field)7273#define GET_STATIC_OBJ_FIELD(_value, _class, _fieldName, _fieldSig)\74GET_STATIC_FIELD_ID(field, _class, _fieldName, _fieldSig);\75_value = env->GetStaticObjectField(_class, field)7677#define GET_INT_FIELD(_value, _obj, _class, _fieldName)\78GET_FIELD_ID(field, _class, _fieldName, "I");\79_value = env->GetIntField(_obj, field)8081#define SET_INT_FIELD(_obj, _class, _fieldName, _newValue)\82GET_FIELD_ID(field, _class, _fieldName, "I");\83env->SetIntField(_obj, field, _newValue)8485#define SET_STATIC_INT_FIELD(_class, _fieldName, _newValue)\86GET_STATIC_FIELD_ID(field, _class, _fieldName, "I");\87env->SetStaticIntField(_class, field, _newValue)8889#define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\90GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\91_value = env->GetObjectField(_obj, field)9293#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\94if (!NSK_JNI_VERIFY(env, (_methodID = \95env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\96exit(1)9798#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\99if (!NSK_JNI_VERIFY(env, (_methodID = \100env->GetMethodID(_class, _methodName, _sig)) != NULL))\101exit(1)102103#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\104GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\105if (!NSK_JNI_VERIFY_VOID(env, env->CallStaticVoidMethod(_class, method)))\106exit(1)107108#define CALL_STATIC_VOID(_class, _methodName, _sig, _param)\109GET_STATIC_METHOD_ID(method, _class, _methodName, _sig);\110if (!NSK_JNI_VERIFY_VOID(env, env->CallStaticVoidMethod(_class, method, _param)))\111exit(1)112113#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\114GET_METHOD_ID(method, _class, _methodName, "()V");\115if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method)))\116exit(1)117118#define CALL_VOID(_obj, _class, _methodName, _sig, _param)\119GET_METHOD_ID(method, _class, _methodName, _sig);\120if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method, _param)))\121exit(1)122123#define MONITOR_ENTER(x) \124NSK_JNI_VERIFY(env, env->MonitorEnter(x) == 0)125126#define MONITOR_EXIT(x) \127NSK_JNI_VERIFY(env, env->MonitorExit(x) == 0)128129#endif /* _IS_NSK_STRACE_DEFINED_ */130131132