【发布时间】:2011-02-03 23:19:04
【问题描述】:
在 Snow Leopard 上运行 Java 6。
您应该能够turn on ExtendedDTraceProbes on a running Java process with the jinfo utility。即使在我的命令提示符 jinfo 谈到启用通用标志:
Usage:
jinfo [option] <pid>
(to connect to running process)
...
where <option> is one of:
-flag [+|-]<name> to enable or disable the named VM flag
据我所知,DTrace 标志没有任何特殊价值,重要的是它们的存在与否。
但是当我尝试这样做时,我会遇到两个错误之一,这取决于我是否以 sudo 开头。
假设:
jps
1234 StayRunning
...
与 StayRunning 进程相同的用户:
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)
以 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
错误在第二行,当然进程还在运行。
奇怪的是,this page doesn't show the "+" option for OS X,但我自己的机器打印出了使用信息。
这是我的简单代码。它与 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 );
}
}
}
【问题讨论】:
-
这个问题有风滚草。 :-( 很多开发人员都使用 Mac,所以我很惊讶没有其他人看到这个?或者也许你们都有同样的问题并且还在等待答案?嗯......好吧,如果你有问题,请至少评论!痛苦爱陪伴你知道的。
标签: java debugging macos dtrace jinfo