• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

Cross-compiling GDB

The GNU Project Debugger (GDB) allows you to see what is going on 'inside' another program while it executes -- or what another program was doing at the moment it crashed. This is useful when trying to find out why the program crashed.

This tutorial describes how to cross-compile GDB. Cross-compiling is the term used when compiling a program for an architecture other than that of the host computer's. In this case, the architecture of the STB. To use GDB to debug a program on the STB, GDB needs to run on the STB too.

The cross-compilation of GDB involves two steps. First the ncurses library is compiled, then GDB is compiled. The step-by-step examples are provided for both ST- and Broadcom-based STBs as below.

For Broadcom-based STBs (vip43x2)

  • Setup build ENV

    First of all, you need to download and install the toolchain provided with KREATV SDK. Contact customer support if you have any problem. After installation, check the toolchain path under /usr/local/kreatv to find your toolchain architecture, toolchain version and toolchain binary name. Match it with help of the following format.

    
    toolchain_path=/usr/local/kreatv/toolchain/<toolchain architecture>/<toolchain version>
    export <tool acronym>=$toolchain_path/bin/<toolchain binary name>-<tool name>
    

    The path of several compiler tools are made available to the build program by exporting them to the environment. Based on the above format, an example is provided below. Please replace the paths with what you actually get for your compiler. These are commands in bash, valid to use for instance in a bash console, in a bash script etc.

    
    toolchain_path=/usr/local/kreatv/toolchain/bcm15/2.2.1
    export CC=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-gcc
    export CXX=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-g++
    export AS=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-as
    export AR=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-ar
    export NM=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-nm
    export RANLIB=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-ranlib
    export STRIP=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-strip
    export SIZE=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-size
    export LD=$toolchain_path/bin/arm-kreatv-linux-gnueabihf-ld
    
  • Build ncurses

    Download ncurses source code and unpack.

    
    ./configure \
        --host=arm-kreatv-linux-gnueabihf \
        --target=arm-kreatv-linux-gnueabihf \
        --without-ada \
        --without-cxx-binding \
        --without-debug \
        --without-normal \
        --without-progs \
        --without-tests
    make
    
  • Build GDB

    Download and unpack the GDB source code. Adjust the paths in the following example to match your directories.

    
    toolchain_path=/usr/local/kreatv/toolchain/bcm15/2.2.1
    export CFLAGS=" -I/tmp/sdk/ncurses/ncurses-5.9/include"
    export CXXFLAGS=" -I/tmp/sdk/ncurses/ncurses-5.9/include"
    export LDFLAGS=" -L/tmp/sdk/ncurses/ncurses-5.9/lib -L$toolchain_path/arm-kreatv-linux-gnueabihf/lib -L$toolchain_path/arm-kreatv-linux-gnueabihf/sys-root/lib -L$toolchain_path/arm-kreatv-linux-gnueabihf/sys-root/usr/lib"
    
    ./configure \
        --host=arm-kreatv-linux-gnueabihf \
        --target=arm-kreatv-linux-gnueabihf \
        --disable-dependency-tracking \
        --disable-nls \
        --disable-werror \
        --with-included-regex \
        --without-expat \
        --without-python \
        --without-x
    make
    

Install GDB to bootimage

Add following IIP into your bootimage configuration and build to boot image.


kreatv-tool-include-file::/usr/bin/gdb=/tmp/sdk/gdb/gdb-kreatv/gdb-7.1/gdb/gdb

Assuming that your boot image configuration includes support for ssh, it can be used to access a command prompt on the STB after it has booted up. From the command prompt you can run GDB.

5.1.p5

Copyright (c) 2017 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.