Restricting Valgrind to a specific function

2019-06-17 02:15发布

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.

标签: valgrind
2条回答
我只想做你的唯一
2楼-- · 2019-06-17 02:34

Googling "valgrind profile specific function only" and go "I feel lucky"

In addition to enabling instrumentation, you must also enable event collection for the parts of your program you are interested in. By default, event collection is enabled everywhere. You can limit collection to a specific function by using --toggle-collect=function. This will toggle the collection state on entering and leaving the specified functions. When this option is in effect, the default collection state at program start is "off". Only events happening while running inside of the given function will be collected. Recursive calls of the given function do not trigger any action.

More here

查看更多
老娘就宠你
3楼-- · 2019-06-17 02:37

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.

查看更多
登录 后发表回答