Debugging and Profiling C++ Code on Linux

“Debugging and Profiling C++ Code on Linux” is a two-day training course with programming exercises taught by Thomas McGuire of The KDAB Group. It is offered at the Sheraton Bellevue Hotel from 9AM to 5PM on Saturday and Sunday, September 30th and October 1st (immediately after the conference). Lunch is included.

Course Description

This course teaches C++ developers the other side of the development story: the time spent writing C++ code is often dwarfed by the time required to find bugs and improve performance.

This training gives an introduction to various tools which help C++ developers and testers at finding bugs and performance issues of native applications written in C++ under Linux. The training is applicable to both desktop as well as embedded developers.

The tools presented cover a wide range of problems, from general purpose debugging and CPU profiling to domain-specific high-level analyzers. Often, it is relatively simple to run a tool, but interpreting the results, or even just using some of the more advanced tools, requires deep technical knowledge.

After the two training days, attendees will have a solid understanding of the tooling landscape on Linux, which should boost their productivity by knowing which tool to use in which situation.

Prerequisites

This course introduces all presented tools without requiring prior knowledge of them. The examples and labs are written in C++, having basic C++ knowledge is sufficient. While some of the examples and labs make use of Qt for displaying a UI, no knowledge of Qt is required either, althought it might be helpful.

During the course, we will do some hand-on labs in which the students get to use various debugging and profiling tools. To participate in the labs, the students should bring a Laptop with a non-virtualized installation of a modern Linux distribution (preferably Kernel >= 3.17), with the following tools installed:

  • root access
  • a recent version of GCC (>=5.x) or clang (>=3.6)
  • Qt 5.4 or newer (release build to get accurate profiling results)
  • their prefered editor/IDE
  • profiling tools
    • Linux perf
    • heaptrack: https://www.kdab.com/heaptrack-v1-0-0-release/
    • V-Tune (optional): https://software.intel.com/en-us/intel-vtune-amplifier-xe/try-buy
    • LTTng (modules, tools and ust)
  • debugging tools
    • gdb or lldb
    • valgrind

Course Topics

Debugging:

  • logging
  • general purpose debuggers – gdb and lldb
  • higher-level debuggers – GammaRay
  • memory error detectors – valgrind’s memcheck, Clang’s AddressSanitizer
  • thread error detectors – valgrind’s helgrind, Clang’s ThreadSanitizer
  • tracing – strace, ldd

Profiling:

  • CPU – Linux perf, Intel VTune Amplifier
  • heap memory – valgrind’s massif, heaptrack
  • tracing – LTTNG, bcc

Testing:

  • static code analysis – Clang Analyzer, Coverity, Clazy
  • code coverage
  • continuous integration

Course Instructor

Thomas McGuire

Thomas McGuire is a Senior Software Engineer and team lead at KDAB. He has actively developed with Qt since 2006, when he started contributing to the open source KDE project. Since joining KDAB in 2008, Thomas has focused on QtQuick and QML, especially on embedded Linux. In addition, his interests are performance analysis and optimization, as well as modern C++. He is a contributor and approver for the Qt Project. Thomas holds an MSc in Computer Science.