| Remote debugging from Windows to Linux [message #838366] |
Fri, 06 April 2012 20:36  |
Gerald Dalley Messages: 1 Registered: April 2012 |
Junior Member |
|
|
Is there a full description of every step needed to do remote cross-platform C++ debugging? I'm using the Indigo version of Eclipse CDT on Windows and would like to debug an application on a remote Linux machine.
On Windows, I do not have the ability to install a compiler or cygwin, but I do have plink and ssh on Windows. I am able to access the remote machine via RSE SFTP (a la stackoverflow.com/questions/4216822/work-on-a-remote-project-with-eclipse-via-ssh). I do have VNC but I find that the Eclipse IDE is very unresponsive under that setup, hence the desire to develop and debug from a native Windows app.
This FAQ is the most complete (wiki.eclipse.org/CDT/User/FAQ#How_do_I_debug_a_remote_application.3F), but doesn't discuss how to deal with Windows using backslash paths and having a different filesystem root compared to Linux and its forward slashes.
I am able to get a remote connection by playing around with the suggestions here (www.eclipse.org/forums/index.php?S=5e54b35462bb80f79ebb9fbbaf93a288&t=msg&th=173880), resulting in console output that looks like:
Last login: Fri Apr 6 20:19:09 2012 from foo.bar.com
echo $PWD'>'
/usr/bin/gdbserver :12345 /linux/path/to/my/binary args_to_my_binary;exit
but it fails with "Error while launching command: gdb --version"
The old FAQ is very incomplete and seems out of date: wiki.eclipse.org/TM_and_RSE_FAQ#How_can_I_do_Remote_Debugging_with_CDT.3F
This suggests it's possible but does not have sufficient details on how to set the myriad configuration options in Eclipse: stackoverflow.com/questions/6044138/remote-debugging-in-eclipse-cdt
I suspect many people would benefit if there was a clear set of instructions in one place on how to make this happen.
--Gerald Dalley
|
|
|
| Re: Remote debugging from Windows to Linux [message #838798 is a reply to message #838366] |
Sat, 07 April 2012 13:32   |
Michael Spertus Messages: 78 Registered: July 2009 |
Member |
|
|
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.
Good luck,
Mike
[Updated on: Mon, 09 April 2012 08:53] Report message to a moderator
|
|
|
|
|
|
| Re: Remote debugging from Windows to Linux [message #985255 is a reply to message #984508] |
Thu, 15 November 2012 04:06   |
Axel Mueller Messages: 1829 Registered: July 2009 |
Senior Member |
|
|
Maneesh Singh wrote on Wed, 14 November 2012 20:12
Now, I face the real issue here which is debugging a real process/daemon running on a Linux box, from Windows 7 using Eclipse.
Though, I did the exact settings, but still am unable to debug the process. The process is already running and is listening to another port for some messages. I receive the following errors:
Error in final launch sequence
Failed to execute MI command:
maintenance set python print-stack off
Error message from debugger back end:
Undefined maintenance set command: "python print-stack off". Try "help maintenance set".
Undefined maintenance set command: "python print-stack off". Try "help maintenance set".
You ve got any thought to it.
It seems your gdb does not have python support.
Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
|
|
|
| Re: Remote debugging from Windows to Linux [message #985348 is a reply to message #985255] |
Thu, 15 November 2012 05:25   |
Maneesh Singh Messages: 6 Registered: November 2012 |
Junior Member |
|
|
I am using Eclipse Indigo Service release 1. and CDT as 8.0.0. and the GDB is 7.5.
I believe there was a bug fixed(#367788) related to this issue, i just went through forum, and I found the following reply
https://bugs.eclipse.org/bugs/show_bug.cgi?id=367788
> How does one install his fix in Eclipse? What file do I install and how?
> Please specify in more details.
Eclipse Juno 3.7 (CDT 8.1) has the fix, as well as Eclipse Indigo 3.6.2 (CDT 8.0.2). If you are running an older Eclipse you will need to upgrade, or not use GDB 7.5.
So, does it mean, I need to upgrade to Juno 3.7(CDT 8.1) and should not use gdb 7.5 thought it is the latest.
Please advice.
Regards
[Updated on: Thu, 15 November 2012 05:26] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03545 seconds