How to attach gdb?

Hi,

I’m currently trying to attach a debugger to an OF application running on my phone. I’ve build the app in Debug mode (in eclipse) and also added android:debuggable=“true” to the manifest file. After launching the app on my phone, I’ve tried to launch gdb:

  
  
$ /c/Development/android-ndk-r6b/ndk-gdb --verbose  
Android NDK installation path: /c/Development/android-ndk-r6b  
Using default adb command: /c/Development/android-sdk/platform-tools/adb.exe  
ADB version found: Android Debug Bridge version 1.0.29  
Using final ADB command: '/c/Development/android-sdk/platform-tools/adb.exe'  
Using auto-detected project path: .  
Found package name: com.brandname.appname  
ABIs targetted by application: armeabi  
Device API Level: 10  
Device CPU ABIs: armeabi-v7a armeabi  
Compatible device ABI: armeabi  
Found debuggable flag: true  
ERROR: Non-debuggable application installed on the target device.  
       Please re-install the debuggable version!  
  

Any clue why it won’t allow me to attach the debugger?

I’ve tried to also apply the techniques used in these posts:

However, it seems like OF isnt using “ndk-build” for building the project, so I’m not sure how to change the build command to “ndk-build NDK_DEBUG=1”

I’m using NDK r6b + SDK target 8.

changing the the manifest to debuggable and building the app in debug mode should do. are you using the version from github develop? the makefiles there generate the correct debug files

I did used the development develop branch of openFramework, rev 0a5f6534b1 .

which android version does your device has? there’s a problem with debugserver not being compatible with >3.0 it could be related to that, i found a compiled version somewhere some time ago but cannot remember where

also some devices like the first samsung tablets had problems debugging because of non standard file system.

I’m using my Google Nexus One with stock FW (Android Gingerbread 2.3.6)

Just did a checkout of the latest dev build from the github. Getting the same problem with the examples:

  
  
Laurence@Austin /e/projects/OF/apps/android/androidEmptyExample  
$ /c/Development/android-ndk-r6b/ndk-gdb --force --start --verbose  
Android NDK installation path: /c/Development/android-ndk-r6b  
Using default adb command: /c/Development/android-sdk/platform-tools/adb.exe  
ADB version found: Android Debug Bridge version 1.0.29  
Using final ADB command: '/c/Development/android-sdk/platform-tools/adb.exe'  
Using auto-detected project path: .  
Found package name: cc.openframeworks.androidEmptyExample  
ABIs targetted by application: armeabi  
Device API Level: 10  
Device CPU ABIs: armeabi-v7a armeabi  
Compatible device ABI: armeabi  
Found debuggable flag: true  
ERROR: Non-debuggable application installed on the target device.  
       Please re-install the debuggable version!  

Perhaps some of the libs are still build in release mode?

Is there a way to use ndk-build NDK_DEBUG=1 though?

Perhaps some of the libs are still build in release mode?

yes but that doesn’t matter

Is there a way to use ndk-build NDK_DEBUG=1 though?

no unless you create your own application.mk, we use standard Makefiles since setting up everything with android system given all the libraries OF uses would be complex and also harder to mantain since we’ll have 2 different building systems for linux and android

but that flag only passes the correct flags to gcc which are already handled in the Makefile. Actually even compiling in release the debugger should start.

Can you check if there’s a higher verbosity level? i remember getting more info whenever the debugger couldn’t start

I think I have found a solution for this problem.

Since I am using MinGW instead of Cygwin, it might be possible its not entirely compatible. I replaced my official ndk r6b with this one: http://code.google.com/p/mingw-and-ndk/downloads/list

( http://code.google.com/p/mingw-and-ndk/downloads/detail?name=android-ndk-r6b-gdb-7.3.50.20110709-binutils-2.22.51-windows.7z&can=2&q= )
Using the same command as above, I now get:

  
$ /c/Development/android-ndk-r6b-custom/ndk-gdb --verbose  
Android NDK installation path: /c/Development/android-ndk-r6b-custom  
Using default adb command: /c/Development/android-sdk/platform-tools/adb.exe  
ADB version found: Android Debug Bridge version 1.0.29  
Using final ADB command: '/c/Development/android-sdk/platform-tools/adb.exe'  
Using auto-detected project path: .  
Found package name: com.AB.NB  
ABIs targetted by application: armeabi  
Device API Level: 8  
Device CPU ABI: armeabi  
Compatible device ABI: armeabi  
Found debuggable flag: true  
Found device gdbserver: //data/data/com.AB.NB/lib/gdbserver  
Using gdb setup init: /e/projects/AB/NB/trunk/OF/apps/android/No  
deBeatPhone/libs/armeabi/gdb.setup  
Using toolchain prefix: /c/Development/android-ndk-r6b-custom/toolchains/arm-lin  
ux-androideabi-4.6.2/prebuilt/windows/bin/arm-linux-androideabi-  
Using app out directory: /e/projects/AB/NB/trunk/OF/apps/android  
/NBPhone/obj/local/armeabi  
Found data directory: '/data/data/com.AB.NB'  
Found running PID: 918  
gdbserver version is  
Launched gdbserver succesfully.