Author Topic: remote debugging from Windows XP of a linux process  (Read 10416 times)

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
remote debugging from Windows XP of a linux process
« on: May 26, 2008, 12:24:55 pm »
Hello,

This is my configuration :
- SlickEdit is installed on Windows XP
- I access my linux files thanks to SAMBA
- I've got X-Win 32 installed on Windows XP
- I compile on a Linux 64 bits machine (using a command "rsh" under SlickEdit build options)

On my linux machine, I've started gdbserver on port 8000
After, under SE :
 - "Attach debugger" -> "Attach to remote process using gdb". Here, I suppose "File" is for the binary file I want to debug (even if SE seems to wait for .exe file ...). And I connect via socket.
 - I've got the error : "Error starting debugger. GDB has terminated prematurely"

Could you please help me,
Best regards,



hs2

  • Senior Community Member
  • Posts: 2735
  • Hero Points: 287
Re: remote debugging from Windows XP of a linux process
« Reply #1 on: May 26, 2008, 03:02:06 pm »
I think you need a cross-gdb matching your target binary/architecture. HS2

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #2 on: May 27, 2008, 07:08:05 am »
Thanks for your answer HS2,

I don't have Cygwin installed on my PC and SE seems to need the library "cygwin1.dll".
I have download this dll and I have now another error :
> Remote register badly formatted: T0506: 00000000000....." and so on

I think the problem comes from an incompatibility of the two "gbd" (linux and windows)

GDB on Linux :
- gdb Red Hat Linux (6.3.0.0-1.63rh)
- configured as "i386-redhat-linux-gnu"

GDB on Windows (I have kept the default gdb installed with SE in "win" directory) :
- gdb 6.6
- configured as "i686-pc-cygwin"

Do you think I just have to compile the windows gdb using the following command ?

./configure --host=i686-pc-cygwin --target=i386-redhat-linux-gnu

hs2

  • Senior Community Member
  • Posts: 2735
  • Hero Points: 287
Re: remote debugging from Windows XP of a linux process
« Reply #3 on: May 27, 2008, 08:35:21 pm »
Quote
./configure --host=i686-pc-cygwin --target=i386-redhat-linux-gnu

Although it seems ok I've to admit that I didn't build a cross toolchain myself.
Sorry, but I'd propose to check the net for some further details...
HS2

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #4 on: May 28, 2008, 07:34:52 pm »
That's ok. I succeed in remote debugging.

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #5 on: May 28, 2008, 07:47:56 pm »
I try now to launch the debug using the accelerator key "F5" but SE is looking for the executable in the "Debug" directory. I compile using a "rsh" command which execute a script on the target. The compiled executable is in a specific directory and I can't find where to specify it into SE.

hs2

  • Senior Community Member
  • Posts: 2735
  • Hero Points: 287
Re: remote debugging from Windows XP of a linux process
« Reply #6 on: May 28, 2008, 10:53:28 pm »
Did you try to ''Attach Debugger>Attach to Remote Process using gdb' ?
I think this requires a previously started gdbserver on the target machine e.g. via rsh command.
And yes - remote debugging is a bit complicated ;)
HS2

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #7 on: May 29, 2008, 05:45:05 am »
Yes, if I do : ''Attach Debugger>Attach to Remote Process using gdb..."
And that's ok, I succeed in debugging, no problem.
I'm just looking for a way to start remote debug more quickly by doing 'F5' for example. Is that possible ?

hs2

  • Senior Community Member
  • Posts: 2735
  • Hero Points: 287
Re: remote debugging from Windows XP of a linux process
« Reply #8 on: May 29, 2008, 07:28:20 am »
Yes, it's possible. Depending on the things you need to do before 'F5' you might need to write a wrapper macro command, which in turn can be easily (re)bound e.g. to 'F5' using the key bindings configuration.
The wrapper macro could be something like this:
Code: [Select]
_command int gregos_b_debug_remote() name_info(','VSARG2_EDITORCTL|VSARG2_REQUIRES_MDI|VSARG2_READ_ONLY)
{
   shell ("rsh <launch gdbserver>");
   return debug_remote();
}

At the first step you an simply try to bind 'debug-remote' to 'F5'.
Good luck,
HS2
« Last Edit: May 29, 2008, 07:30:27 am by hs2 »

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #9 on: June 02, 2008, 05:56:40 am »
hs2,

I've tried this but remote_debug() only call the dialog "Attach Debugger". I would like to launch the debug automaticaly.

hs2

  • Senior Community Member
  • Posts: 2735
  • Hero Points: 287
Re: remote debugging from Windows XP of a linux process
« Reply #10 on: June 02, 2008, 08:55:27 pm »
I afraid that this is a question for the real experts - the SlickTeam .
Or you might rev.engineer debug_remote() and apply a patch/extension yourself...
HS2

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #11 on: June 25, 2008, 08:04:22 am »
First, thanks to hs2 for all your responses.

Now, I would like to remote debug a program which uses a dynamic library (.so) and I'd like to debug into this library. When I try to step into the library method, I've got a "segmentation fault" error. The program runs normally when I execute it directly a the Linux server.

I have seen that when a remote process dynamically loads libraries and we have to debug code in the shared libraries, we have to explicitely tell GDB to load the libraries by issuing a command to GDB from the SlickEdit command line after we have started the debugging session.

debug-send-command -file-symbol-file {library}

The command line execution is ok, it returns "^Done". But after that, I can't set breakpoint. I have the error message, something like that : "Gdb cannot set breakpoint : No attributs".

Any ideas ?
Best regards,
Greg
« Last Edit: June 27, 2008, 09:55:54 am by gregos_b »

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: remote debugging from Windows XP of a linux process
« Reply #12 on: June 27, 2008, 10:04:17 am »
I think that the command "-file-symbol" makes GDB lost old symbol table. I found the command :
add-symbol-file [filename] [address]
which should be used when filename has been dynamically loaded. The symbol table of the file [filename] is added to the symbol table originally loaded.

I execute this command without the adress argument however it seems to execute normally, but I still have an error when I try to step into a method of the shared library. The problem is that I don't know how to find this address. Does someone got any ideas ?