1 /* 2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 #ifndef NSK_SHARE_JVMTI_AOD_H 24 #define NSK_SHARE_JVMTI_AOD_H 25 26 #include <aod.h> 27 #include <jvmti.h> 28 #include <jvmti_tools.h> 29 30 extern "C" { 31 32 #define MAX_STRING_LENGTH 1024 33 34 #define PATH_TO_NEW_BYTE_CODE_OPTION "-pathToNewByteCode" 35 36 void nsk_jvmti_aod_disableEventAndFinish(const char* agentName, jvmtiEvent event, int success, jvmtiEnv *jvmti, JNIEnv* jni); 37 38 void nsk_jvmti_aod_disableEventsAndFinish(const char* agentName, jvmtiEvent events[], int eventsNumber, int success, jvmtiEnv *jvmti, JNIEnv* jni); 39 40 /* 41 * Functions which can be used to work with stored agents options when several 42 * agents using the same libary are attached (agents are identified by its jvmti environment) 43 */ 44 45 #define MAX_MULTIPLE_AGENTS 10 46 47 int nsk_jvmti_aod_addMultiagentsOptions(jvmtiEnv *agentEnv, Options *options); 48 49 Options* nsk_jvmti_aod_getMultiagentsOptions(jvmtiEnv *agentEnv); 50 51 /* 52 * Auxiliary functions 53 */ 54 55 void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem); 56 57 /* 58 * Get class name of the given class and copy it to the given buffer, 59 * it attempt to get class name fails buffer contains zero-length string for safety. 60 */ 61 int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuffer[]); 62 63 /* 64 * Get name of the given thread and copy it to the given buffer, 65 * it attempt to get thread name fails buffer contains zero-length string for safety. 66 */ 67 int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNameBuffer[]); 68 69 // events enabling/disabling 70 71 #define nsk_jvmti_aod_enableEvent(X,Y) NSK_JVMTI_VERIFY( NSK_CPP_STUB4(SetEventNotificationMode, X, JVMTI_ENABLE, Y, NULL)) 72 #define nsk_jvmti_aod_disableEvent(X,Y) NSK_JVMTI_VERIFY( NSK_CPP_STUB4(SetEventNotificationMode, X, JVMTI_DISABLE, Y, NULL)) 73 74 int nsk_jvmti_aod_enableEvents(jvmtiEnv* jvmti, jvmtiEvent events[], int eventsNumber); 75 int nsk_jvmti_aod_disableEvents(jvmtiEnv* jvmti, jvmtiEvent events[], int eventsNumber); 76 77 // java threads creation 78 79 jthread nsk_jvmti_aod_createThread(JNIEnv *jni); 80 81 jthread nsk_jvmti_aod_createThreadWithName(JNIEnv *jni, const char* threadName); 82 83 // class redefinition 84 85 int nsk_jvmti_aod_redefineClass(Options* options, jvmtiEnv* jvmti, jclass classToRedefine, const char* fileName); 86 87 // capabilities 88 89 void printCapabilities(jvmtiCapabilities caps); 90 91 } 92 93 #endif /* END OF NSK_SHARE_JVMTI_AOD_H */