Glen
Glen

Reputation: 22300

How do I merge Valgrind memcheck reports from multiple runs of the same process?

I've got an set of acceptance tests that run nightly. I'd like to use valgrind to check for memory leaks in my code automatically as an additional safe-guard to manually checking for leaks. Updating my scripts to run my processes under valgrind is trivial, however, each test starts and stops a number of processes and there are around 15000 test cases, so I'll end up with thousands of individual reports.

Is there a tool that's able to merge these reports? I've seen valkyrie, but according to the docs they don't support valgrind 3.5

Upvotes: 6

Views: 2199

Answers (3)

BobTuckerman
BobTuckerman

Reputation: 699

The newer versions of Valkyrie (The GUI companion to Valgrind) has what you're looking for.

$ man valkyrie
NAME
   valkyrie - graphical front-end to the Valgrind suite of tools for debugging and profiling Linux executables

SYNOPSIS
   valkyrie [valkyrie-opts] [valgrind-opts] [prog-and-args]

<snip> 
   --merge <loglist>
          Merge multiple logfiles, discarding duplicate errors

There is also a CLI only variant, called vk_logmerge. It's available in the valkyrie package if you're on Ubuntu.

Upvotes: 0

Doomsday
Doomsday

Reputation: 2668

A way to solve your problem should be to add --gen-suppressions=all option, and concat all ignored errors in your suppressions files. You have to sort true leaks and false leaks manually, but once it's done, valgrind will print only true leaks.

Then, if reports wrote anything, it is maybe you have to resolve memory leaks before proceed.

--quiet option is necessary : Run silently, and only print error messages. Useful if you are running regression tests or have some other automated test machinery.

Upvotes: 0

Douglas Leeder
Douglas Leeder

Reputation: 53320

If your code is mostly clean, then you could just keep the error cases.

If your going to right a tool to combine the outputs, then the valgrind xml output format might be the right thing to start with. At least then parsing shouldn't be too hard. You can also output the valgrind log to a different file to separate it from the programs' output. Also you can get valgrind to give an error when it detects a memory leak with --error-exitcode=.

You'll still have to decide what counts as the same memory leak, when comparing leaks.

Upvotes: 1

Related Questions