如何使用 sudo 在 PetaLinux VSCode 调试器上运行代码?

问题描述 投票:0回答:1

我使用 sudo 权限在 PetaLinux 上运行 C 程序。就像下面的例子。

$ sduo ./test.c

我的petalinux版本

$ uname -a
Linux petalinux_project 5.15.36-xilinx-v2022.2 #1 SMP PREEMPT Mon Oct 3 07:50:07 UTC 2022 armv7l armv7l armv7l GNU/Linux

现在我想使用gdb调试器,但不知道如何添加sudo。如果我不使用 sudo 运行调试器,我的程序将会崩溃。

我的launch.json如下:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "gdb",
            "request": "launch",
            "target": <exe_file_path>,
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText",
        }
    ]
}

你能给我解释一下吗?谢谢大家。

debugging gdb vscode-debugger petalinux
1个回答
0
投票

可以尝试用这个替换参数:


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/yourExecutable",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "",
            "runtimeExecutable": "sudo",
            "runtimeArgs": [],
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}



© www.soinside.com 2019 - 2024. All rights reserved.