When I run callgrind with "--toggle-collect=fun" or "--toggle-collect=main" it does not work. I tried with adding return type also but nothing worked. "--toggle-collect=void fun" or "--toggle-collect=int main". any idea why it is not working?
cmd used
valgrind --tool=callgrind --callgrind-out-file=callgrind.out "--toggle-collect=fun" -v a.out
below is the sample code
#include<stdio.h>
#include<stdlib.h>
void fun1()
{
for(int i=0; i<10;i++)
printf("a");
}
int main()
{
fun1();
}
Your code uses
fun1but your Callgrind command uses--toggle-collect=funwhich is missing the "1" at the end.I don't know exactly what function matching Callgrind uses for toggle collect. It certainly supports '*' and '?' wildcards. I'm not sure what it does for C++ mangled names. It won't use the return type though.
EDIT: add example
With the wrong toggle. Note zero Ir (instructions retired).
With the right toggle. 57k Irs.
If you want to use some form of prefix then you need to use the "?" or "*" wildcard characters.