Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting Valgrind to a specific function

Tags:

valgrind

I have a big program to run. Using valgrind it takes hours and hours to run. I heard that there is something where we can call valgrind for a specific function in the program. And rest of program will be executed normally(without valgrind env). Can anybody help me with this. I tried searching it over internet , May be I am missing the term to search.

like image 717
NinjaCoder Avatar asked Jun 08 '11 14:06

NinjaCoder


People also ask

What is Valgrind suppression?

Valgrind is (mostly) a memory error detector for Linux. It's very good at finding leaks and uninitialised variables; unfortunately it's too good, and usually produces a number of false positives. It comes with suppression files which automatically silence some of these; but not enough, and none specific to wxGTK.

How do you stop Valgrind?

With this setup Valgrind will keep the NGINX process up and running until you gracefully stop it by typing kill -TERM valgrindPID, where valgrindPID is the Valgrind's process identifier.

How do you run Valgrind with command line arguments?

To run Valgrind, pass the executable as an argument (along with any parameters to the program). The flags are, in short: --leak-check=full : "each individual leak will be shown in detail" --show-leak-kinds=all : Show all of "definite, indirect, possible, reachable" leak kinds in the "full" report.

Is Valgrind single threaded?

The main thing to point out with respect to threaded programs is that your program will use the native threading library, but Valgrind serialises execution so that only one (kernel) thread is running at a time.


1 Answers

It all depends on what tool you're wanting to use. For callgrind (the profiler in valgrind) there is an option --toggle-collect=function to allow you to collect information inside a particular function and all its children.

However if the tool you're interested in is memcheck (for capturing leaks / memory errors) then there is no available command line option.

like image 183
Rob Bradford Avatar answered Sep 28 '22 22:09

Rob Bradford