Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Remote debugging a Linux process from CDT on Windows(Has anyone achieved this? What's the knack?)
Remote debugging a Linux process from CDT on Windows [message #553452] Tue, 17 August 2010 15:04 Go to next message
Robin Fernandes is currently offline Robin FernandesFriend
Messages: 5
Registered: July 2009
Junior Member
Hi all,

I am running Eclipse CDT on Windows to develop C code that is built & tested on remote Linux systems. Currently, the code is only compiled on Linux - never on Windows.

My aim is to remotely debug a Linux process from the Windows CDT environment. The RSE FAQ describes two general approaches to achieve this:


  • Option 1: Launch the gdb client on the remote system over ssh.
  • Option 2: Use a cross-debugging version of the gdb client that can run on the Windows development system and understand the remote Linux process data fed to it by gdbserver.


Option 1 seems more simple. The idea is simply to replace the gdb command in the debug launch configuration with e.g. "plink remotehost gdb". However, this fails, because many fields in the launcher are forcefully tied to the local system. For example, the project directory must be a path on the system on which CDT is running. Consequently, when gdb runs on the remote host, it fails with errors like:

Error in final launch sequence
Failed to execute MI command:
-environment-cd "C:/code/helios.workspace/Build Test C"
Error message from debugger back end:
C:/code/helios.workspace/Build Test C: No such file or directory.


Where "C:\code\helios.workspace\Build Test C" is a path on the Windows system where CDT is running, so is of course not found on the remote Linux system where gdb is running. So question 1 is: has anyone ever successfully launched a debug session from CDT using gdb over ssh from CDT, and if so, how?

Option 2 should be as simple as getting hold of / building the appropriate flavour of gdb. So question 2 is: does anyone know where I can find a cross-build of gdb that will allow me to debug Linux processes from a Windows system, or where I can find instructions to build one myself? Smile


Many thanks,
-R

[Updated on: Tue, 17 August 2010 15:42]

Report message to a moderator

Re: Remote debugging a Linux process from CDT on Windows [message #553582 is a reply to message #553452] Wed, 18 August 2010 06:11 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
http://www.embedded-linux.co.uk/tutorial/eclipse-rse


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Remote debugging a Linux process from CDT on Windows [message #553615 is a reply to message #553582] Wed, 18 August 2010 08:22 Go to previous messageGo to next message
Thomas .Friend
Messages: 32
Registered: July 2009
Member
Thanks for the tutorial. However, I need to go for Robin's option 1, because for my toolset no cross tool versions are available. Even worse, it's not a gdb. Any chance to achieve remote debugging?
Re: Remote debugging a Linux process from CDT on Windows [message #553732 is a reply to message #553615] Wed, 18 August 2010 15:51 Go to previous messageGo to next message
andreyvo  is currently offline andreyvo Friend
Messages: 3
Registered: August 2010
Junior Member
Two little helper scripts to run gdb on remote linux target from eclipse ssh needed (I'm using cygwin ssh client):

dbg.cmd - windows gdb wrapper:
c:\cygwin\bin\ssh.exe userlogin@targethost "~/[B]debug.sh[/B] '%*'"


debug.sh - bash helper script on target linux machine:
#!/bin/bash  

# Delete windows drive letter from gdb cmd line parameters
options=${@//C:\\/}
# replace backslashes
options=${options//\\/\/}
# replace possible path inconsistencies
options=${options//SambaPathToProject/\/LinuxPathToProject}

sed -u -e 's/\\/\//g'| \
sed -u -e "s/C:\/SambaPathToProject/\/LinuxPathToProject/g"| \
gdb ${options}

Re: Remote debugging a Linux process from CDT on Windows [message #553830 is a reply to message #553732] Thu, 19 August 2010 06:31 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Cool. Can you add this to the CDT Wiki, please?
-> http://wiki.eclipse.org/CDT/User/FAQ


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Remote debugging a Linux process from CDT on Windows [message #553884 is a reply to message #553732] Thu, 19 August 2010 09:57 Go to previous messageGo to next message
Thomas .Friend
Messages: 32
Registered: July 2009
Member
Quote:
Two little helper scripts to run gdb on remote linux target from eclipse ssh needed (I'm using cygwin ssh client).

I understand that you don't use the RSE or TM or however it is called, but a call to an Eclipse-external ssh tool (cygwin in your case, putty as an alternative).
Is this stil necessary? The Remote C/C++ project creates a "Remote Build" service via an RSE connection. Couldn't we make use of that service?
Re: Remote debugging a Linux process from CDT on Windows [message #553912 is a reply to message #553732] Thu, 19 August 2010 12:06 Go to previous messageGo to next message
Robin Fernandes is currently offline Robin FernandesFriend
Messages: 5
Registered: July 2009
Junior Member
andreyvo wrote on Wed, 18 August 2010 11:51
debug.sh - bash helper script on target linux machine:
#!/bin/bash  

# Delete windows drive letter from gdb cmd line parameters
options=${@//C:\\/}
# replace backslashes
options=${options//\\/\/}
# replace possible path inconsistencies
options=${options//SambaPathToProject/\/LinuxPathToProject}

sed -u -e 's/\\/\//g'| \
sed -u -e "s/C:\/SambaPathToProject/\/LinuxPathToProject/g"| \
gdb ${options}




Thanks for your reply! Unfortunately, I've had no luck with this sort of script: CDT seems to send some paths to the remote process over gdb/mi after launching it, so the paths are not as command line arguments. There's an open bug here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=252758 .

Could you share how you got around this? There are many options that can be configured in the launch (process launcher, debugger, protocol etc...). Perhaps you have some combination of launcher config parameters which ensures the paths are only passed on the command line?

[Updated on: Thu, 19 August 2010 13:29]

Report message to a moderator

Re: Remote debugging a Linux process from CDT on Windows [message #554714 is a reply to message #553912] Tue, 24 August 2010 08:19 Go to previous messageGo to next message
andreyvo  is currently offline andreyvo Friend
Messages: 3
Registered: August 2010
Junior Member
sed -u -e 's/\\/\//g'| sed -u -e "s/C:\/SambaPathToProject/\/LinuxPathToProject/g"| gdb ${options}

sed commands in front of gdb being used to convert window paths to unix style paths on the fly: all the input (stdin) from CDT first processed by sed replacing C:\SambaPathToProject\ with /LinuxPathToProject/ - and all backslashes/drive letters got replaced. Obviously you need tweak it a bit to match your code/binary locations
Re: Remote debugging a Linux process from CDT on Windows [message #559512 is a reply to message #554714] Thu, 16 September 2010 23:11 Go to previous messageGo to next message
Steven Hubbell is currently offline Steven HubbellFriend
Messages: 1
Registered: September 2010
Junior Member
I appear to be stuck at an earlier step. It appears I have no option in Helios to create a Remote C/C++ project.

If I look at the debug configurations on a existing project, I only see C/C++ Application, Attach to Application, or Postmortem Debugger.

No remote options.

Suggestions?
Re: Remote debugging a Linux process from CDT on Windows [message #559865 is a reply to message #559512] Mon, 20 September 2010 07:35 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Steven Hubbell wrote on Fri, 17 September 2010 01:11
I appear to be stuck at an earlier step. It appears I have no option in Helios to create a Remote C/C++ project.

If I look at the debug configurations on a existing project, I only see C/C++ Application, Attach to Application, or Postmortem Debugger.

No remote options.

Suggestions?

You need the RSE plugin.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Remote debugging a Linux process from CDT on Windows [message #634894 is a reply to message #559865] Sun, 24 October 2010 23:45 Go to previous messageGo to next message
pablo  is currently offline pablo Friend
Messages: 3
Registered: October 2010
Junior Member
Axel, I installed the RSE plugin but the debug configurations options still are "C/C++ Application, Attach to Application and Postmortem Debugger".

How can I execute the remote debug?

Sorry for my bad english

Thank you very much in advance.
Re: Remote debugging a Linux process from CDT on Windows [message #634901 is a reply to message #634894] Mon, 25 October 2010 01:44 Go to previous messageGo to next message
pablo  is currently offline pablo Friend
Messages: 3
Registered: October 2010
Junior Member
pablo wrote on Sun, 24 October 2010 19:45
Axel, I installed the RSE plugin but the debug configurations options still are "C/C++ Application, Attach to Application and Postmortem Debugger".

How can I execute the remote debug?

Sorry for my bad english

Thank you very much in advance.


Well. I configured an entry under "C/C++ Application" using "Standar create process launcher" instead of "GDB (DSF) create process launcher" and gdb.cmd (according andreyvo's tip) as the "GDB Debugger".

The debug process is launched correctly (progress = 57% according to the status bar) but after a few seconds an error occurs:

Error creating session
Target is not responding (timed out)

The console show:

13-gdb-set confirm off
(gdb)
14-gdb-exit

In the remote host I created a file containing the gdb output (using tee). The content is:

(gdb)
13^done
(gdb)

I am clueless. Somebody can help me?

Thanks again!

I'm using gdb 6.3 under OpenBSD 4.5
Re: Remote debugging a Linux process from CDT on Windows [message #634924 is a reply to message #634894] Mon, 25 October 2010 07:19 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
pablo wrote on Mon, 25 October 2010 01:45
Axel, I installed the RSE plugin but the debug configurations options still are "C/C++ Application, Attach to Application and Postmortem Debugger".

How can I execute the remote debug?

Sorry for my bad english

Thank you very much in advance.

You need the plugin "C/C++ Remote Launch".


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Remote debugging a Linux process from CDT on Windows [message #635046 is a reply to message #634901] Mon, 25 October 2010 14:20 Go to previous message
pablo  is currently offline pablo Friend
Messages: 3
Registered: October 2010
Junior Member
pablo wrote on Sun, 24 October 2010 21:44
pablo wrote on Sun, 24 October 2010 19:45
Axel, I installed the RSE plugin but the debug configurations options still are "C/C++ Application, Attach to Application and Postmortem Debugger".

How can I execute the remote debug?

Sorry for my bad english

Thank you very much in advance.


Well. I configured an entry under "C/C++ Application" using "Standar create process launcher" instead of "GDB (DSF) create process launcher" and gdb.cmd (according andreyvo's tip) as the "GDB Debugger".

The debug process is launched correctly (progress = 57% according to the status bar) but after a few seconds an error occurs:

Error creating session
Target is not responding (timed out)

The console show:

13-gdb-set confirm off
(gdb)
14-gdb-exit

In the remote host I created a file containing the gdb output (using tee). The content is:

(gdb)
13^done
(gdb)

I am clueless. Somebody can help me?

Thanks again!

I'm using gdb 6.3 under OpenBSD 4.5



I try it on SUSE Linux Enterprise Server 10 (gdb 6.6) on the server side and everything works OK! (without any RSE plugin).

Only two mods to andreyvo's script:
1.- options=${@//C:\\/\/} instead of options=${@//C:\\/}
2.- convert back paths to windows' paths on gdb output

Regards




Previous Topic:CTRL+D & console in cdt
Next Topic:help with g++ error report -> Error 2 ?
Goto Forum:
  


Current Time: Fri Nov 22 14:47:27 GMT 2024

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

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

Back to the top