diff --git a/agent/src/ebpf/Makefile b/agent/src/ebpf/Makefile index 10d4421f710..6233b06ef55 100644 --- a/agent/src/ebpf/Makefile +++ b/agent/src/ebpf/Makefile @@ -102,7 +102,7 @@ OBJS := user/elf.o \ user/profile/java/collect_symbol_files.o JAVA_TOOL := deepflow-jattach -JAVA_AGENT_VERSION := 2 +JAVA_AGENT_VERSION := 3 JAVA_AGENT_GNU_SO := df_java_agent_v$(JAVA_AGENT_VERSION).so JAVA_AGENT_MUSL_SO := df_java_agent_musl_v$(JAVA_AGENT_VERSION).so JAVA_AGENT_SO := $(JAVA_AGENT_GNU_SO) $(JAVA_AGENT_MUSL_SO) diff --git a/agent/src/ebpf/user/profile/java/symbol_collect_agent.c b/agent/src/ebpf/user/profile/java/symbol_collect_agent.c index 7b91e117e82..c5769c1a048 100644 --- a/agent/src/ebpf/user/profile/java/symbol_collect_agent.c +++ b/agent/src/ebpf/user/profile/java/symbol_collect_agent.c @@ -377,9 +377,30 @@ void generate_single_entry(enum event_type type, jvmtiEnv * jvmti, } else { memcpy(class_name, csig, sizeof(class_name) - 1); } - snprintf(output, noutput, "%s::%s%s", class_name, - method_name, method_signature); + char *source_file = NULL; + jvmtiError err = + (*jvmti)->GetSourceFileName(jvmti, class, &source_file); + if (err != JVMTI_ERROR_NONE) { + source_file = NULL; + } + + jint entry_count = 0; + jvmtiLineNumberEntry *table = NULL; + int line_number = -1; + err = + (*jvmti)->GetLineNumberTable(jvmti, method, &entry_count, + &table); + if (err == JVMTI_ERROR_NONE && entry_count > 0 && table != NULL) { + line_number = table[0].line_number; + } + + snprintf(output, noutput, "%s::%s%s[%s:%d]", class_name, + method_name, method_signature, + source_file == NULL ? "" : source_file, line_number); + + deallocate(jvmti, (unsigned char *)table); + deallocate(jvmti, (unsigned char *)source_file); deallocate(jvmti, (unsigned char *)csig); }