2

I'm trying to map Java Thread to OS thread within JVMTI. In JVMTI, all I could grab is Java Thread object leveraging GetCurrentThread. But I want to know which OS thread this jthread is mapping to.

I was told that there is a field in Hotspot, eetop, which is a pointer to the underlying OS-level native thread instance of the JVM(ref: hotspot/src/share/vm/classfile/javaClasses.cpp).

How do I use this field to finish the mapping?

This magic is also being performed in async-profiler at src/vmStructs.cpp line 364. Why it works? enter image description here

boneill
  • 1,478
  • 1
  • 11
  • 18
  • 2
    If your JVMTI agent subscribes to `ThreadStart` event, you can create your own jthread->os_thread_id mapping in `ThreadStart` handler. – apangin Dec 19 '22 at 14:00
  • @apangin I think I've understood the code in async-profiler about `initThreadBridge`. Thank you. – OnePair3Can'tPay Dec 26 '22 at 02:08

0 Answers0