windows下gdb与gdb_server调试Android的程序

手机服务端:

启动方式:  gdbserver:23946 + bin程序路径

附加方式:  gdbserver:23946+-attach [pid]

PC客户端:

D:\Android-ndk-r9\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb.exe

(gdb) target remote 127.0.0.1:23946

gdbserver 路径 D:\android-ndk-r9\prebuilt\android-arm\gdbserver 


1.上传并修改手机的gdbserver权限

adb push D:\android-ndk-r9\prebuilt\android-arm\gdbserver\gdbserver /data/local/tmp

adb shell chmod 777 /data/local/tmp/gdbserver

2.端口转发

adb forward tcp:23946 tcp:23946

./gdbserver :23946 --attach 3281

3.运行gdbserver

启动方式:  gdbserver:23946  bin程序路径

附加方式:  gdbserver :23946 --attach [pid]

root@android:/ # ./gdbserver  :23946 --attach 1805
gdbserver :23946 --attach 1805
Attached; pid = 1805
Listening on port 23946


4.运行gdb

C:\Users>D:\android-ndk-r9\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb.exe
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i586-pc-mingw32msvc --target=arm-linux-androi
d".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
(gdb) set disassemble-next on
(gdb) set step-mode on
(gdb) target remote 127.0.0.1:23946
Remote debugging using 127.0.0.1:23946
0x40037ebc in ?? ()
=> 0x40037ebc:  90 00 bd e8     pop     {r4, r7}
(gdb)

此时gdbserver的显示

root@android:/ # gdbserver :23946 --attach 1805
gdbserver :23946 --attach 1805
Attached; pid = 1805
Listening on port 23946
Remote debugging from host 127.0.0.1

后续结合IDA分析。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值