Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:41 Go to next message
wen liu is currently offline wen liuFriend
Messages: 7
Registered: September 2015
Junior Member
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 06:45]

Report message to a 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 07:20 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
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>.



--

Tauno Voipio
Re: how to debug a program with root priviledge on eclipse CDT? [message #1710770 is a reply to message #1710768] Fri, 09 October 2015 07:22 Go to previous messageGo to next message
wen liu is currently offline wen liuFriend
Messages: 7
Registered: September 2015
Junior Member
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 14:02 Go to previous message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
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.


--

Tauno Voipio
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: Tue Apr 16 20:21:00 GMT 2024

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

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

Back to the top