Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK debugging: armeabi-v7a not working

Eclipse / Cygwin

NDK 8c

Building a shared library

I can't get gdbserver to start anymore after switching to armeabi-v7a. I've searched online for hours but can't find a topic that deals specifically with armeabi-v7a debugging issues.

I have no choice to switch to armeabi-v7a due to using a third party library which depends on it. Without it, I get these kind of errors:

D:\TEMP\ccnnGAqD.s:10427: Error: selected processor does not support Thumb mode `ldrex r6,[r3]'
D:\TEMP\ccnnGAqD.s:10429: Error: selected processor does not support Thumb mode `strex r4,r5,[r3]'

It was all working fine before with 'armeabi', using this setup: http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/

The only change I've made is to add this to Application.mk:

APP_ABI := armeabi-v7a

At the very bottom of the shared library Android.mk I added this:

$(info TARGET_ARCH     = $(TARGET_ARCH))
$(info TARGET_ARCH_ABI = $(TARGET_ARCH_ABI))
$(info TARGET_ABI      = $(TARGET_ABI))

which outputs the following:

TARGET_ARCH     = arm
TARGET_ARCH_ABI = armeabi-v7a
TARGET_ABI      = android-14-armeabi-v7a

I've uninstalled the app using

adb uninstall com.example.game

AndroidManifest.xml does have the android:debuggable="true" property.

Done a "clean all" in Eclipse, and manually deleted the ./libs and ./obj folders. Then, ndk-build outputs to the right folders (obj/local/armeabi-v7a and libs/armeabi-v7a), and obj/local/armeabi and libs/armeabi do not exist.

However, here's what happens when I run ndk-gdb:

user@MACHINENAME /cygdrive/e/projects/game
$ ndk-gdb-eclipse --force --verbose
Android NDK installation path: /cygdrive/e/projects/sdks/android-ndk
Using default adb command: /cygdrive/e/projects/sdks/android-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.game
ABIs targetted by application: armeabi
Device API Level: 15
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/e/projects/sdks/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found debuggable flag: true
ERROR: Could not find gdbserver binary under ./libs/armeabi
   This usually means you modified your AndroidManifest.xml to set
   the android:debuggable flag to 'true' but did not rebuild the
   native binaries. Please call 'ndk-build' to do so,
   *then* re-install to the device!

Notice the "ABIs targetted by application" using the wrong 'armeabi'. Here's the relevant part of ndk-gdb:

get_build_var ()
{
    if [ -z "$GNUMAKE" ] ; then
        GNUMAKE=make
    fi
    $GNUMAKE --no-print-dir -f $ANDROID_NDK_ROOT/build/core/build-local.mk -C $PROJECT DUMP_$1 | tail -1
}

APP_ABIS=`get_build_var APP_ABI`
if [ "$APP_ABIS" != "${APP_ABIS%%all*}" ] ; then
# replace first "all" with all available ABIs
  ALL_ABIS=`get_build_var NDK_ALL_ABIS`
  APP_ABIS_FRONT="${APP_ABIS%%all*}"
  APP_ABIS_BACK="${APP_ABIS#*all}"
  APP_ABIS="${APP_ABIS_FRONT}${ALL_ABIS}${APP_ABIS_BACK}"
fi
log "ABIs targetted by application: $APP_ABIS"

I clearly set APP_ABI to armeabi-v7a in Application.mk, so is this a bug in the NDK? Or am I missing something?

like image 671
foo64 Avatar asked Nov 27 '12 18:11

foo64


1 Answers

I had the same issue. I configured eclipse following this article. Then I change from armeabi to armeabi-v7a. Then I couldn't debug.

I fixed this issue:
1) You must fix the folders in "Debug configurations"

  • Main tab change ...obj/local/armeabi/app_process to ...obj/local/armeabi-v7a/app_process
  • Debugger tab change ...obj/local/armeabi/gdb2.setup to obj/local/armeabi-v7a/gdb2.setup
  • Debugger tab change .../toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb to toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb

2) May be this is workaround but it works. In "Debug configurations" ->Debugger->Shared Libraries add <project path>/obj/local/armeabi-v7a and check "Load shared library symbols automatically"

like image 101
Deyan Chakarov Avatar answered Oct 21 '22 06:10

Deyan Chakarov