diff --git a/ddprof-lib/src/main/cpp/profiler.cpp b/ddprof-lib/src/main/cpp/profiler.cpp index 5f83a14d..767e0b6b 100644 --- a/ddprof-lib/src/main/cpp/profiler.cpp +++ b/ddprof-lib/src/main/cpp/profiler.cpp @@ -88,6 +88,7 @@ static inline int makeFrame(ASGCT_CallFrame *frames, jint type, void Profiler::addJavaMethod(const void *address, int length, jmethodID method) { + printf("Add compiled method: %ld\n", (long)method); CodeHeap::updateBounds(address, (const char *)address + length); } diff --git a/ddprof-lib/src/main/cpp/vmEntry.cpp b/ddprof-lib/src/main/cpp/vmEntry.cpp index 47fc4d4f..9dd704ba 100644 --- a/ddprof-lib/src/main/cpp/vmEntry.cpp +++ b/ddprof-lib/src/main/cpp/vmEntry.cpp @@ -390,6 +390,7 @@ bool VM::initProfilerBridge(JavaVM *vm, bool attach) { capabilities.can_generate_compiled_method_load_events = 1; capabilities.can_generate_monitor_events = 1; capabilities.can_tag_objects = 1; + capabilities.can_generate_method_entry_events = 1; _jvmti->AddCapabilities(&capabilities); @@ -405,6 +406,8 @@ bool VM::initProfilerBridge(JavaVM *vm, bool attach) { callbacks.SampledObjectAlloc = ObjectSampler::SampledObjectAlloc; callbacks.GarbageCollectionFinish = LivenessTracker::GarbageCollectionFinish; callbacks.NativeMethodBind = ddprof::VMStructs::NativeMethodBind; + callbacks.MethodEntry = MethodEntry; + _jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); _jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); @@ -415,6 +418,8 @@ bool VM::initProfilerBridge(JavaVM *vm, bool attach) { JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL); _jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + _jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL); + if (hotspot_version() == 0 || !CodeHeap::available()) { // Workaround for JDK-8173361: avoid CompiledMethodLoad events when possible diff --git a/ddprof-lib/src/main/cpp/vmEntry.h b/ddprof-lib/src/main/cpp/vmEntry.h index 2047193d..a9d82386 100644 --- a/ddprof-lib/src/main/cpp/vmEntry.h +++ b/ddprof-lib/src/main/cpp/vmEntry.h @@ -180,7 +180,13 @@ class VM { static void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jclass klass) { - loadMethodIDs(jvmti, jni, klass); +// loadMethodIDs(jvmti, jni, klass); + } + + static void JNICALL MethodEntry(jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method) { } static jvmtiError JNICALL