eunomia-bpf / bpf-developer-tutorial

eBPF Developer Tutorial: Learning eBPF Step by Step with Examples
https://eunomia.dev/tutorials/
MIT License
2.43k stars 348 forks source link

USDT java guide #78

Open sebastiaoamaro opened 11 months ago

sebastiaoamaro commented 11 months ago

Hi everyone, I was following the guide in [1], however, when attaching the usdt it fails with the error:

libbpf: usdt: no USDT notes section (.note.stapsdt) found in '/usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so'

Which I believe to be caused by not having dtrace enabled in the JVM, however, I can not find any guide/tutorial to enabling it. Sorry for the unrelated question to eBPF, but did you enable anything to run java USDT? or use a specific java version?

Thanks in advance. [1]https://github.com/eunomia-bpf/bpf-developer-tutorial/tree/main/src/15-javagc

lcxjy commented 7 months ago

我也遇到了这个问题,但是并没有找到解决方法 "I have also encountered this problem, but have not found a solution yet."

fuwx295 commented 2 months ago

@lcxjy @sebastiaoamaro USDT requires JDK support (set --enable-dtrace when compiling the JVM) To determine whether the current JDK supports USDT, enter the following command

readelf -n /path/to/openjdk/lib/server/libjvm.so

If it does, the following message will be displayed, otherwise, it means that the current JDK does not support USDT.

stapsdt              0x0000002f       NT_STAPSDT (SystemTap probe descriptors)
    Provider: hotspot
    Name: thread__yield
    Location: 0x000000000098745b, Base: 0x000000000107e7f4, Semaphore: 0x0000000000000000
    Arguments: 
  stapsdt              0x0000003d       NT_STAPSDT (SystemTap probe descriptors)
    Provider: hotspot
    Name: thread__sleep__begin
    Location: 0x000000000098ff64, Base: 0x000000000107e7f4, Semaphore: 0x0000000000000000
    Arguments: -8@%r12
  stapsdt              0x00000039       NT_STAPSDT (SystemTap probe descriptors)
    Provider: hotspot
    Name: thread__sleep__end
    Location: 0x000000000098ffa3, Base: 0x000000000107e7f4, Semaphore: 0x0000000000000000
    Arguments: -4@$0
  stapsdt              0x00000039       NT_STAPSDT (SystemTap probe descriptors)
    Provider: hotspot
    Name: thread__sleep__end
    Location: 0x0000000000990100, Base: 0x000000000107e7f4, Semaphore: 0x0000000000000000
    Arguments: -4@$1