Next step – SystemTap java hotspot jstack() support
Just checked in support for getting java backtraces from hotspot through systemtap. This is the next step in making not just the kernel and native programs observable, but also runtime based languages with SystemTap. And it is pretty powerful. It allows you to answer the question “How did I get here?” in combination with any of the SystemTap tapsets for VM level tracing, Java method entry/exit tracing, Native methods (JNI) tracing, or any other basic SystemTap function, statement or process probe that points into your java process. Just add one of the print_jstack()
variants to your code (possibly including native frame and method signatures) and suddenly it is really easy to see what triggered a particular code path:
$ stap -e 'probe hotspot.jni.CallObjectMethod { log (probestr); print_jstack() }' -c 'java ModalTest'
CallObjectMethod(env=0x7f9d1000a1b8,obj=0x7f9d73efcaf8,methodid=0x7f9de4088b70)
sun/font/FontManager.getFont2D
sun/java2d/SunGraphics2D.checkFontInfo
sun/java2d/SunGraphics2D.getFontInfo
sun/java2d/pipe/GlyphListPipe.drawString
sun/java2d/SunGraphics2D.drawString
sun/swing/SwingUtilities2.drawString
sun/swing/SwingUtilities2.drawStringUnderlineCharAt
javax/swing/plaf/basic/BasicGraphicsUtils.drawStringUnderlineCharAt
sun/awt/X11/XButtonPeer.paintText
sun/awt/X11/XButtonPeer.paint
sun/awt/X11/XButtonPeer.paint
sun/awt/X11/XRepaintArea.paintComponent
sun/awt/RepaintArea.paint
sun/awt/X11/XComponentPeer.handleEvent
java/awt/Component.dispatchEventImpl
java/awt/Component.dispatchEvent
java/awt/EventQueue.dispatchEvent
java/awt/EventDispatchThread.pumpOneEventForFilters
java/awt/EventDispatchThread.pumpEventsForFilter
java/awt/EventDispatchThread.pumpEventsForFilter
java/awt/Dialog$1.run
java/awt/event/InvocationEvent.dispatch
java/awt/EventQueue.dispatchEvent
java/awt/EventDispatchThread.pumpOneEventForFilters
java/awt/EventDispatchThread.pumpEventsForFilter
java/awt/EventDispatchThread.pumpEventsForHierarchy
java/awt/EventDispatchThread.pumpEvents
java/awt/EventDispatchThread.pumpEvents
java/awt/EventDispatchThread.run
You currently need both IcedTea6 from mercurial and Systemtap from git to play with it. But both projects are planning new releases soon.