在设置gdb和eclipse之后,从Android应用程序调试共享库时,无法访问地址0X1的内存 [英] cannot access memory at address 0X1 after setting up gdb and eclipse to debug shared library from Android Application
问题描述
http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/
我已经注释了最后一行
## $ GDBCLIENT -x`native_path $ GDBSETUP`
但以下行
## cp -f $ GDBSETUP_INIT $ GDBSETUP
抱怨邮件:
它不能统计./libs/armeabi-v7a/gdb.setup
所以我评论了,因为我认为Eclipse会上传给我。此外,我确定:
-
在Android.mk中,我将LOCAL_CFLAGS:= -Wall -g
-
我在应用程序的libs库中获取.so。
-
我使可调试的应用程序
-
为了引用.so使用solib-search-path ./libs/armeabi-v7a/和/或使用目录
获取引用源。
在执行了System.LoadLibrary指令后,我执行了ndk-build-eclipse
并没有产生任何错误,当我开始调试本来我得到:
无法访问内存在地址0x1
和Cygwin我得到:
远程调试从主机0.0.0.0
以下是运行ndk-gdb-eclipse命令的输出:
$ ./ndk-gdb-eclipse --adb = / cygdr ive / 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安装路径:/ cygdrive / c / Utilities / android-ndk-r8c-windows / android-ndk-r8c /。
使用特定的adb命令:/ cygdrive / c / Utilities / adt-bundle-windows / adt-bundle-windows / sdk / platform-tools / adb
找到ADB版本:Android Debug Bridge版本1.0.31
使用ADB标志:
使用指定的项目路径:/ cygdrive / c / Projects / IDSmart / IDSmartApp / IDSmart
找到的包名称:uk.co.idscan.idsmart
ABIs target通过应用程序:armeabi-v7a
设备API级别:15
设备CPU ABIs:armeabi-v7a armeabi
兼容设备ABI:armeabi-v7a
使用gdb setup init:./libs /armeabi-v7a/gdb.setup
使用工具链前缀:/cygdrive/c/Utilities/android-ndk-r8c-windows/android-ndk-r8c/./toolchains/arm-linux-androideabi-4.6/prebuilt / windows / bin / arm-linux-androideabi-
使用app out目录:./obj/local/armeabi-v7a
找到可调试标志:true
找到的设备gdbserver:/ data / data /uk.co.idscan.idsmart/lib/gdbserver
找到的数据目录:'/data/data/uk.co.idscan.idsmart'
找到运行PID:7922
7922
杀死现有调试会话
##命令:adb_cmd shell kill -9 7864
/ system / bin / sh:kill:7864:不允许操作
成功启动gdbserver。
设置网络重定向
##命令:adb_cmd shell run-as uk.co.idscan.idsmart lib / gdbserver + debug-socket -attach 7922
##命令:adb_cmd forward tcp: 5039 localfilesystem:/data/data/uk.co.idscan.idsmart/debug-socket
附加; pid = 7922
在Unix socket上侦听debug-socket
##命令:adb_cmd pull / system / bin / app_process obj / local / armeabi-v7a / app_process
1373 KB / s(9848 bytes在0.007s)
从设备/模拟器拉出app_process。
##命令:adb_cmd pull / system / bin / linker obj / local / armeabi-v7a / linker
2147 KB / s(0.018s中为39592字节)
从设备/模拟器拉出的链接器。
##命令:adb_cmd pull /system/lib/libc.so obj / local / armeabi-v7a / libc.so
2576 KB / s(0.107s中为282316字节)
拉式libc .so从设备/模拟器。
无法访问内存在地址0x1
发布您的gdb2.setup文件,与您在eclipse中使用的文件相同。
通常,这些无法访问内存的原因是solib-search-path不正确。尝试在gdb2.setup文件中输入绝对路径到您的项目lib文件夹。例如,我设置为:
set solib-search-path D:/ android / android-ndk-r8d / sample / hello-jni / obj / local / armeabi
让我知道,如果它有帮助。
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/
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.
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.
这篇关于在设置gdb和eclipse之后,从Android应用程序调试共享库时,无法访问地址0X1的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!