Linux from Scratch - build debug tool (strace and gdb)

This note is written on Jan. 10, 2017.
Modified on Jan. 11, 2017 (add: build gdb)
Translated from Chinese on demand.
Tested on Lichee One.

1. Environment variable

export ARM_PREFIX=/home/lichee-rootfs
export ARM_HOST=arm-linux-gnueabihf
export ARM_CFLAGS=-I$ARM_PREFIX/include
export ARM_LDFLAGS=-L$ARM_PREFIX/lib
export PKG_CONFIG_PATH=$ARM_PREFIX/lib/pkgconfig

2. Build strace-4.8

Source: http://pkgs.fedoraproject.org/repo/pkgs/strace
version:strace-4.8.tar.xz (released on 2015-07-14)

In order to run on lichee, a patch must be made to the source code.
Same modifications should be made to the following files.

  • signal.c
  • syscall.c
  • util.c

origional code:

#elif defined(HAVE_LINUX_PTRACE_H)

modify to:

#endif
#ifdef HAVE_LINUX_PTRACE_H

Compile strace

./configure --prefix=$ARM_PREFIX --host=$ARM_HOST
make
make install

Build gdb-7.12

Source: https://ftp.gnu.org/gnu/gdb
Version: gdb-7.12.tar.xz (released on 2016-10-07)
Dependent tool: texinfo

sudo apt-get install texinfo
./configure --prefix=$ARM_PREFIX --host=$ARM_HOST
make
make install

I think it’s a English BBS :wink:

And they’re not Lichee One specific. (Zero can also use)

Please translate your document into english version, thanks a lot! :smile:

Should you find inaccurate narration please feel free to make corrections. (My major is mechatronics/hydraulic system control. Not familiar with IT terminology)

Oh so thanks for the translation :wink: