码迷,mamicode.com
首页 > 移动开发 > 详细

vscode单步调试Android c++源码

时间:2021-06-05 18:17:03      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:div   mod   type   symbol   res   shell   code   nes   pre   

步骤

注意:这个过程需要在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

vscode单步调试Android c++源码

标签:div   mod   type   symbol   res   shell   code   nes   pre   

原文地址:https://www.cnblogs.com/pyjetson/p/14852326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!