性能问答>使用sa-jdi core dump class文件报错>
2回复
1年前

使用sa-jdi core dump class文件报错



最近看到笨神之前写的一篇文章《从一起GC血案谈到反射原理》,于是想在自己电脑上实践一下利用sa-jdi来dump运行时进程的class文件

但是在执行dump命令的时候报错了,信息如下:

Attaching to process ID 34755, please wait...
ERROR: attach: task_for_pid(34755) failed: '(os/kern) failure' (5)
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process. Could be caused by an incorrect pid or lack of privileges.
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process. Could be caused by an incorrect pid or lack of privileges.
	at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal$BsdDebuggerLocalWorkerThread.execute(BsdDebuggerLocal.java:169)
	at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.attach(BsdDebuggerLocal.java:287)
	at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:671)
	at sun.jvm.hotspot.HotSpotAgent.setupDebuggerDarwin(HotSpotAgent.java:659)
	at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:341)
	at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304)
	at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)
	at sun.jvm.hotspot.tools.Tool.start(Tool.java:185)
	at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
	at sun.jvm.hotspot.tools.jcore.ClassDump.main(ClassDump.java:180)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process. Could be caused by an incorrect pid or lack of privileges.
	at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.attach0(Native Method)
	at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.access$100(BsdDebuggerLocal.java:65)
	at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal$1AttachTask.doit(BsdDebuggerLocal.java:278)
	at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal$BsdDebuggerLocalWorkerThread.run(BsdDebuggerLocal.java:144)

执行的命令为

sudo java -classpath .:$JAVA_HOME/lib/sa-jdi.jar -Dsun.jvm.hotspot.tools.jcore.filter=MethodAccessorFilter  -Dsun.jvm.hotspot.tools.jcore.outputDir=/Users/martin/Downloads  sun.jvm.hotspot.tools.jcore.ClassDump 34755

google了一下这个报错 有说是JDK BUG的 也有说权限不足的,权限问题我这都用sudo执行了 不知道还有什么权限需要满足,JDK BUG的话 又不想升级JDK版本,因为毕竟现在主流还是1.8的版本

希望有了解的大佬指教一下

2656 阅读
请先登录,查看2条精彩评论吧
快去登录吧,你将获得
  • 浏览更多精彩评论
  • 和开发者讨论交流,共同进步