Author Topic: Debug Linux Executable From Windows XP  (Read 11038 times)

avgarrison

  • Community Member
  • Posts: 6
  • Hero Points: 0
Debug Linux Executable From Windows XP
« on: February 21, 2008, 09:28:01 PM »
I'm trying to setup SlickEdit 12.0.0.0 (running on Windows XP) to debug a remote process running on a Linux machine (running RHEL 4.0).

First, I start the gdbserver on the Linux machine:
> gdbserver host:8000 ./process

Then I switch over the Windows XP machine and do a Debug->Attach Debugger->Attach to Remote Process using GDB...

However, when I attempt to connect to the process, I get the following error:
"Remote register badly formatted: T0506: 00000000000....." and so on

I have been reading about this for the better part of today and I think that I may have to setup SlickEdit to use a cross-gdb, but I'm not really sure why, or how to do that.  Does anyone know of any solid documentation of how to do this?  Does anyone know if this is in fact my problem?

Thank you.

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Re: Debug Linux Executable From Windows XP
« Reply #1 on: February 22, 2008, 03:10:17 PM »
Presumably you're pointing SE (and, hence the local gdb) at a copy of the processs that's being debugged on RH?

avgarrison

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: Debug Linux Executable From Windows XP
« Reply #2 on: February 22, 2008, 03:13:32 PM »
Yes.  I have a drive on the Windows XP machine that is mapped to a samba share on the Linux machine.  I point SlickEdit to the actual executable that is being ran on the Linux machine.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Debug Linux Executable From Windows XP
« Reply #3 on: February 22, 2008, 04:35:24 PM »
I think you need to add a cross-gdb. See Debug>Debugger Options: Configurations tab.
There you can add your cross-gdb. When starting a debug session you can specify that this add. gdb is used e.g. when attaching to a remote process using 'gdbserver'.
HS2

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Re: Debug Linux Executable From Windows XP
« Reply #4 on: February 22, 2008, 04:46:43 PM »
OK. If the target were non-x86 the cause would be simple: you need a gdb compiled to run on the local machine (i.e. XP) but that knows about the target architecture (RH). However, I'm not sure if this is the case for something like RH where it's the same CPU as the host.

I'd hazard an uneducated guess that your RH box is not a common or garden i386 but something like an AMD64?

Do you have Cygwin installed on XP?

avgarrison

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: Debug Linux Executable From Windows XP
« Reply #5 on: February 22, 2008, 04:54:06 PM »
The PCs are actually using identical hardware.  Same CPU (which is a 64-bit Xeon quad-core), same everything.  Does this situation require a cross debugger?

I just noticed that the Linux machine is running gdb version 6.4 and the Slick Edit 2007 gdb version is 6.5.  Do you think that could be the problem?
« Last Edit: February 22, 2008, 05:01:13 PM by avgarrison »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Debug Linux Executable From Windows XP
« Reply #6 on: February 22, 2008, 05:04:57 PM »
But since the SE gdb tells 'This GDB was configured as "i686-pc-cygwin" I think you've to use the approriate cross-gdb configured for your actual 'real' linux target. The executable formats are different.
AFAIK gdb up to v6.6 (at least) is verified to work. I'm using a cross (PPC-)gdb v6.5 with SE.
HS2

avgarrison

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: Debug Linux Executable From Windows XP
« Reply #7 on: February 22, 2008, 05:53:20 PM »
I am guessing that I want a gdb that is configured for 'i686-pc-linux'?

I've been pouring over the internet for what seems like ages.  Do you have any links to good documentation for dumb people on how to configure and compile a cross gdb?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Debug Linux Executable From Windows XP
« Reply #8 on: February 22, 2008, 06:25:19 PM »
Sorry - I'm also just a user of the cross-gdb. I didn't build it myself. It's part of the cross tool chain I'm using.
In any case you'll need a cygwin environment installed on your WXP machine to build and run the 'i686-pc-linux' cross-gdb.
Good luck, HS2

avgarrison

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: Debug Linux Executable From Windows XP
« Reply #9 on: February 25, 2008, 08:11:34 PM »
I finally figured this out.  I had to download the source for GDB and compile the same source on Linux and on Windows (using Cygwin).
For Linux, I had to provide the host parameter:
Code: [Select]
tar -xzf gdb-6.4.tar.gz
cd gdb-6.4
./configure --host=i686-pc-linux-gnu
make
make install

In Windows, I compiled the same source through Cygwin.  Here I provided a host and target parameter, although it may not have been necessary:
Code: [Select]
tar -xzf gdb-6.4.tar.gz
cd gdb-6.4
./configure --host=i686-pc-cygwin --target=i686-pc-linux-gnu
make
make install

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Debug Linux Executable From Windows XP
« Reply #10 on: February 25, 2008, 10:16:52 PM »
Congrats ! Sometimes this kind of stuff is hard to get it working...