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

3

6

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

Dolhenty answered 24/6, 2010 at 22:27 Comment(1)
Same problem. Conclusion for now : write a script :) I'm interested if you found such a tool ...Booking
Y
1

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.

Yogi answered 25/6, 2010 at 13:27 Comment(2)
given that there may be thousands of reports produced just finding the error cases may be difficult. There will be a lot of error cases as well as I know there are a good few leaks in there. There'll also be a lot of duplicates which I was hoping that any merge tool would combine into one master report for me.Dolhenty
Hence my "if your code is mostly clean" statement. merging would be tricky in any case, as it would have to decide how much of the traceback mattered when comparing.Yogi
G
0

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.

Gallipot answered 22/7, 2010 at 8:49 Comment(0)
H
0

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.

Hectogram answered 10/1, 2017 at 20:20 Comment(1)
unfortunately vk_logmerge doesn't exist anymore in Ubuntu/Debian and the upstream sourceGalcha

© 2022 - 2024 — McMap. All rights reserved.