cannot access memory at address 0X1 after setting up gdb and eclipse to debug shared library from Android Application

I have two Android Projects: one is a library and the other a regular application using this library. My aim is to debug the shared library from the android application. I followed this guide:

http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/

  • How to get the path to the Android assets folder in the application package
  • android libvlc multiple surface problems
  • Android button select and press drawable
  • Alternative to getRunningTasks in Android L
  • Android: Extending user's contact book. Performance ContentProvider vs Sqlite vs List in memory
  • Why can't one add/remove items from an ArrayAdapter?
  • And I commented out the the last line

    ##$GDBCLIENT -x `native_path $GDBSETUP`
    

    But the following line

    ##cp -f $GDBSETUP_INIT $GDBSETUP
    

    complains with the message:

    it cannot stat ./libs/armeabi-v7a/gdb.setup

    so I commented it out since I think Eclipse will uploaded it for me. Besides that I made sure that:

    • In both Android.mk I put LOCAL_CFLAGS := -Wall –g

    • I am getting the .so in the libs library of the application

    • I made debuggable true in the application

    • The gdb2.setup path modified in order to refer both to the .so using solib-search-path ./libs/armeabi-v7a/ and the source is get referenced using directory

    After stepping in the System.LoadLibrary instruction I executed the ndk-build-eclipse
    and no errors were produced and when I started debugging natively I got:

    Cannot access memory at address 0x1

    and on Cygwin I got:

    Remote debugging from host 0.0.0.0

    Here’s the output of running the ndk-gdb-eclipse command:

    $ ./ndk-gdb-eclipse --adb=/cygdrive/c/Utilities/adt-bundle-windows/adt-bundle-windows/sdk/platform-tools/adb --project=/cygdrive/c/Projects/IDSmart/IDSmartApp/IDSmart  --force --port=5039 --verbose
    Android NDK installation path: /cygdrive/c/Utilities/android-ndk-r8c-windows/android-ndk-r8c/.
    Using specific adb command: /cygdrive/c/Utilities/adt-bundle-windows/adt-bundle-windows/sdk/platform-tools/adb
    ADB version found: Android Debug Bridge version 1.0.31
    Using ADB flags:
    Using specified project path: /cygdrive/c/Projects/IDSmart/IDSmartApp/IDSmart
    Found package name: uk.co.idscan.idsmart
    ABIs targetted by application: armeabi-v7a
    Device API Level: 15
    Device CPU ABIs: armeabi-v7a armeabi
    Compatible device ABI: armeabi-v7a
    Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
    Using toolchain prefix: /cygdrive/c/Utilities/android-ndk-r8c-windows/android-ndk-r8c/./toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-
    Using app out directory: ./obj/local/armeabi-v7a
    Found debuggable flag: true
    Found device gdbserver: /data/data/uk.co.idscan.idsmart/lib/gdbserver
    Found data directory: '/data/data/uk.co.idscan.idsmart'
    Found running PID: 7922
    7922
    Killing existing debugging session
    ## COMMAND: adb_cmd shell kill -9 7864
    /system/bin/sh: kill: 7864: Operation not permitted
    Launched gdbserver succesfully.
    Setup network redirection
    ## COMMAND: adb_cmd shell run-as uk.co.idscan.idsmart lib/gdbserver +debug-socket --attach 7922
    ## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/uk.co.idscan.idsmart/debug-socket
    Attached; pid = 7922
    Listening on Unix socket debug-socket
    ## COMMAND: adb_cmd pull /system/bin/app_process obj/local/armeabi-v7a/app_process
    1373 KB/s (9848 bytes in 0.007s)
    Pulled app_process from device/emulator.
    ## COMMAND: adb_cmd pull /system/bin/linker obj/local/armeabi-v7a/linker
    2147 KB/s (39592 bytes in 0.018s)
    Pulled linker from device/emulator.
    ## COMMAND: adb_cmd pull /system/lib/libc.so obj/local/armeabi-v7a/libc.so
    2576 KB/s (282316 bytes in 0.107s)
    Pulled libc.so from device/emulator.
    

  • Android calling AsyncTask right after an another finished
  • Android - How to Dismiss All Dialogs in onPause
  • Changing ActionBar tabs underline color programmatically
  • Access to Google API - GoogleAccountCredential.usingOAuth2 vs GoogleAuthUtil.getToken()
  • How do I use obtainStyledAttributes(int ) with internal Themes of Android
  • Join 3 tables in SQLite database
  • One Solution collect form web for “cannot access memory at address 0X1 after setting up gdb and eclipse to debug shared library from Android Application”

    Cannot access memory at address 0x1
    

    Post your gdb2.setup file, the same one that you are using in eclipse.

    Typically, these cannot access memory are due to solib-search-path being incorrect. Try entering absolute path to your project lib folder in your gdb2.setup file. For example, I have it set as:

    set solib-search-path D:/android/android-ndk-r8d/samples/hello-jni/obj/local/armeabi
    

    Let me know if it help.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.