Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 761 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to debug application as root in eclipse in Ubuntu?

#1
I'm programming application using libpcap. when I debug the application in normal mode, pcap cannot get the network device. it seems that I have to debug the application in root.
How can I debug the application in root? I have the root password.
I think eclipse has such an option that can add root for the debugging application,but I don't know how to do it.
please help.
Reply

#2
From the console in the directory with your executable:

sudo gdb ./my_program

If eclipse supports remote debugging then you could do that even though it is running locally.

From the console:

sudo gdbserver localhost:<port_number> ./my_program

And then tell Eclipse the address (localhost and the port number you chose).

Oh yeah, you said the reason you were doing this was because you were using `libpcap`, so you may not want to use remote debugging over TCP because you may end up capturing your debugging connection packets in addition to your other network traffic.

In that case you do your remote (but really local) debugging over a serial port. I have never done this on a local machine, but you could use two actual serial ports (attaching them though a null modem) or try using a psudoterminal:

sudo gdbserver /dev/ptmx ./my_program

This will create the psudo-terminal under `/dev/pts/` but you'll have to figure out the name of it, and it might also create it with restrictive permissions. You can get around those. Unless you are running lots of terminal windows as root, it is not likely that you have many entries under `/dev/pts` that belong to root, so take note of the one that does after running the above command and then `sudo chmod` or `sudo chown` it to make it usable for your normal user and then tell your debugger to use that as your serial connection to your remote debugging target.


Reply

#3
Another solution is to grant you (or the gdb executable) the rights to make some pcap captures as [mentioned here][1]. With something like this :

setcap cap_net_raw,cap_net_admin=eip /usr/bin/gdb

you should be able to allow to capture packets to gdb without being root.

[1]:

[To see links please register here]

Reply

#4
this question was asked a long time ago but if this will help to anybody I open a bug in bugzilla and this short thread solved the problem:
[bugzilla bug][1]


[1]:

[To see links please register here]

Reply

#5
You can use gdbserver on localhost to attach a existing process, the following is the command line:

sudo gdbserver :<listening port> --attach <pid>

Or you can create a new process using gdbserver:

sudo gdbserver :<listening port> <process executable>

Then you can create a debugging configuration in Eclipse, in the debugger tab, the debugger item, select gdbserver, and input the listening port in the connection tab in the bellow.
Reply

#6
Launch Eclipse with sudo (just for completeness:

[To see links please register here]

)

Update: Follow xmoex solution. If you run Eclipse as root (ie. using sudo) your files will be root-owned... which you probably don't want.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through