Debugging Apps with gdb

How to analyze an app with GDB

The instructions below use the global_navigation example application for the Auterion SDK. The method explained is valid for any C++ application for AuterionOS.

  1. Remove the CMD line for the executable you would like to debug from your Dockerfile so you can start it manually:

CMD . /opt/ros/humble/setup.sh && \
    /opt/sysroot/app/build/global_navigation
  1. Install gdb by adding this line to the end of your app's Dockerfile:

RUN apt update && apt install -y gdb && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*
  1. Compile with debugging flags, for use with gdb by adding -DCMAKE_BUILD_TYPE=Debug to cmake in your dockerfile:

RUN . /opt/sysroot/opt/ros/humble/setup.sh && \
    cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=/Toolchain_$TARGETARCH.cmake 
    -DCMAKE_BUILD_TYPE=Debug && cmake --build build
  1. Copy the source code from the build stage of your Dockerfile:

COPY --from=build-stage /opt/sysroot/app/src /opt/sysroot/app/src
  1. Start a container with the docker image of the modified app:

root@skynode-111261566:~# docker run -it 0d47ef72670b

root@2fdac2bb88c5:/# source /opt/ros/humble/setup.sh
  1. Start gdb with your executable:

  1. Add breakpoints and run your executable:

Last updated