问题
Running IDE-Machine Windows 10 with Visual Studio 2019. Target-System for debugging is a Ubuntu 18.04. Using CMake available in Visual Stdio addons. Test software is the soem lib, with the simple_test programm, wich already leads to the issue (https://github.com/OpenEtherCATsociety/SOEM). After passing the eth-interface to the built programm, it stops with cause it can't get root. Already tried to pass sudo in the launch.vs.json and also pipe sudo the programm. Tried to change the access to the security permission for the eth-device.
"configurations": [
{
"type": "cppdbg",
"name": "simple_test (test\\linux\\simple_test\\simple_test)",
"project": "CMakeLists.txt",
"projectTarget": "simple_test (test\\linux\\simple_test\\simple_test)",
... // standard setup
"args": [
"enp3s0" //the eth dev I want to use
],
... // standard setup
]
}
The result of the programm without root is:
>SOEM (Simple Open EtherCAT Master)
>Simple test
>Starting simple test
>No socket connection on enp3s0
>Excecute as root
expecting something like:
>>sudo ~/SOEM/test/linux/simple_test/simple_test enp3s0
>SOEM (Simple Open EtherCAT Master)
>Simple test
>Starting simple test
>ec_init on enp3s0 succeeded.
>2 slaves found and configured.
>Slaves mapped, state to SAFE_OP.
>segments : 1 : 2 0 0 0
>Request operational state for all slaves
>Calculated workcounter 3
>Operational state reached for all slaves.
>^Cocessdata cycle 320, WKC 3 , O: 00 I: 00 T:0
Suggestions about this would be helpfull.
Thanks
回答1:
Okay solved my problem.
You have to pass sudo to the debugger by adding sudo
to "debuggerPath": "/usr/bin/gdb"
like this:
"debuggerPath": "sudo /usr/bin/gdb"
Resolved for me.
来源:https://stackoverflow.com/questions/56492075/starting-a-cmake-built-application-with-administrative-priviliges-from-visual-st