Skip to content

Latest commit

 

History

History
76 lines (63 loc) · 2.24 KB

File metadata and controls

76 lines (63 loc) · 2.24 KB

Android Debugging with Visual Studio Code

准备好工程

参考android

配置Python环境

# 使用NDK r23c,24开始就没gdb了
/Applications/AndroidNDK8568313.app/Contents/NDK/prebuilt/darwin-x86_64/bin/gdb

配置工程

配置task,在.vscode的task.json文件中
 	{
            "label": "Forward_Debug_Port",
            "type": "shell",
            "command": "adb",
            "args": [
                "forward",
                "tcp:5039",
                "tcp:5039"
            ],
            "presentation": {
                "reveal": "never"
            },
            "problemMatcher": []
    }

配置工程启动,在.vscode的launch.json中

  • 注:osx 有问题Debugger executable '/usr/local/bin/gdb' is not signed.
{
    "name": "Remote GDB",
    "type": "cppdbg",
    "request": "launch",
            
    "preLaunchTask": "Build_Android",
    "cwd": "${workspaceRoot}",
    "program": "${workspaceRoot}/android/build_arm64-v8a/hello",
    "additionalSOLibSearchPath": "${workspaceRoot}", 
    "miDebuggerServerAddress": "172.19.101.17:5039",
    "windows": {
        "miDebuggerPath": "",
        "MIMode": "gdb"
    },
    "osx": {
        "miDebuggerPath": "/Applications/AndroidNDK8568313.app/Contents/NDK/prebuilt/darwin-x86_64/bin/gdb",
        "MIMode": "gdb"
    }
}
        

客户端配置

# 推送gdbserver到设备
export ANROID_NDK="/Applications/AndroidNDK8568313.app/Contents/NDK"
export ANROID_NDK="/opt/ndk/android-ndk-r23b"
adb push ${ANROID_NDK}/prebuilt/android-arm64/gdbserver/gdbserver /data/local/tmp
# 使用adb命令来forward tcp端口是最常用的
adb forward tcp:5039 tcp:5039

# 启动程序
 /data/local/tmp/gdbserver :5039 ./hello

参考资料