Home Products Documentation Wiki Support Download Showroom Contact us Where to buy
The information on this page is nolonger maintained.
For current product information visit the new Axis Developer web site on www.axis.com/products/dev/
For current developer information visit the Axis Developer WIKI
  » Debugging user mode applications

Documentation

Overview

Software

Overview

  SDK

  Compiler

  Debugger

Hardware

  Chips

  ETRAX FS

  ETRAX 100LX

  ETRAX 100LX MCM

  Developer boards

  Developer board 82+

  Developer board LX

Old Documentation

  Old documentation page

  Old software page

 

Debugging User Mode Applications

Please note that you should always set the correct paths when debugging an application which uses shared libraries.

Make Debug

To be able to debug a program, you must build it with debugging in mind. With the Developer Board 82/LX SDK there is a make target that does this for you, called 'debug' (check Rules.axis for details). To build your application for debugging, simply 'make debug' (and 'make nodebug' to reverse the effect') before 'make' and 'make install'.

Below follows a summary of what 'make debug' does (and what you need to do if you don't use it). 

  • Adds -g to the compiler flags. This will include debug information in the program. (The default debug format is Dwarf-2.) 
  • Removes -s (which strips the program from its symbol information) from the link flags. (If your program is in ELF format, the 'file' command will tell you whether it's stripped or not.) The symbols are only needed on the host side when debugging, and 'make install' automatically strips the binary when putting it in the install directory (/bin, for example).
  • Turns off optimizations (adds -O0 to the compiler flags).  This makes it easier to debug the program, but it may affect the behaviour. You can debug optimized code, but be aware that the compiler has probably rearranged the execution order of your statements. Also, variables may have been optimized away.
  • Adds -fno-omit-frame-pointer to your compiler flags. This is a nop when the optimization level is set to 0, but it's there as a reminder that you should keep it if you change the debug optimization level (gcc optimizations starting at -O2 imply -fomit-frame-pointer). The frame pointer acts as a local stack pointer inside a function, and will be placed in register r8.

Starting a Program

Telnet, or log in via the serial port (if you have agetty on that port) to your board. The preferred way to communicate with gdb on the host side is over TCP/IP. On the target:

gdbserver [<hostname/ip address>]:<port> <program>

Example: gdbserver hostname:1234 /tmp/hello_world

Now start gdb-cris on the host. To connect to the target:

target <hostname/ip address>:<port> (make sure you specify the same port number)

Example: (gdb) target remote 10.13.8.122:2345

To debug over a serial connection, make sure it is enabled in the kernel configuration (under "Drivers for Etrax built-in interfaces") and not used for anything else. One of the ports is often used by the kernel for debug printouts, or agetty might be using it (check your /etc/inittab). On the target:

gdbserver <device> <program>

Example: gdbserver /dev/ttyS2 /tmp/hello_world

Then start gdb-cris on the host.  To connect you need to specify what device on the host you have connected the serial cable to:

target remote <device>

Example: (gdb) target remote /dev/ttyS0

After you have connected to the target, you will end up in the startup routine for the C library the application is using (often called _start). To get to the main function of your application, simply

(gdb) until main

Attaching to a Process

You may attach to an already running process by giving the process id as an argument to the gdbserver:

gdbserver [<hostname/ip address/device>]:<port> <pid>

Example: gdbserver hostname:2345 32

© Axis Communications, All Rights Reserved.

Contact  | Axis Sites  | Privacy Statement