今天在使用jsadebugd调试core文件的时候又报错了:
Error attaching to core file or starting server: sun.jvm.hotspot.debugger.DebuggerException: Can’t attach to the core file
堆栈如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ jsadebugd java core.48296 TempServer Attaching to core core.48296 from executable java and starting RMI services, please wait... Error attaching to core file or starting server: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the core file at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native Method) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:276) at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:604) at sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:565) at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:338) at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:313) at sun.jvm.hotspot.HotSpotAgent.startServer(HotSpotAgent.java:249) at sun.jvm.hotspot.DebugServer.run(DebugServer.java:110) at sun.jvm.hotspot.DebugServer.main(DebugServer.java:45) at sun.jvm.hotspot.jdi.SADebugServer.main(SADebugServer.java:55) |
之前碰到这个报错的时候甚至去看了jdk的源码,但还是一无所获。今天灵光一现,通过分析和不断尝试,大致可以总结出有以下几个原因:
1.core文件损坏
2.调试的command不正确,这个工具的使用格式是这样的:
1 |
jsadebugd executable core [ server-id ] |
executable必须是java的全路径,而不能是java。
所以这样使用是会报错的:
1 |
jsadebugd java core.48296 TempServer |
正确的使用方式是:
1 |
jsadebugd /usr/local/jdk/jre/bin/java core.28225 TempServer |
3.调试用的jdk版本和当时出core的jdk版本[……]