NDK调试

1. AnroidManifest.xml 加入<application android:debuggable="true" >


2. Android.mk 加入 A PP_OPTIM := debug


3. 工程目录 ndk-build  && 安装并运行。


4.在工程目录  ndk-gdb  (如果是命令行调试,现在就可以了,GUI调试这一步也少不了。ndk-gdb 生成三个文件,obj/local/armeabi/libc.so,app_process,这两个文件是直接从设备下载下来的,另一个gdb.setup,改名为gdb2.setup,并删除最后一行 target remote 5039, 因为 ndk-gdb 把GDB SERVER与GDB CLIENT 一起运行了,如果命令行运行这样最方便了,如果要用  eclispe 作GUI CLIENT ,所以要删除,另外ndk-gdb 最后一行[$GDBCLIENT -x `native_path $GDBSETUP`]也注释了,目的一样,改名为   gdb2.setup是因为,每次运行ndk-gdb会生成三个文件)


5.配置GDB CLIENT
Run/Debug Configuration... 
**在Main Tab
C/C++ Application to point to obj/local/armeabi/app_process
witch launcher type to Standard Create Process Launcher using the link Select
other... at the bottom of the window
Go to the debugger file and set:


** debuger tab
 Debugger type to gdbserver.
GDB debugger to ${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb.
GDB command file to point to the gdb2.setup file located in obj/local/armeabi/ (you can use either an absolute or a relative path)


Go to the Connection tab and set Type to TCP. Default value for Host name or IP
address and Port number can be kept(localhost d 5039).


**Make a copy of $ANDROID_NDK/ndk-gdb and open it with a text editor.
Find the following line:
$GDBCLIENT -x `native_path $GDBSETUP`
Comment it because GDB client is going to be run by Eclipse itself:
#$GDBCLIENT -x `native_path $GDBSETUP`(注释这个一步就是为了用 现在配置的GDB CLIENT代替,以在GUI下操作)
6.配置 GDB SERVER TOOL
Run | External Tools | External Tools
Configurations... 
location :${env_var:ANDROID_NDK}/ndk-gdb
Working directory :${workspace_loc:/xxx}
arguments : --verbose --start

最后设置断点,运行 GDB SERVER ,再运行 GDB CLIENT,OK了,以下是成功图


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值