Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Remote debugging from Windows to Linux
Remote debugging from Windows to Linux [message #838366] Sat, 07 April 2012 00:36 Go to next message
Gerald Dalley is currently offline Gerald DalleyFriend
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 17:32 Go to previous messageGo to next message
Michael Spertus is currently offline Michael SpertusFriend
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).



  1. 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.
  2. 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.
  3. Install MinGW on your Windows box (I had trouble building gdb on cygwin, so I recommend MinGW).
  4. 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.
  5. In the expat directory. "./configure --enable-shared", make, make install.
  6. Download the gdb sources
  7. ../gdb-7.4/configure --with-expat --target=x86_64-unknown-linux-gnu --host=i686-pc-mingw32
  8. make, make install
  9. Time to test. On your linux box, create and compile hello.cpp to hello.
  10. 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.
  11. Copy hello.cpp and hello to your Windows machine
  12. 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.
  13. In gdb, load the executable with "file hello"
  14. target remote localhost:4444 Note: This assumes that you have an ssh tunnel on localhost. Modify appropriately.
  15. Verify that gdb commands like break, cont, and run work here.
  16. 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.
  17. Launch Eclipse (finally!). New debug configuration C/C++ attach to process.
  18. In Main, give path to the copy of the Linux executable on the Windows system.
  19. 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.
  20. Make sure gdbserver is running (it often quits when the program ends) and launch the debug configuration
  21. 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 12:53]

Report message to a moderator

