Author Topic: Debugging remote application in Linux (32-bits) from Windows (64-bits)  (Read 2874 times)

nelsonhf

  • Community Member
  • Posts: 47
  • Hero Points: 2
The application I want to debug is running in 32-bit Linux (KDE 3.5.5 "release 45") and my SlickEdit is 64-bits under Windows 7.
Apparently, the gdb installed with SE is 64-bits and will not connect to that environment: when I try to "Attach to remote process", I receive the error "The supplied gdb is built for debugging 64-bit programs only. You may need to configure a different version of GDB to debug 32-bit programs [...]".
Someplace else in the forums, someone implied that if you have a 64-bit Windows, you have a 64-bit GDB (and so, if you have a 32-bit windows you get a 32-bit GDB?). If you have a 32-bit GDB, how can I get it? I don't want to install a full 32-bits version of SE only to get the debugger, if at all possible (and would it run under 64-bit SE?).
I'm not sure if this will help, but I attached the log with the exchange between SE and GDB.
Thanks!

jporkkahtc

  • Senior Community Member
  • Posts: 2506
  • Hero Points: 206
  • Text




In the log, this error:
="localhost:8002: The system tried to join a drive to a directory on a joined drive
Means that GDB its trying to connect to the remote, but the remote isn't listening.
Since it is "localhost": It is expecting that there is a GDB server running on your machine listening on port 8002.


WRT 64 vs 32: It doesn't matter if Slick edit is 32 or 64 bit.
What matters is the local GDB: A GDB.exe can be built to support many different combinations of processors and OS's.
I think that you can build GDB.exe such that it has support for several.


In any case, your local GDB needs to be built to support 32-bit Linux
From a CMD window, try running "gdb --version"
For example on my machine, under cygwin:
$  gdb --version
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".


nelsonhf

  • Community Member
  • Posts: 47
  • Hero Points: 2
I found in my PC a GDB installed with Visual Studio named "i686-linux-gnu-gdb.exe".
I think my problem was trying to access "localhost". The program I am trying to debug is certainly NOT in my local machine!
In the remote, when I start the program under gdbserver, the last line it shows (waiting for the gdb client to connect) is:

Listening on port 2159

I put this number in the "Port" box under "Connect via socket" in the "Attach debugger" window that opens when you start a remote debug session with GDB and the program started running (after I clicked on the "play" button after waiting for a long time for a "starting debugging" message)!

A final warning for those trying to do what I was. If you receive a message like

Error starting debugger: GDB returned an error opening the executable
"w:\dir2\dir1\program": not in executable format


It may mean that what you thought was the program you want to debug is, in fact, a script to call it! As you can imagine, it just happened to me.

After I drilled down into the script and found the actual program, everything is working!

Linux utility "file" is your friend! (it shows / tries to guess the type of a file, e.g. text, script, executable, directory, etc)

Thanks for the help!