1

I have a Android native code, which comprises of a static library(XXX.a) and the final ndk-build command(with NDK_DEBUG set to 1) takes the above prebuilt static library and creates a shared object.

I use the nm command to look into the shared object for a particular function definition and it seems to be available( 001ff2f5 T XXXXX).

But when I run ndk-gdb on Android device running 4.4.2, gdb fails to load the shared object symbols :

Android NDK installation path: /opt/android-ndk-r8
Using specific adb command: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags: 
Using auto-detected project path: .
Found package name: com.example.ue2fileviewer
ABIs targetted by application: armeabi
Device API Level: 19
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /opt/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.ue2fileviewer/lib/gdbserver
Found data directory: '/data/data/com.example.ue2fileviewer'
Found first launchable activity: .UE2FvSample
Launching activity: com.example.ue2fileviewer/.UE2FvSample
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell am start -n com.example.ue2fileviewer/.UE2FvSample
Starting: Intent { cmp=com.example.ue2fileviewer/.UE2FvSample }
COMMAND:~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell sleep 10
Found running PID: 1650
Killing existing debugging session
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell kill -9 29470
/system/bin/sh: kill: 29470: Operation not permitted
Launched gdbserver succesfully.
Setup network redirection
COMMAND:~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.example.ue2fileviewer/debug-socket
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell run-as com.example.ue2fileviewer lib/gdbserver +debug-socket --attach 1650
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb pull /system/bin/app_process ./obj/local/armeabi/app_process
Attached; pid = 1650
Listening on sockaddr socket debug-socket
106 KB/s (9560 bytes in 0.087s)
Pulled app_process from device/emulator.
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb pull /system/lib/libc.so ./obj/local/armeabi/libc.so
780 KB/s (310652 bytes in 0.388s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-linux-gnu --target=arm-elf-linux".
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0x4004f73c in ?? ()
gdb: Unable to get location for thread creation breakpoint: requested event is not supported
(gdb) 

I am running it on Ubuntu, ndk-r8 NDK version and on Android SDK Platform android-19.

I have tried almost all posts currently available in stack overflow but none of it seems to work for me. I have been trying to set a breakpoint in the function present in the static library but with no success.

Can someone please provide an insight of where I might be going wrong and how to proceed from here to get ndk-gdb debugging working?

learn_develop
  • 1,735
  • 4
  • 15
  • 33

1 Answers1

0

can you try compiling with APP_OPTIM=debug in addition to NDK_DEBUG=1 ? Also, upgrading to the latest version of the NDK (r9d) may help, as there were a large amount of bug fixes concerning gdb since r8.

ph0b
  • 14,353
  • 4
  • 43
  • 41