I just get trouble to use ndk-gdb to debug my native application. This is my environment:
- OS X El Captain 10.11.5
- NDK version r12
- SDK version 24
- Build tool version 24.0.0
- Device Nexus 6P with Android N (NPD35K)
The issue:
When I was going to launch ndk-gdb
it always fail with the message
Error: unable to connect to device.
Remote connection closed
However, the gdbserver
instance has already been launched since my app is paused and I could see the gdbserver
in adb shell ps
list.
What I have tried:
- Instead of start
gdbserver
by thendk-gdb
script, I launched thegdbserver
manually byadb run-as
and make sure thegdbserver
keeps running Make a socket forward by
adb forward :5039 localfilesystem:/the_gdb_socket_path
Use
netstat -na | grep 5309
to make sure the port is being listening- Use
telnet localhost 5039
to test socket but get the errorConnection closed by foreign host
Is there any better way to identify where the issue cause the remote gdb failed on connection?