diff --git a/agent/src/ebpf/Makefile b/agent/src/ebpf/Makefile index dc41dcf1c35..a91ccbc5f74 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); } diff --git a/agent/src/ebpf/user/profile/stringifier.c b/agent/src/ebpf/user/profile/stringifier.c index 2a977d0a6fa..3ca05c38a31 100644 --- a/agent/src/ebpf/user/profile/stringifier.c +++ b/agent/src/ebpf/user/profile/stringifier.c @@ -374,7 +374,7 @@ static inline int symcache_resolve(pid_t pid, void *resolver, u64 address, */ char format_str[4096]; snprintf(format_str, sizeof(format_str), - "[%s]", sym->module); + "[%s 0x%016lx]", sym->module, address); int len = strlen(format_str); *sym_ptr = create_symbol_str(len, format_str, "");