Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a program using Valgrind in Clion?

How can I run my program using valgrind directly in CLion using the run configuration ? I found how to add parameters when I launch my program, but how can I launch valgrind like :

valgrind my_program arg1 --arg2 ...

And how can I change easily the parameters without going on the "Edit configuration" panel to add, for example, valgrind options ?

like image 778
GauthierPLM Avatar asked Dec 22 '14 13:12

GauthierPLM


People also ask

How do I run a valgrind command line?

Valgrind is installed on the department machines. To invoke it on an executable called a. out, you simply run the command valgrind ./a. out (with any arguments your program might need).

What is valgrind and how do you use it?

Valgrind is a multipurpose code profiling and memory debugging tool for Linux when on the x86 and, as of version 3, AMD64, architectures. It allows you to run your program in Valgrind's own environment that monitors memory usage such as calls to malloc and free (or new and delete in C++).


2 Answers

You could create a custom target in your CMakeLists.txt that runs your program under valgrind.

like image 128
legalize Avatar answered Oct 25 '22 06:10

legalize


Valgrind is now natively supported in CLion 2017.3.

like image 26
Vadim Peretokin Avatar answered Oct 25 '22 06:10

Vadim Peretokin