Debugging target with sudo rights

Sysprogs forums Forums VisualGDB Debugging target with sudo rights

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #509
    chanda
    Participant

    Hello
    I have setup my raspberry Pi and try to use the GPIO. Almost all efficient libraries like wiringPi or bcm2835 need root access to run. How is it possible to debug such a program?

    I tried to add commands like
    sudo chown 0.0 “binary”
    sudo chmod 4777 “binary”

    in the GDB startup commands, but sudo is not known, e.g. error message during connect Undefined command: “sudo”. Try “help”.

    What are the possibilities with VisualGDB?

    Thanks

    #2245
    support
    Keymaster

    The easiest way would be to let VisualGDB connect via SSH already as root:

    1. Open a root shell with ‘sudo su’
    2. Change the root password with ‘passwd’
    3. In VisualGDB Project Properties (right-click on the project file to open) find the ‘Remote Computer’ setting, select ‘New connection’ and enter ‘root’ as the user name and the password you set in the previous step.

    From now on the project will be built and debugged as root.

    #2247
    Anonymous
    Participant

    Hey,
    I want to reheat that question:
    What bazis writes works for me, but I would prefer to be able to run with su rights from an (automatically logged in) standard user account.

    The reason is, my application should have a GUI on lxde and still access root.
    Debugging it either leads to (with root):

      Invalid MIT-MAGIC-COOKIE-1 myAppName: cannot connect to X server :0

    Or (without root):

      wiringPiSetup: Must be root. (Did you forget sudo?)

    What works is:

      Taking the application created without root and running it on the lxde desktop with either:
      root: ./myAppName

      pi: sudo ./myAppName

    works as intended, just isn’t debugging

    TL:DR
    I want to know how to debug applications with su rights on a standard users LXDE desktop

    Thanks!

    #2246
    support
    Keymaster

    Hi,

    We’ve added support for running gdb via sudo a few versions ago. See the “run debugger as root with sudo” checkbox on the Debug Settings page.

    #11631
    dcomer
    Participant

    Sorry, I know that was an old post. I have the same issue, but I do not see “run debugger as root with sudo”. Is this accessable via the VW (2015 in my case) IDE, or a VisualGDB dialog. I’ve looked all over and do not see this option.

     

    Thanks,

     

    Dave

    #11632
    support
    Keymaster

    Hi,

    It should be on the Debug Settings page of VisualGDB Project Properties. If not, please attach a screenshot of this page (we have recently added attaching functionality to the forum) and we will advise.

    #11645
    dcomer
    Participant

    Ah, got it now. I was looking in the right-click menu for the project. I did not realize that I should have, instead, been right-clicking on the VisualGDB settings project item, looking on the left hand side of the tabbed dialog that says “Debug Settings, and in the middle of tab with the debug settings indeed there is the “Run debugger as root with sudo (this can cause debugging to hang)” check box. I’m being a little verbose in my reply should someone else have the same issue. I’d include an image here but not sure it would remain with my reply.

    Thanks for your help. I LOVE VisualGDB. It is perfect for the development I do!

     

    Dave

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.