Using ndk-gdb


#1

Hello all.  I have been trying to use ndk-gdb to no avail and I am at a complete loss.  I have no idea what else to try.  I am deploying on an Android 4.4.4 device.  I am using Ant 1.9.4.  NDK r9d (64-bit).  JDK6.  I had originally started trying to debug my app but finally reverted to a simple sample from the JUCE library, HelloWorld.  Baby steps.  I have updated the target API of the project to API-19.  I am able to run ant debug, and install the debug apk.  I can start ndk-gdb and then it all goes to hell.  I have posted in other forums and on SO but noone can help!  Has anyone here successfully been able to debug?  If so, could you maybe clue me in on what my issue is?  Here is the output from the console-- I am not ever able to attach to the process, and the tablet hangs on a waiting for the debugger screen.  I have aso tried this with an NDK sample and I get the same error-- in the command line and in eclipse.

Claudias-MacBook-Pro:Android claudia$ ndk-gdb --force --verbose --start

Android NDK installation path: /Applications/Intel/INDE/Framework/NDK

Using default adb command: /Applications/Intel/INDE/Framework/ADT/sdk/platform-tools/adb

ADB version found: Android Debug Bridge version 1.0.31

Using ADB flags: 

Using JDB command: /usr/bin/jdb

Using auto-detected project path: .

Found package name: com.rawmaterialsoftware.jucehelloworld

ABIs targetted by application: armeabi armeabi-v7a

Device API Level: 19

Device CPU ABIs: x86 armeabi-v7a

Compatible device ABI: armeabi-v7a

Using gdb setup init: ./libs/armeabi-v7a/gdb.setup

Using toolchain prefix: /Applications/Intel/INDE/Framework/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-

Using app out directory: ./obj/local/armeabi-v7a

Found debuggable flag: true

Found data directory: '/data/data/com.rawmaterialsoftware.jucehelloworld'

Found device gdbserver: /data/data/com.rawmaterialsoftware.jucehelloworld/lib/gdbserver

Found first launchable activity: .HelloWorld

Launching activity: com.rawmaterialsoftware.jucehelloworld/.HelloWorld

## COMMAND: adb_cmd shell am start -D -n com.rawmaterialsoftware.jucehelloworld/.HelloWorld

Starting: Intent { cmp=com.rawmaterialsoftware.jucehelloworld/.HelloWorld }

## COMMAND: adb_cmd shell sleep 2

Found running PID: 3640

Launched gdbserver succesfully.

Setup network redirection

## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.rawmaterialsoftware.jucehelloworld/debug-socket

## COMMAND: adb_cmd shell run-as com.rawmaterialsoftware.jucehelloworld /data/data/com.rawmaterialsoftware.jucehelloworld/lib/gdbserver +debug-socket --attach 3640

## COMMAND: adb_cmd pull /system/bin/app_process ./obj/local/armeabi-v7a/app_process

Cannot attach to lwp 3640: Function not implemented (38)


2732 KB/s (12780 bytes in 0.004s)

Exiting

Pulled app_process from device/emulator.

## COMMAND: adb_cmd pull /system/bin/linker ./obj/local/armeabi-v7a/linker

4508 KB/s (183465 bytes in 0.039s)

Pulled linker from device/emulator.

## COMMAND: adb_cmd pull /system/lib/libc.so ./obj/local/armeabi-v7a/libc.so

3089 KB/s (824333 bytes in 0.260s)

Pulled libc.so from device/emulator.

Setup JDB connection

## COMMAND: adb_cmd forward tcp:65534 jdwp:3640

java.io.IOException: handshake failed - connection prematurally closed

    at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:118)

    at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:214)

    at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:98)

    at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:72)

    at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:358)

    at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:168)

    at com.sun.tools.example.debug.tty.Env.init(Env.java:64)

    at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1010)


Fatal error:

Unable to attach to target VM.

GNU gdb (GDB) 7.3.1-gg2

Copyright (C) 2011 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "--host=x86_64-apple-darwin --target=arm-linux-android".

For bug reporting instructions, please see:

<http://source.android.com/source/report-bugs.html>.

./obj/local/armeabi-v7a/gdb.setup:4: Error in sourced command file:

Remote connection closed

(gdb) quit


#2

First the bad news, I haven't successfully debugged a JUCE Android app... The good news is haven't *really* needed to, yet.

If my app works on Windows, it's worked on my Android devices.

Just checking (obvious question - pre-babysteps / crawling) have you managed to *run* (not debug) the simple example?

If not, don't forget to make sure the project is Native {gets me everytime}


#3

I'm currently using ndk-gdb with JUCE, OSX and Android KitKat (NDK 10c) with a Nexus.

If anyone has trouble, I can at least tell you what I did to get it working.

I know Claudia got the project she was working on debugging.

Having a Nexus makes it much easier, she was working with an Intel device and that was fucking her.

Yes, I've also debugging Juce apps on intel Android with ndk-gdb.