Search⌘ K
AI Features

Dynamic Analysis With Valgrind: Memcheck-Cover

Explore how to perform dynamic memory analysis using Valgrind's Memcheck tool and enhance error reporting with Memcheck-Cover. This lesson guides you through configuring Memcheck-Cover in CMake, running memory checks, and generating navigable HTML reports to better understand and fix memory issues in your C++ applications.

We'll cover the following...

Memcheck-Cover

Commercial IDEs such as CLion natively support parsing Valgrind's output to something that can be easily navigated through GUI without scrolling through the console window to find the right message. If our editor doesn't have this option, we can still get a much clearer view of the errors by using a third-party report generator. Memcheck-Cover offers a nicer experience in the form of a generated HTML file, as shown in the following figure:

A report generated by Memcheck-Cover
A report generated by Memcheck-Cover

This neat little project is available on GitHub; it requires Valgrind and gawk (GNU AWK tool). To use it, we'll prepare a setup function in a separate CMake module. It will ...