FrozenTarzan
FrozenTarzan

Reputation: 874

How to enable --leak-check=yes for valgrind in Qt Creator?

System Info: Ubuntu 16.04, Qt Creator 4.2.0, valgrind 3.12.0

When using valgrind from the console to output detailed leak analysis I do it like that:

valgrind --leak-check=yes ./my_application --an_argument

Since I want to use Qt Creator's nice output formatting and filtering of the reported issues I tried to use valgrind within the editor but I cannot configure any arguments (such as --leak-check) for valgrind itself. The dialog looks like this:

valgrind configuration within Qt Creator

Can I do this somewhere in a config file or in hidden dialog options?

Edit: I accepted the answer that explicitly mentions the --leak-check option but other answers mentioning a wrapper script from inside Qt Creator is a very nice way to go. Unfortunately there is still a difference in the outputs within Qt Creator compared to valgrind from the console so I guess that there are suppression files used inside Qt Creator... but that's a different topic.

Upvotes: 1

Views: 1801

Answers (2)

DBedrenko
DBedrenko

Reputation: 5029

In the worst case you can create a wrapper for the valgrind binary with the desired options. You would create an executable file valgrind somewhere:

#!/bin/bash
exec /usr/bin/valgrind --leak-check "$@"

Then in the QtCreator settings put the new file's filepath in the Valgrind executable field.

Upvotes: 4

hank
hank

Reputation: 9853

Set the 'Check for leaks on finish' option value to 'Full':

enter image description here

This will spawn the '--leak-check=full' valgrind option which is equivalent to '--leak-check=yes'.

Upvotes: 3

Related Questions