3

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:

  1. Instead of start gdbserver by the ndk-gdb script, I launched the gdbserver manually by adb run-as and make sure the gdbserver keeps running
  2. Make a socket forward by adb forward :5039 localfilesystem:/the_gdb_socket_path

  3. Use netstat -na | grep 5309 to make sure the port is being listening

  4. Use telnet localhost 5039 to test socket but get the error Connection closed by foreign host

Is there any better way to identify where the issue cause the remote gdb failed on connection?

jayatubi
  • 1,972
  • 1
  • 21
  • 51

1 Answers1

1

In my case, I had to root the phone to fix that connection issue, see: Does ndk-gdb work under macOS Sierra?

kakyo
  • 10,460
  • 14
  • 76
  • 140