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 Meydenbauer Conference Center from 9AM to 5PM on Saturday and Sunday, September 29th and 30th (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.

During the training the participants will do hands-on exercises (“labs”) to optimize or find bugs in existing code.

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.

Course Topics

Debugging:

  • debuggers – GDB and RR
  • sanitizers – address, undefined behaviour and thread
  • valgrind
  • assertions
  • strace
  • static code analysis – compiler warnings and clazy

Profiling:

  • manual timing
  • Linux perf – stat, trace, sampling and off-cpu profiling, hotspot UI frontend
  • heaptrack
  • Intel V-Tune
  • LTTng

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 we use Qt as the build system and to display a UI in some of the examples and labs, no knowledge of Qt is required.

A VirtualBox VM with most of the tools installed will be provided in advance of the course. Some tools are limited in the VM, as the VM has no support for accessing the performance counters (PMU) of the host. This mainly affects RR, which is used in one lab, so it needs to be installed on the host. It also affects perf and V-Tune, although the performance counter support in these is not needed for the labs. Nevertheless perf and V-Tune can optionally be installed on the host to see the full performance counter support.

For installing the required RR tool on the host, the following is needed:

For the other optional host tools, the following is needed in addition:

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.