地址0X1设置GDB后无法访问内存和Eclipse从Android应用程序调试共享库应用程序、无法访问、内存、地址

2023-09-07 14:58:22 作者:走路太酷↘会掉内裤

我有两款Android项目:一个是库,并使用这个库中的其他常规应用程序。我的目标是从Android应用程序调试共享库。我遵循这个指南:

的http://mhandroid.word$p$pss.com/2011/01/23/using-eclipse-for-android-cc-debugging/

和我注释掉最后一行

  ## $ GDBCLIENT -x`$ native_path GDBSETUP` 
Eclipse CDT gdb调试android ndk程序

但下面的行

  ## CP -f $ GDBSETUP_INIT $ GDBSETUP 

抱怨与消息:

不能与stat ./libs/armeabi-v7a/gdb.setup

所以我评论它,因为我觉得Eclipse将上传对我来说。除此之外我确信:

在这两个Android.mk我把LOCAL_CFLAGS:= -Wall -g

我收到了。所以在应用程序

的库库

我做了调试的真正的应用程序

为了使用solib搜索路径./libs/armeabi-v7a/和源指的是。所以修改的gdb2.setup路径开始使用目录中引用

在的System.loadLibrary指令步进后,我执行了NDK的构建月食并没有产生错误,当我开始调试本身我:

  

地址为0x1不能访问内存

和在Cygwin我:

  

从主机0.0.0.0远程调试

下面是运行NDK-GDB-日食命令的输出:

  $ ./ndk-gdb-eclipse --adb = / cygdrive / C /工具/ ADT-束窗/ ADT-束窗/ SDK /平台工具/ ADB --project = / cygdrive / C /项目/ IDSmart / IDSmartApp / IDSmart --force --port = 5039 --verboseAndroid的NDK安装路径为:/ cygdrive / C /工具/ Android的NDK-R8C窗口/ Android的NDK-R8C /。使用特定的亚行命令:/ cygdrive / C /工具/ ADT-束窗/ ADT-束窗/ SDK /平台工具/ ADB发现ADB版本:Android的调试桥版本1.0.31使用亚行标志:使用指定的项目路径:/ cygdrive / C /项目/ IDSmart / IDSmartApp / IDSmart发现包名:uk.co.idscan.idsmartarmeabi-V7A:ABIS通过应用针对性设备API等级:15设备CPU的ABI:armeabi-V7A armeabi兼容设备ABI:armeabi-V7A使用GDB设置初始化:./libs/armeabi-v7a/gdb.setup使用工具链preFIX: /cygdrive/c/Utilities/android-ndk-r8c-windows/android-ndk-r8c/./toolchains/arm-linux-androideabi-4.6/$p$pbuilt/windows/bin/arm-linux-androideabi-使用App out目录:./obj/local/armeabi-v7a找到调试的标志:真发现设备gdbserver的:/data/data/uk.co.idscan.idsmart/lib/gdbserver发现数据目录:/data/data/uk.co.idscan.idsmart发现运行PID:79227922杀死现有的调试会话## COMMAND:adb_cmd外壳杀-9 7864/系统/ bin / sh的:杀:7864:不允许操作成功地推出了gdbserver的。设置网络重定向## COMMAND:adb_cmd shell中运行,如LIB uk.co.idscan.idsmart / gdbserver的调试+插座--attach 7922## COMMAND:adb_cmd转发TCP:5039 localfilesystem:/data/data/uk.co.idscan.idsmart/debug-socket附; PID = 7922监听Unix套接字调试插座## COMMAND:adb_cmd拉/系统/斌/ app_process OBJ /本地/ armeabi-V7A / app_process1373 KB /秒(在0.007s 9848字节)从设备/仿真器拉app_process。## COMMAND:adb_cmd拉/系统/斌/连接器OBJ /本地/ armeabi-V7A /连接器2147 KB /秒(在0.018s 39592字节)从设备/仿真器连接拉。## COMMAND:adb_cmd拉/system/lib/libc.so OBJ /本地/ armeabi-V7A / libc.so2576 KB /秒(在0.107s 282316字节)从设备/仿真器libc.so拉动。 

解决方案

 无法地址为0x1访问内存 

发布你的gdb2.setup文件,您使用Eclipse中的相​​同。

典型地,这些不能访问存储器是由于solib搜索路径是不正确。尝试在gdb2.setup文件中输入绝对路径到你的项目lib文件夹。例如,我有它设置为:

 设置solib搜索路径D:/安卓/ Android的NDK-r8d /样本/ HELLO-JNI / OBJ /本地/ 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.