Basic Debugging

When developing new software for ONIE sometimes you need a little help.


The strace(1) utility is very handy when developing and debugging programs. Use it at runtime on the target platform to trace the system calls made by a program.

Dynamic Libraries

When trying to debug which dynamic libraries a program is trying to load the ldd(1) utility is very handy. Doing this in an embedded cross-compile environment, however, can be a little challenging. The ONIE project does not have ldd exactly, but we offer something very close.

At runtime on the target platform you can get basic LDD information by setting the environment variable LD_TRACE_LOADED_OBJECTS=1. For example:

ONIE:/ # LD_TRACE_LOADED_OBJECTS=1 /usr/bin/grub-mkimage => /usr/lib/ (0x7fc806c29000) => /lib/ (0x7fc806a14000) => /lib/ (0x7fc8067c8000) => /lib/ (0x7fc8065b0000) => /lib/ (0x7fc8063a3000) => /lib/ (0x7fc80619f000) => /lib/ (0x7fc806e62000)

For debugging LDD at build time the ONIE project includes a cross-ldd you can run on your build host. The cross-ldd is implemented as a Makefile target. The core of cross-ldd comes from the crosstool-NG project.

For example to inspect the PowerPC /usr/bin/dropbearmulti binary from your x86_64 build host you would invoke the Makefile ‘ldd’ target like this:

monster-04:~/onie-cn/onie/build-config$ gmake -j48 MACHINEROOT=../machine/nxp MACHINE=nxp_p2020rdbpca ldd LDD_TARGET=usr/bin/dropbearmulti => /lib/ (0xdeadbeef) => /lib/ (0xdeadbeef) => /lib/ (0xdeadbeef) => /lib/ (0xdeadbeef) => /usr/lib/ (0xdeadbeef) => /lib/ (0xdeadbeef) => /lib/ (0xdeadbeef)