4

I have a native C++ app which is supposed to run on an Android device. The application crashes at the startup, most likely when calling a function from a linked library. I am trying to debug it with gdb, but I can't succeed.

I am starting gdbserver on the Android device on some arbitrarily picked port (2000):

shell@msm8996: gdbserver :2000 my_app
Process my_app created; pid = 3420
Listening on port 2000

Now I am trying to attach to this process on my Host system (Windows 7) with gdb that was provided in Android-NDK.

C:\> gdb
(gdb) attach 3420
Can't attach to process.
(gdb) target remote :2000
:2000: The system tried to join a drive to a directory on a joined drive.

What is the problem?

EDIT: Prior to running gdb I forwarded the port 2000 using adb:

adb forward tcp:2000 tcp:2000

This at least helped me to establish some communication, but:

(gdb) target remote :2000
Remote debugging using :2000
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 00000000000000000000000000000... 

On the device side:

Listening on port 2000
Remote debugging from host 127.0.0.1
readchar: Got EOF
Remote side has terminated connection.  GDBserver will reopen the connection.
Listening on port 2000

1 Answer 1

3

You are most probably using different architecture / version of gdb. When you start the gdb, it displays a line like (I am showing what my GDB shows):

This GDB was configured as "--host=x86_64-linux-gnu --target=arm-Linux-android"

Check if this matches with your phone's architecture.
Downloading the correct GDB version may solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.