Thursday, November 6, 2008

Remote debugging – an approach to debug embedded programs

In most cases, developers debug their programs locally. They run their code with debugger on the same machine. What if there is no mouse and keyboard on the target machine, such as a device, a POS terminal with a touch screen? You also want to see what happened behind the scene right? Remote debugging can give you the capability to do such a thing. I have an example which I have used for almost half a year and willing to share with you all.

This example is based on Linux ( Embedded Linux for the target machine, any Linux distribution for the debugger )

System requirement:

Target machine: gdbserver and the target application on Linux

Debugger machine: ddd with any Linux distribution

Steps to do:

Target machine: ( You need to have your app on this machine )

  1. ssh to the target machine

  2. gdbserver TARGET_IP:PORT TARGET_APP

Debugger machine: ( You need to have both source code and executable on this machine )

  1. ddd TARGET_APP

  2. In ddd command line, connect to the target:
    target remote TARGET_IP:PORT
    Turn off the following signals:
    handle SIG32 noprint nostop
    handle SIGPIPE noprint nostop
    handle SIGTRAP noprint nostop

  3. On the tool box of ddd, press CONT button to start the program

Now, you should be able to debug your program remotely.

No comments: