vscode搭建gdb调试交叉编译代码

本文详细介绍了如何在VSCode中配置并使用gdb进行跨平台编译项目的调试,包括安装openssh插件、创建launch.json文件、设置调试参数和在开发板上运行gdbserver的过程。
摘要由CSDN通过智能技术生成

vscode搭建gdb调试交叉编译代码

1.vscode环境搭建

  • c++插件
  • openssh插件

2.调试配置添加

  • 在代码工程中的run and debug菜单中添加launch.json文件,然后点击add configuration添加gdb和运行信息,其中需要配置的有如下

    • program:运行的bin文件路径
    • miDebuggerPath : 交叉编译器gdb的路径
    • miDebuggerServerAddress : 目标主板的ip以及端口号
    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program":*/path/bin",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${fileDirname}",
                "miDebuggerPath": "**、arm-rockchip830-linux-uclibcgnueabihf-gdb",
                "miDebuggerServerAddress":"192.168.80.159:9001",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    },
                    {
                        "description": "Set Disassembly Flavor to Intel",
                        "text": "-gdb-set disassembly-flavor intel",
                        "ignoreFailures": true
                    }
                ]
            }
    
    
        ]
    }
    

3.开发板运行

  • 开发板的ip地址需要分配,然后把ip对应到vscode中的miDebuggerServerAddress中
  • 编译的gdbserver拷贝到目标开发板上,
  • 执行gdbserver ip+端口 目标文件

4.vscode代码调试

  • 启动gdb,添加断点 查看变量
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值