Re: Remote debugging from Windows to Linux [message #842278 is a reply to message #838798] Thu, 12 April 2012 06:33 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Very nice instructions. Can you add them to the CDT Wiki, please?
http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_debug_a_remote_application.3F


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 #982971 is a reply to message #838798] Tue, 13 November 2012 15:22 Go to previous messageGo to next message
Stefan Mueller is currently offline Stefan MuellerFriend
Messages: 4
Registered: November 2012
Junior Member
Hi Mike,

thanks for your step-by-step instructions!

Following them, I finally was able to connect the Eclipse Indigo SR2 gdb console on a Windows machine to a running hello world program on a x86_64-suse-linux.

In the gdb console, I run the commands
file hello
break main
run

Unfortunately, I get no connection to the source file, although I added the path to the file hello.c as Source in the debug configuration.

In the gdb console in Eclipse I get the following error messages:
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: Could not load shared library symbols for 2 libraries, e.g. /lib64/libc.so.6.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?


Is there still a step missing?
Did you manage to attach the source to the running gdb instance, so that you could for example set breakpoints directly in the code?

Best regards,
Stefan
Re: Remote debugging from Windows to Linux [message #984508 is a reply to message #982971] Wed, 14 November 2012 19:12 Go to previous messageGo to next message
Maneesh Singh is currently offline Maneesh SinghFriend
Messages: 6
Registered: November 2012
Junior Member
Hi Stefan,

You need to make sure you have the needed shared libs in the relative path from where you are launching your hello program and then set the solib-search-path to these libraries.
For example, for me the path from where I am running the hello program is
C:\MinGW\msys\1.0\home\Maneesh\hello.exe

so i create two more folders as /usr/lib64 and /lib64 and copy the respective libraries in there. Next when debug the program set the solib-search-path to say C:\MinGW\msys\1.0\home\Maneesh\usr\lib64;C:\MinGW\msys\1.0\home\Maneesh\lib64 and you should be good.

First try it out directly from the command prompt. Once it starts working there, do teh same settings in Eclipse.

@Michael
Thanks for an elaborate procedure on debugging on a ermote linux machine from Windows using Eclipse. I am able to debug a simple Hello World program so far with minor changes of path and other settings here and there.

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.
Re: Remote debugging from Windows to Linux [message #985255 is a reply to message #984508] Thu, 15 November 2012 09:06 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
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 10:25 Go to previous messageGo to next message
Maneesh Singh is currently offline Maneesh SinghFriend
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 10:26]

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 Go to previous messageGo to next message
Stefan Mueller is currently offline Stefan MuellerFriend
Messages: 4
Registered: November 2012
Junior Member
Hi,

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?

Regards,
Stefan


Re: Remote debugging from Windows to Linux [message #985930 is a reply to message #985638] Fri, 16 November 2012 17:45 Go to previous messageGo to next message
Maneesh Singh is currently offline Maneesh SinghFriend
Messages: 6
Registered: November 2012
Junior Member
I upgraded to Juno SR1 and am facing the same issue - no process connection dialog comes up when I click on "connect to a process" icon.
Re: Remote debugging from Windows to Linux [message #986022 is a reply to message #985930] Sat, 17 November 2012 15:37 Go to previous messageGo to next message
Maneesh Singh is currently offline Maneesh SinghFriend
Messages: 6
Registered: November 2012
Junior Member
I checked the eclipse logs and it shows the following exceptions:
!ENTRY org.eclipse.ui 4 0 2012-11-17 20:45:07.331
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)




I tried ignoring this error. I executed a process on the remote machine as
\>gdbserver --attach :5555 <pid of the process>
Attached; Pid = <pid>
Listening on port 5555


And in Eclipse I set the debug configuration as "Attach to Application" using GDB(SDF) Attach to Process Launcher configuration. I set the application path, path to source and also path to gdb. The I launched the debugging.

At remote: I see, "Remote Debugging from host XXX.XXX.XXX.XXX"

In eclipse on local machine I see the following:
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.


Any idea what could be going wrong.

I think the procedure to perform remote debugging should also describe these minute settings so that one can follow it up easily. I know its like spoon feeding, but then missing even a minor step/setting can make you wonder for ages Smile

Regards,
Maneesh
Re: Remote debugging from Windows to Linux [message #987102 is a reply to message #986022] Fri, 23 November 2012 13:44 Go to previous messageGo to next message
Stefan Mueller is currently offline Stefan MuellerFriend
Messages: 4
Registered: November 2012
Junior Member
Hi Maneesh,

what happens, when you use the file command?
E.g. enter the following in the gdb console:
file name_of_local_linux_executable

Regards,
Stefan
Re: Remote debugging from Windows to Linux [message #990173 is a reply to message #987102] Tue, 11 December 2012 09:43 Go to previous messageGo to next message
Maneesh Singh is currently offline Maneesh SinghFriend
Messages: 6
Registered: November 2012
Junior Member
I checked and I get the following error:

"No such file or directory".

I am not sure why would file return this error as the binaries are present. I tried both with the relative and absolute path of to the binaries.

Regards,
Maneesh
Re: Remote debugging from Windows to Linux [message #990787 is a reply to message #985930] Fri, 14 December 2012 09:47 Go to previous messageGo to next message
Markus Henschel is currently offline Markus HenschelFriend
Messages: 6
Registered: July 2009
Junior Member
Maneesh Singh wrote on Fri, 16 November 2012 12:45
I upgraded to Juno SR1 and am facing the same issue - no process connection dialog comes up when I click on "connect to a process" icon.


Hi. I also have the very same issue. It works fine in Helios but when using Indigo or Juno the process selection dialog doesn't show up. I tried a different version of GDB. When downgrading to gdb 6.8 (used 7.0 before) I get a dialog box asking for the process ID to attach to but after entering it nothing happens. With GDB 7.0 I can see in the GDB traces that a process list is sent. A lot of process names show up there. But the process selection dialog isn't displayed. I don't think there's anything wrong with my toolchain because it's working fine with the helios release.

I'm running the 32 bit version of eclipse under Windows 7 64 bit and the target system is Linux. So may be this bug fix that went into Indigo and Juno did break something else.

Did you already file a bug report?
Re: Remote debugging from Windows to Linux [message #990964 is a reply to message #990787] Sat, 15 December 2012 15:16 Go to previous messageGo to next message
Maneesh Singh is currently offline Maneesh SinghFriend
Messages: 6
Registered: November 2012
Junior Member
Hi Markus,

I haven't filed any bug on this yet. I am actually not aware of the process of filing a bug report. Moreover, was thinking if this was one odd issue and so did not think of filing a bug and was looking for a resolution in the forum.

I think, as three of us(including Stefan) are facing this issue, I guess this might be an issue left out in Juno release, we must file a bug report.

Please do let me know if you are filing a bug or else I ll figure out how to do it and then go ahead and do it.

Also, please do let me know if you were able to do rest of the setting properly for remote debugging and you got any success with it.

With Best Regards,
Maneesh Singh
Re: Remote debugging from Windows to Linux [message #991083 is a reply to message #990964] Mon, 17 December 2012 10:17 Go to previous messageGo to next message
Markus Henschel is currently offline Markus HenschelFriend
Messages: 6
Registered: July 2009
Junior Member
I found an existing bug report and added some comments to it:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396386

You can vote for it to get processed more quickly.
Re: Remote debugging from Windows to Linux [message #991153 is a reply to message #991083] Mon, 17 December 2012 14:40 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
This sounds related to the problem and solution described here:
http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg25071.html

Marc
Re: Remote debugging from Windows to Linux [message #1128325 is a reply to message #838798] Mon, 07 October 2013 15:16 Go to previous messageGo to next message
Sergiy Kholod is currently offline Sergiy KholodFriend
Messages: 1
Registered: October 2013
Junior Member
Hi,

Can you help to build gdb-7.2 (for remote debugging) with cygwin or mingw?

I got an error "*** multiple target patterns. Stop.", when run "make" command. Any advice?

Thanks
Re: Remote debugging from Windows to Linux [message #1703106 is a reply to message #1128325] Tue, 28 July 2015 14:50 Go to previous messageGo to next message
Mohamed Abdelazim is currently offline Mohamed AbdelazimFriend
Messages: 4
Registered: July 2015
Junior Member
Instead of gdbserver you can use the following plugin directly
http://marketplace.eclipse.org/content/direct-remote-c-debugging

It just needs to have ssh supported on the remote sever. The building and compiling must be done on the remote system only.

So nothing is required locally. All the debug features will be available locally too.
Re: Remote debugging from Windows to Linux [message #1703167 is a reply to message #838366] Wed, 29 July 2015 06:32 Go to previous messageGo to next message
dha nam is currently offline dha namFriend
Messages: 1
Registered: July 2015
Location: India
Junior Member
Nice post. Thanks for sharing!
Re: Remote debugging from Windows to Linux [message #1816781 is a reply to message #838366] Wed, 06 November 2019 19:29 Go to previous message
Feng Zhang is currently offline Feng ZhangFriend
Messages: 2
Registered: November 2019
Junior Member
I have made a new post at end of 2019 at stack over flow site, please search "Debug C/C++ application on linux through Eclipse".
Previous Topic:Debug configuration program selection
Next Topic:Problem when trying to run a successfully compiled program from eclipse
Goto Forum:
  


Current Time: Thu Mar 28 12:29:10 GMT 2024

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

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

Back to the top