# include "precompiled.hpp" # include "memory/resourceArea.hpp" # include "utilities/macros.hpp" #if INCLUDE_JVMTI # include "logging/log.hpp" # include "oops/oop.inline.hpp" # include "prims/jvmtiEnter.hpp" # include "prims/jvmtiRawMonitor.hpp" # include "prims/jvmtiUtil.hpp" # include "runtime/threadSMR.hpp" #ifdef JVMTI_TRACE // Error names const char* JvmtiUtil::_error_names[] = { }; // Event threaded const bool JvmtiUtil::_event_threaded[] = { }; jbyte JvmtiTrace::_event_trace_flags[ ]; jint JvmtiTrace::_max_event_index = ; // Event names const char* JvmtiTrace::_event_names[] = { }; #endif /*JVMTI_TRACE */ // names const char* ConstantNames[] = { NULL }; // value jint ConstantValues[] = { 0 }; " ", , // Check Event Capabilities const bool JvmtiUtil::has_event_capability(jvmtiEvent event_type, const jvmtiCapabilities* capabilities_ptr) { switch (event_type) { case : return capabilities_ptr-> != 0; default: break; } // if it does not have a capability it is required return JNI_TRUE; } jbyte JvmtiTrace::_trace_flags[ ]; jint JvmtiTrace::_max_function_index = ; // Function names const char* JvmtiTrace::_function_names[] = { }; // Exclude list short JvmtiTrace::_exclude_functions[] = { 0 }; extern "C" { } /* end extern "C" */ // JVMTI API functions struct jvmtiInterface_1_ jvmti _Interface = { }; #endif // INCLUDE_JVMTI jvmti _ /* : */ RESERVED */ NULL , " " NULL , false true false , , // // functions // if (this_thread == NULL || !this_thread->is_Java_thread()) { if (this_thread == NULL || (!this_thread->is_Java_thread() && !this_thread->is_VM_thread())) { if (!this_thread->is_Java_thread()) { if (trace_flags) { log_trace(jvmti)("[non-attached thread] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_UNATTACHED_THREAD)); } return JVMTI_ERROR_UNATTACHED_THREAD; } JavaThread* current_thread = (JavaThread*)this_thread; ThreadInVMfromNative __tiv(current_thread); VM_ENTRY_BASE(jvmtiError, , current_thread) debug_only(VMNativeEntryWrapper __vew;) CautiouslyPreserveExceptionMark __em(this_thread); if (jvmti_env->get_capabilities()-> == 0) { if (trace_flags) { log_trace(jvmti)("[%s] %s %s", curr_thread_name, func_name, JvmtiUtil::error_name(JVMTI_ERROR_MUST_POSSESS_CAPABILITY)); } return JVMTI_ERROR_MUST_POSSESS_CAPABILITY; } static jvmtiError JNICALL (jvmtiEnv* env ) { #if !INCLUDE_JVMTI return JVMTI_ERROR_NOT_AVAILABLE; #else if(!JvmtiEnv::is_vm_live()) { if (trace_flags) { log_trace(jvmti)("[-] %s %s(%d)", func_name, JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE), JvmtiEnv::get_phase()); } return JVMTI_ERROR_WRONG_PHASE; } Thread* this_thread = Thread::current_or_null(); if(JvmtiEnv::get_phase()!=JVMTI_PHASE_ONLOAD && JvmtiEnv::get_phase()!=JVMTI_PHASE_LIVE ) { if (trace_flags) { log_trace(jvmti)("[-] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE)); } return JVMTI_ERROR_WRONG_PHASE; } if(JvmtiEnv::get_phase(env)!=JVMTI_PHASE_START && JvmtiEnv::get_phase()!=JVMTI_PHASE_LIVE) { if (trace_flags) { log_trace(jvmti)("[-] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE)); } return JVMTI_ERROR_WRONG_PHASE; } Thread* this_thread = Thread::current_or_null(); JvmtiEnv* jvmti_env = JvmtiEnv::JvmtiEnv_from_jvmti_env(env); if (!jvmti_env->is_valid()) { if (trace_flags) { log_trace(jvmti)("[%s] %s %s env=" PTR_FORMAT, curr_thread_name, func_name, JvmtiUtil::error_name(JVMTI_ERROR_INVALID_ENVIRONMENT), p2i(env)); } return JVMTI_ERROR_INVALID_ENVIRONMENT; } jvmtiError err; if (Threads::number_of_threads() != 0) { Thread* this_thread = Thread::current_or_null(); Thread* this_thread = NULL; bool transition; if (Threads::number_of_threads() == 0) { transition = false; } else { this_thread = Thread::current_or_null(); transition = ((this_thread != NULL) && !this_thread->is_VM_thread() && !this_thread->is_ConcurrentGC_thread()); } if (transition) { } else { } return err; #endif // INCLUDE_JVMTI } err = jvmti_env-> ( ); SafeResourceMark rm; jint trace_flags = JvmtiTrace::trace_flags( ); const char *func_name = NULL; const char *curr_thread_name = NULL; if (trace_flags) { func_name = JvmtiTrace::function_name( ); curr_thread_name = JvmtiTrace::safe_get_current_thread_name(); } if ((trace_flags & JvmtiTrace::SHOW_IN) != 0) { } if ((trace_flags & JvmtiTrace::SHOW_ERROR) != 0) { if ((trace_flags & JvmtiTrace::SHOW_IN) == 0) { } log_error(jvmti)("[%s] %s } %s - erroneous arg is ", curr_thread_name, func_name, JvmtiUtil::error_name( ) ); } return ; if ( err != JVMTI_ERROR_NONE && (trace_flags & JvmtiTrace::SHOW_ERROR) != 0) { if ((trace_flags & JvmtiTrace::SHOW_IN) == 0) { } log_error(jvmti)("[%s] %s } %s", curr_thread_name, func_name, JvmtiUtil::error_name(err)); } else if ((trace_flags & JvmtiTrace::SHOW_OUT) != 0) { log_trace(jvmti)("[%s] %s }", curr_thread_name, func_name); } log_trace(jvmti)("[%s] %s { ", curr_thread_name, func_name ); if ( == NULL) { JVMTI_ERROR_NULL_POINTER } JvmtiRawMonitor *rmonitor = (JvmtiRawMonitor *) ; if (rmonitor == NULL) { JVMTI_ERROR_INVALID_MONITOR - raw monitor is NULL } if (!rmonitor->is_valid()) { JVMTI_ERROR_INVALID_MONITOR - not a raw monitor " PTR_FORMAT " , p2i(rmonitor) } err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), , &java_thread, NULL); if (err != JVMTI_ERROR_NONE) { err - jthread did not convert to a JavaThread - jthread = " PTR_FORMAT " , p2i() } JavaThread* java_thread = NULL; ThreadsListHandle tlh(this_thread); if ( == NULL) { java_thread = current_thread; } else { } if (depth < 0) { JVMTI_ERROR_ILLEGAL_ARGUMENT - negative depth - jthread = " INT32_FORMAT " , } oop k_mirror = JNIHandles::resolve_external_guard( ); if (k_mirror == NULL) { JVMTI_ERROR_INVALID_CLASS - resolved to NULL - jclass = " PTR_FORMAT " , p2i() } if (!k_mirror->is_a(SystemDictionary::Class_klass())) { JVMTI_ERROR_INVALID_CLASS - not a class - jclass = " PTR_FORMAT " , p2i() } if (java_lang_Class::is_primitive(k_mirror)) { JVMTI_ERROR_INVALID_CLASS - is a primitive class - jclass = " PTR_FORMAT " , p2i() } Klass* k_oop = java_lang_Class::as_Klass(k_mirror); if (k_oop == NULL) { JVMTI_ERROR_INVALID_CLASS - no Klass* - jclass = " PTR_FORMAT " , p2i() } Method* method_oop = Method::checked_resolve_jmethod_id( ); if (method_oop == NULL) { JVMTI_ERROR_INVALID_METHODID } if (method_oop->is_native()) { return JVMTI_ERROR_NATIVE_METHOD; } ResourceMark rm_fdesc(current_thread); fieldDescriptor fdesc; if (!JvmtiEnv::get_field_descriptor(k_oop, , &fdesc)) { JVMTI_ERROR_INVALID_FIELDID } if ( < ) { JVMTI_ERROR_ILLEGAL_ARGUMENT } g ='%s' =" PTR_FORMAT " , p2i() =" PTR_FORMAT " , p2i() =" PTR_FORMAT " , p2i() =%s =%s , rmonitor->get_name() =%s , JvmtiTrace::safe_get_thread_name(java_thread) depth=%d , , JvmtiTrace::get_class_name(k_mirror) =%s.%s , method_oop == NULL? "NULL" : method_oop->klass_name()->as_C_string(), method_oop == NULL? "NULL" : method_oop->name()->as_C_string() , fdesc.name()->as_C_string() =%d:%s , , JvmtiUtil::error_name( ) JvmtiTrace::event_name( ) JvmtiTrace::enum_name( ConstantNames, ConstantValues, ) =" INT32_FORMAT " =" JLONG_FORMAT " =" JLONG_FORMAT " =" SIZE_FORMAT_HEX " =%f =%c =0x%x , =%s , ? "true" : "false"