I know that this question was asked many times on various sites, but I couldn't find any recommendations how to fix my problem. I'm working with GCC 4.8.1 in NetBeans 8.0 and need to (visually) debug a program, which accesses raw devices, so I need to run it via sudo.
My project properties settings are:
- Run -> Run Command = "sudo ${OUTPUT_PATH}"
- Run -> Console Type = "External Terminal"
- Run -> External Terminal Type = "Default"
All the other settings are default ones, including Debug -> Debug Command
, which is empty.
So, the program works fine when I run it in NetBeans - sudo asks for a password and then the program continues. However, I can't debug it in the NetBeans - the debugger outputs the text below and stops.
Any ideas? Please don't suggest running the NetBeans as root - it's too troublesome for me.
(I'm on Xubuntu 3.11
, which runs as a guest OS
in the VMWare Fusion VM on Mac)
UPDATE FROM 2015/09/16:
According to multiple advices (from the net) I tried to replace the Debug Command
in the Tools
-> Options
-> C/C++
pop-up window by my script with the following content:
#!/bin/bash
PROG=$(which gdb)
sudo $PROG "$@"
This script works fine from command line. However, when I try to debug my program from NetBeans I get the following pop-up window:
So, the first problem goes away and the second one pops up. I saw a number of recommendations to clear breakpoints in this case - it didn't help me.
Any ideas what to try next?
(The gdb version is GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04)
The NetBeans IDE with C/C++ uses the gdb debugger and provides numerous features for debugging your projects. To explore these features, you will use the Quote project. If you have not already created this project, do the following: Choose File > New Project.
NetBeans C/C support lets you create C and C Application and Library projects with generated makefiles, as well as C and C++ projects with existing sources. You can build, run, and debug your project on the local host (the system from which you started the IDE) or on a remote host running a UNIX® operating system.
NetBeans IDE with the C/C/Fortran plugin supports unit tests in C/C projects. You can use the IDE to create, run, debug, and view results of your C and C tests. This article shows you how to use unit tests in the IDE with your C/C projects.
C Unit Testing Framework project on sourceforge. See the NetBeans IDE Installation Instructions and + Configuring the NetBeans IDE for C/C+/Fortran for information about downloading and installing the required NetBeans software. NetBeans IDE with the C/C/Fortran plugin supports unit tests in C/C projects.
A bit late, but I ran across this question while I was looking for a solution to the exact same problem.
Create a script file with the following:
#!/bin/bash
sudo /usr/bin/gdb $*
Change the permissions of the script file to executable for your user.
In NetBeans, go to Tools -> Options -> C/C++ -> Debugger Command -> script_file_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With