vscode单步调试Android c++源码
vscode单步调试Android c++源码
目录
步骤
注意:这个过程需要在Android源码环境中运行,可以使用adb端口转发工具,来连接服务器端的源码进行运行
关于adb端口转发:请看https://www.cnblogs.com/pyjetson/p/14828485.html
1. 运行gdbclient.py脚本
首先是使用vscode remote ssh终端连接服务器
1. 找到进程的pid号
adb shell "ps -A | grep vold"
2. 运行gdbclient.py脚本
gdbclient.py -p 20750 --setup-forwarding vscode
2. 复制生成的launch.json并新建/home/jetson/android_aosp/aosp/.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"miDebuggerPath": "/home/jetson/android_aosp/aosp/prebuilts/gdb/linux-x86/bin/gdb",
"program": "/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/bin/vold",
"setupCommands": [
{
"text": "-enable-pretty-printing",
"description": "Enable pretty-printing for gdb",
"ignoreFailures": true
},
{
"text": "-environment-directory /home/jetson/android_aosp/aosp",
"description": "gdb command: dir",
"ignoreFailures": false
},
{
"text": "-gdb-set solib-search-path /home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/lib/:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/lib/hw:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/lib/ssl/engines:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/lib/drm:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/lib/egl:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/system/lib/soundfx:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/vendor/lib/:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/vendor/lib/hw:/home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols/vendor/lib/egl",
"description": "gdb command: set solib-search-path",
"ignoreFailures": false
},
{
"text": "-gdb-set solib-absolute-prefix /home/jetson/android_aosp/aosp/out/target/product/generic_x86/symbols",
"description": "gdb command: set solib-absolute-prefix",
"ignoreFailures": false
},
{
"text": "-interpreter-exec console \"source /home/jetson/android_aosp/aosp/development/scripts/gdb/dalvik.gdb\"",
"description": "gdb command: source art commands",
"ignoreFailures": false
}
],
"name": "(gdbclient.py) Attach vold (port: 5039)",
"miDebuggerServerAddress": "localhost:5039",
"request": "launch",
"type": "cppdbg",
"cwd": "/home/jetson/android_aosp/aosp",
"MIMode": "gdb"
}
]
}
3. 运行gdb即可,打断点
参考
1. 使用调试程序
https://source.android.com/devices/tech/debug/gdb