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:

  • What are best practices for using AES encryption in Android?
  • How do I know if a MotionEvent is relative or absolute?
  • Android emulator how to use telnet localhost 5554?
  • Job Scheduler not running on Android N
  • Saving the state of a WebView and reloading the position
  • ProGuard not working in my app
  • And I commented out the the last line

    ##$GDBCLIENT -x `native_path $GDBSETUP`

    But the following line


    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 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

    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:
    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/
    Found data directory: '/data/data/'
    Found running PID: 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 lib/gdbserver +debug-socket --attach 7922
    ## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/
    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/ obj/local/armeabi-v7a/
    2576 KB/s (282316 bytes in 0.107s)
    Pulled from device/emulator.

    Related posts:

    Full Screen Notification only showing as a Heads Up
    AlarmManager does not always execute BroadcastReceiver
    Generate 10 numbers and move first number to the end 10 times
    Android Unique Serial Number
    android finish current activity causes app close
    Java compiler for android phones
  • Keystore and Aliases - is there a use to multiple aliases?
  • zoom over specific route google map
  • How to handle UI based Navigation in Cross Platform Apps?
  • Android options menu icon won't display
  • How to categorize android layout in to small,medium,large,x-large screen?
  • List all the leaderboards in Google play game services
  • 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.