不然你要我怎么样

彪悍的代码不需要注释

Archive for the ‘GDB’ tag

使用gdb在Android Emulator中进行调试c程序

8 comments

参考文章:Debug Native c/c++ Application for Android(Step by Step)

Google Android Debugging Utilities

首先,我们需要一个含有调试信息的exe文件,一般这个文件存在于out/target/product/generic/obj/EXECUTABLES/yourexefile_intermediates/LINKED/libomstts目录下,这里以我们前面文章中生成的helloworld为例。

1. 下载Android Debugging Utilities

gdb and gdb-server (6.8)

2. 启动Android Emulator模拟器

$ emulator @1.5_R2

3. 把gdb和调试文件以及源代码放到模拟器上

$ adb push gdb /data/bin

$ adb push helloworld /data/bin

以helloworld为例,源代码要放在/data/bin/development/hello目录下。

有的文章说将以上文件放在/system/bin目录下,但后果是一旦关掉模拟器,这些的文件就消失了,下次又要重传~所以推荐放在/data/bin目录下。

4. 启动shell

$adb shell

如果提示文件系统不可写的话,执行:

#mount -o remount

5. 因为Android文件系统没有/bin/sh, 所以这里有两种解决方法(推荐第二种方法):

(1). 拷贝一个bash文件(点击下载)到/bin目录下:

#mkdir /bin

$adb push bash /bin

(2). 或者设置SHELL的路径:

#export SHELL=/system/bin/sh

6. 进入/data/bin目录,运行gdb,可以开始调试程序了

#cd /data/bin

#./gdb helloworld

转载请注明: 转载自不然你要我怎么样
本文链接地址: 使用gdb在Android Emulator中进行调试c程序

Written by xiangmocheng

六月 14th, 2009 at 9:42 下午

Posted in Android

Tagged with ,