我使用 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",
}
]
}
你能给我解释一下吗?谢谢大家。
可以尝试用这个替换参数:
{
"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"
}
]
}