Unable to enable DTrace tests via jinfo on Mac OS X

Running Java 6 on Snow Leopard.

It is assumed that you enable ExtendedDTraceProbes in a running Java process using the jinfo utility . Even the jinfo command line says to enable common flags:

Usage: jinfo [option] <pid> (to connect to running process) ... where <option> is one of: -flag [+|-]<name> to enable or disable the named VM flag 

And as far as I know, DTrace flags do not really matter, it only matters their presence or absence.

But when I try to do this, I get one of two errors, depending on whether I predict it with sudo or not.

Assuming:
Jps

 1234 StayRunning ... 

The same user as the StayRunning process:
jinfo -flag + ExtendedDTraceProbes 1234

 Exception in thread "main" java.io.IOException: Command failed in target VM at sun.tools.attach.MacosxVirtualMachine.execute(MacosxVirtualMachine.java:200) at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:195) at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:172) at sun.tools.jinfo.JInfo.flag(JInfo.java:111) at sun.tools.jinfo.JInfo.main(JInfo.java:58) 

Trying as root:
sudo jinfo -flag + ExtendedDTraceProbes 1234

 Password: (which I enter) 1234: Unable to open socket file: target process not responding or HotSpot VM not loaded 

the error is on the second line, and, of course, the process is still running.

Oddly enough, this page does not show the "+" option for OS X , but my own computer prints a usage message.

Here is my simple code. It does not work like Eclipse.

StayRunning.java

 class StayRunning { public static void main( String [] args ) throws Exception { long counter = 0L; while( true ) { Thread.sleep( 1000 ); counter++; System.out.println( "tick "+counter ); } } } 
+4
source share
1 answer

You are right that this probe is one that can be “installed” or “not installed” (that is, no specific “value” is associated with it).

This is almost certainly a (long-standing) bug in the JVM Hotspot, and not unique to OSX. Here is a report from someone who cannot set VM flags via jinfo on Windows:

http://www.herongyang.com/Java-Tools/jstack-jinfo-Change-HotSpot-VM-Option.html

I can provide first-hand experience of the inability to dynamically extend ExtendedDTraceProbes and (for science!) Several other flags using jinfo on Linux. In fact, after several attempts, I could not find a flag that could set dynamically.

I came across the corresponding error on Sun / Oracle:

http://bugs.sun.com/view_bug.do;jsessionid=24c1d7e1b0cda2ffffffff97aef6bbd818cf2?bug_id=6445836

Most interestingly, in the Evaluation section: “jinfo -flag is a temporary solution that allows DTrace dynamic probes dynamically. As Mandy said, this should go away.”

Based on this, as well as my own past experience with Hotspot documentation, which is very outdated and / or inaccurate, I suspect that, despite the / manpage documentation for jinfo, as well as the documentation for the probes themselves (http: // download. oracle.com/javase/6/docs/technotes/guides/vm/dtrace.html), indicating otherwise that some implementation details in Hotspot have been changed to make the dynamic configuration of this flag impossible or impractical that it has been disabled. In other words, this is a mistake that will not be fixed.

+3
source

Source: https://habr.com/ru/post/1338336/


All Articles