adb部署记录

本文详细介绍了如何在本地通过NDK进行远程Android设备的调试,包括adb的部署、gdbserver的安装与启动、系统依赖配置以及adb常用命令的使用,特别强调了目标远程连接和库搜索路径设置的步骤。

1 [NDK部署]

version 1:android-ndk-r10e-linux-x86_64/android-ndk-r10e/prebuilt/android-arm64/gdbserver (arm64)
version 2:android-ndk-r10e-linux-x86_64/android-ndk-r10e/prebuilt/android-arm/gdbserver (armv7)

version 1提取链接:https://pan.baidu.com/s/1dK7aLdASn7mQtTPJh1Oohw
提取码:8888

1.1 首先在本地部署adb(NDK,已经完成编译,可以直接运行)
sun@sun:~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e/prebuilt/android-arm64$ cd ../../
sun@sun:~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e$ cd toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/
sun@sun:~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin$ ./aarch64-linux-android-gdb 
GNU gdb (GDB) 7.7
Copyright (C) 2014 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=x86_64-linux-gnu --target=aarch64-elf-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote 192.168.103.246:1111

192.168.103.246:1111: Connection timed out.
(gdb) 
(gdb) exit
Undefined command: "exit".  Try "help".
(gdb) quit
sun@sun:~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin$ adb devices
List of devices attached
192.168.103.246:5555	device

1.2 其次在远端部署 gdbserver
~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e/prebuilt/android-arm64$ adb connect 192.168.103.246
connected to 192.168.103.246:5555
sun@sun:~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e/prebuilt/android-arm64$ adb push gdbserver /sdcard/
/sdcard/gdbserver/: 1 file pushed. 0 files skipped. 0.8 MB/s (759464 bytes in 0.899s)
sun@sun:~/softinstall/android-ndk-r10e-linux-x86_64/android-ndk-r10e/prebuilt/android-arm64$ adb shell
tb8788p1_64_bsp_wxp:/ $ su
tb8788p1_64_bsp_wxp:/ # mv /sdcard/gdbserver /data/                                       
tb8788p1_64_bsp_wxp:/data # chmod 777 gdbserver                                           

==============================================================================================================================================================================

2 系统依赖配置

2.1 拉去远程设备端数据到本地,在本地对应的文件夹下执行如下命令
adb pull /system/lib64 ./system_lib/
adb pull /vendor/lib64 ./vendor_lib/
adb pull /system/framework/oat ./frame_lib/oat/
adb pull /system/framework/arm64 ./frame_lib/arm64/
2.2 监听target remote
./gdbserver :1111 --attach 4080

注:1111 为监听的端口号,PID 为进程号

gdb
aarch64-linux-android-gdb 用于调试Android aarch64平台代码,位于android-ndk-r10e-linux-x86_64/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin目录下

arm-linux-androideabi-gdb 用于调试Android armv7平台代码,位于android-ndk-r10e-linux-x86_64/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin目录下

target remote 192.168.105.76:1111
192.168.105.76为Android机器的ip
1111 Android机器gdbserver监听的端口号
2.3监听set solib-search-path
~/bctc300_mtk8788_symbol/:~/bctc300_mtk8788_symbol/system_lib/:~/bctc300_mtk8788_symbol/vendor_lib/:~/bctc300_mtk8788_symbol/frame_lib/arm64/:~/bctc300_mtk8788_symbol/vendor_lib/egl/:~/bctc300_mtk8788_symbol/vendor_lib/hw/:~/bctc300_mtk8788_symbol/frame_lib/oat/arm64/:~/bctc300_mtk8788_symbol/so/

==============================================================================================================================================================================

3 adb常用命令

首先连接设备

adb
adb connect ip

进入远程设备端

adb shell 

获取远程设备端su权限

adb root 

查看远程端设备

adb devices

挂载远程端

adb remount

推送数到远程端

adb push 

连接上设别后直接使用该命令传输文件即可(包括远程连接)

sun@sun:~/workspace/androd$ adb push ./bin/aurora300_runner /data/debug/aurora300_test 
[100%] /data/debug/aurora300_test/aurora300_runner
sun@sun:~/workspace/androd$ adb push ./bin/  /data/debug/aurora300_test 
/data/debug/aurora300_test/bin/: 43 files pushed. 0 files skipped. 1.0 MB/s (112192766 bytes in 111.913s)

==============================================================================================================================================================================

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大江东去浪淘尽千古风流人物

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值