|Re: Remote debugging from Windows to Linux [message #838798 is a reply to message #838366]
||Sat, 07 April 2012 17:32
| Michael Spertus
Registered: July 2009
OK. I just spent the last two days figuring this out, so here are step-by-step instructions that hopefully will help others (This list is unusually anal by the standards of this group, but really simple concrete instructions would have helped me).|
- on the target linux box, make sure you have gdbserver. If you don't, get the gdb sources. Note: Making gdb does not build gdbserver. Instead, you have to go into the gdbserver directory and configure/make there.
- Run gdb on the linux box. In the startup banner, it will say what its target is. This will be something like x86_64-unknown-linux-gnu or i686-pc-linux-gnu. Remember this for later.
- Install MinGW on your Windows box (I had trouble building gdb on cygwin, so I recommend MinGW).
- Download expat from http://sourceforge.net/projects/expat/files/expat/2.1.0/.Note: Do not download the Windows expat installer. Download the sources instead.
- In the expat directory. "./configure --enable-shared", make, make install.
- Download the gdb sources
- ../gdb-7.4/configure --with-expat --target=x86_64-unknown-linux-gnu --host=i686-pc-mingw32
- make, make install
- Time to test. On your linux box, create and compile hello.cpp to hello.
- On your linux box, gdbserver :4444 hello
Note:If you are on a corporate network, non-standard ports may be blocked. Set up an ssh tunnel if necessary.
- Copy hello.cpp and hello to your Windows machine
- From the MinGW prompt, run "x86_64-unknown-linux-gnu-gdb ./Hello" Note: Substitute the name of the gdb you built as appropriate based on the target platform you got in step 2.
- In gdb, load the executable with "file hello"
- target remote localhost:4444 Note: This assumes that you have an ssh tunnel on localhost. Modify appropriately.
- Verify that gdb commands like break, cont, and run work here.
- Now we want to run it from outside of MinGW. In Control Panel/System/Advanced/Environment Variables add something like E:\MinGW\bin to the path. This is necessary for the loader to find libiconv_2.dll, etc. Now verify that you can do the preceding step from an ordinary Windows command prompt.
- Launch Eclipse (finally!). New debug configuration C/C++ attach to process.
- In Main, give path to the copy of the Linux executable on the Windows system.
- In Debugger tab, set Debugger dropdown to gdbserver. Set "GDB debugger" to something like "E:\MinGW\msys\1.0\local\bin\x86_64-unknown-linux-gnu-gdb.exe" based on where your gdb is. For Connection, choose TCP and fill in the hostname and port number you've been using from gdb in the previous steps.
- Make sure gdbserver is running (it often quits when the program ends) and launch the debug configuration
- In the gdb console, enter "file hello," "break main," and cont or run (sometimes it wants one. Sometimes the other) and voila, you should be there.
Let me know if this works, and I'll post it somewhere better.
[Updated on: Mon, 09 April 2012 12:53]
Report message to a moderator
|Re: Remote debugging from Windows to Linux [message #985638 is a reply to message #984508]
||Thu, 15 November 2012 15:08
| Stefan Mueller
Registered: November 2012
after copying the libraries to my local eclipse workspace\project folder, I am able to connect with my Eclipse Helios SR2 on Windows 7 via a version 7.5 gdbserver --multi :10000 on my Suse Linux box to a running process.
When I click on the green "Connect to a process" icon in the Eclipse Debug perspective, the process selection dialog is displayed with all processes running on my Linux box.
I select my process and my local source is displayed, where I can set breakpoints and step through the code.
But this works only with Eclipse Helios SR2.
With Eclipse Juno SR1 and Eclipse Indigo SR2, when I click on the "Connect to a process" icon, no process selection dialog is displayed.
I have attached the gdb traces from my Eclipse Juno SR1 and my Eclipse Helios SR2.
Is there a known bug with the process selection dialog in Eclipse Juno SR1 and Eclipse Indigo SR2?
Powered by FUDForum
. Page generated in 0.02608 seconds