Starting a cmake-built application with administrative priviliges from Visual Studio 2019 on a remote Linux machine

只谈情不闲聊 提交于 2021-01-29 06:58:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!