[Linux]用VScode 调试Linux命令行带参数可执行程序

最近在研究大神给我的一个程序,挺长的,如果不是单步调试估计是看不懂了,其实编译运行都是没问题的,然后注意编译的时候要加一个"-g"选项,保留调试信息,最好不要优化,即"-O0",运行时的命令行参数是:

./mkimage_imx8mm -fit -loader u-boot-spl-ddr.bin 0x7E1000 -out flash.bin

然后需要在调试时弹出来的launch.json配置文件中设置,主要注意两个地方,
第一个是指定运行程序的位置:"program": "${workspaceFolder}/iMX8MM/mkimage_imx8mm",
另一个要注意的地方带的参数之间每个空格都要用引号分隔开:"args": ["-fit","-loader","u-boot-spl-ddr.bin","0x7E1000","-out","flash.bin"]
其他基本保持默认就可以了。
完整的launch.json文件如下所示:

{
    // 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": "${workspaceFolder}/iMX8MM/mkimage_imx8mm",
            "args": ["-fit","-loader","u-boot-spl-ddr.bin","0x7E1000","-out","flash.bin"],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}/iMX8MM/",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

山猫Show

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

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

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

打赏作者

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

抵扣说明:

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

余额充值