eviljack
eviljack

Reputation: 3716

How to debug a remote linux binary?

Here is the situation:

I've got a linux binary that is crashing. No log files, trace files, etc. I need to be able to attach a debugger to it (I have the source locally) and track down the error.

Whats the easiest, best way to approach this problem?

Upvotes: 3

Views: 2772

Answers (2)

ks1322
ks1322

Reputation: 35708

Remote debugging is rather straightforward: on the target platform, launch the application with GDBserver, while specifying the host and port for listening to an incoming TCP connection:

  gdbserver HOST:PORT PROG [ARGS ...]

On the development workstation, launch the cross-target GDB:

  powerpc-7450-linux-gnu-gdb PROG

Be sure to specify the non-stripped executable. At the GDB console, type:

  target remote HOST:PORT
  break main
  continue

Remote cross-target debugging with GDB and GDBserver

Upvotes: 6

Douglas Leeder
Douglas Leeder

Reputation: 53310

It looks like gdb supports remote debugging.

I've never used it but http://davis.lbl.gov/Manuals/GDB/gdb_17.html looks like a start.

Basically you run the program under gdbserver on the target machine, and gdb connects (over TCP or serial) to the gdbserver.

Upvotes: 0

Related Questions