【发布时间】:2016-06-21 08:30:24
【问题描述】:
我一直在尝试运行 jdb 以尝试将其附加到我的 android 设备上的进程。
我试过的命令如下:
adb forward tcp:12345 jdwp:4127
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=12345
我们可以假设 pid 为 4127 的进程还活着。
但是,输入2条命令后,我收到如下错误信息:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:130)
at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066)
我注意到一个奇怪的行为,即仅当我的 1 个应用程序正在运行时才会出现此输出。这可能是由于程序运行时线程或进程或端口的冲突造成的吗?
当我关闭该特定应用程序时,我大部分时间都可以获得以下输出:
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> Input stream closed.
我还尝试通过以下步骤在管理员模式下运行命令提示符:
netsh advfirewall set global StatefulFTP disable
adb forward tcp:12345 jdwp:4127
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=12345
输出如下:
java.io.IOException: handshake failed - connection prematurally closed
at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:136)
at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066)
Fatal error:
Unable to attach to target VM.
【问题讨论】: