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 David Faure 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

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

David Faure

David Faure is Senior Software Engineer and Trainer at KDAB. Long time KDE developer, he has been developing with Qt since 1998 and contributing to Qt itself since Qt 4.0. In addition to the many consulting projects he has delivered, David has taught modern C++, Qt development, as well as debugging and profiling on Linux, to numerous companies. He holds an MSc in Computer Science.