简体   繁体   English

分离后可以将调试器附加到Java进程吗?

[英]Can you attach a debugger to a Java process after detaching?

If you run a java process with arguments -Xdebug -agentlib:jdwp=transport=dt_socket,suspend=n,server=y,address=9000 , the process stops listening on the port once the debugger attaches to it. 如果使用参数-Xdebug -agentlib:jdwp=transport=dt_socket,suspend=n,server=y,address=9000运行Java进程,则调试器连接到该端口后,该进程将停止侦听该端口。 Then, once the debugger detaches, you can't connect to it again. 然后,调试器分离后,您将无法再次连接。 Is there any way to attach the debugger once it has been detached? 调试器拆离后,是否可以附加任何方法? Or is there a jdwp proxy server that is always attached to the process and allows the debugger to attach and detach at will? 还是有一个始终附在进程中的jdwp代理服务器,并允许调试器随意附加和分离?

Short answer is yes, you should be able to just reattach. 简短的回答是,您应该可以重新连接。 There should be no problems doing this. 这样做应该没有问题。 There might be a race condition if multiple applications try to bind to the same port during detach/attach, but I don't see any other possible issues. 如果在分离/附加期间多个应用程序尝试绑定到同一端口,则可能会出现争用情况,但是我看不到任何其他可能的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM