Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » how to debug a program with root priviledge on eclipse CDT?
how to debug a program with root priviledge on eclipse CDT? [message #1710764] Fri, 09 October 2015 02:41 Go to next message
Eclipse UserFriend
I'm using ubuntu(linux)

My program uses libpcap to capture packets and so it needs root priviledge.

I searched a solution from Internet

1 Enable your user to run gdb as root without being asked for any password:
sudo visudo
Add the following line after all other rules:
<youruser> ALL=(root) NOPASSWD:/usr/bin/gdb

2 Create or modify a debug configuration in eclipse to run gdb as root
e.g. in Run > Debug Configurations > C/C++ Application > YourProject Debug:
change Debugger > Main > GDB debugger from gdb to sudo -u <youruser> gdb


but this solution doesn't work, I get "Pcap open live capture failure: wlan0: You don't have permission to capture on that device (socket: Operation not permitted)"

what is wrong?

are there any other workaround?

BTW: I don't know how to run the eclipse program itself through terminal. I have two eclipse installed, one is for Java and the other is CDT.
when I run the command "eclipse", I get

esolve@mypad:~$ eclipse
The program 'eclipse' is currently not installed. You can install it by typing:
sudo apt-get install eclipse-platform

is it possible if I can run my CDT eclipse through command line using sudo (something like sudo eclipse), then I CAN debug my program with root priviledge? if so, how?

[Updated on: Fri, 09 October 2015 02:45] by Moderator

Re: how to debug a program with root priviledge on eclipse CDT? [message #1710768 is a reply to message #1710764] Fri, 09 October 2015 03:20 Go to previous messageGo to next message
Eclipse UserFriend
You should not debug as root - it is by far unhealthy.

Have you thought of getting a capture file with tcpdump -w and using it as feed to your program under debugging?

Have a look at the Wireshark capture instructions <https://wiki.wireshark.org/CaptureSetup/CapturePrivileges>.

Re: how to debug a program with root priviledge on eclipse CDT? [message #1710770 is a reply to message #1710768] Fri, 09 October 2015 03:22 Go to previous messageGo to next message
Eclipse UserFriend
why it is unhealthy?

I get some segmentation fault, so I need to debug the program using gdb/eclipse, tcpdump can't solve my problem
Re: how to debug a program with root priviledge on eclipse CDT? [message #1710819 is a reply to message #1710770] Fri, 09 October 2015 10:02 Go to previous message
Eclipse UserFriend
It is always unhealthy to run flaky programs as root.

Did you look at the Wireshark instructions? There are ways to capture without being root.

You should have core dumps from the segmentation faults. Did you look at them with gdb?

If you *have* to run the debug session, do it with gdb alone as root. Please do not forget to compile the program with debug symbols and with optimization turned off.
Previous Topic:autotools project doesnt want to compile my source files
Next Topic:Can not find library file(dll) of rinside under eclipse+cygwin
Goto Forum:
  


Current Time: Sun Jun 15 20:00:59 EDT 2025

Powered by FUDForum. Page generated in 0.05221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top