From ca5786a6568490dd010a8e3a8648b85fc4a362e6 Mon Sep 17 00:00:00 2001 From: Jiping Yin Date: Sat, 9 May 2026 22:08:44 +0800 Subject: [PATCH 1/2] feat(eBPF): include file name and line number in java method symbols --- agent/src/ebpf/Makefile | 2 +- .../user/profile/java/symbol_collect_agent.c | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) 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); } From 244d87cf25903fbbc77f0612f8d6fbd2d3541605 Mon Sep 17 00:00:00 2001 From: Jiping Yin Date: Thu, 14 May 2026 10:47:07 +0800 Subject: [PATCH 2/2] Add the address if it cannot be resolved --- agent/src/ebpf/user/profile/stringifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, "");