How to tell Intel Pin to profile only a specific function

230 views Asked by At

I want to profile a specific function in a large piece of code using Intel Pin. I have compiled my code with -O3, so I cannot access the debug symbols. I'm compiling my code using the following command: gcc -O3 -march=native -pedantic -o bin/baseline_main baseline_main/main.c.

I have written a pin tool to track branches and count them. The tool looks at the instructions and if an instruction is a branch instruction, it adds a call to increment a counter. At the end of the profiling period, the tools simply prints out the branch instruction count.

If I run this tools with a simple C code with no branches, I still get a branch count of 25950. The code which gave me this number is shown below. I suppose that this count is not zero due to the code being executed by my OS's loader. I want to know if I can somehow tell the pin tool to only instrument the main function and to ignore the rest of the execution.

#include <stdio.h>
#include <stdbool.h>                                                                                                                                           

int main()
{
        volatile bool x = false;
        volatile int y = 0;
        return 0;
}
0

There are 0 answers