user2924551
user2924551

Reputation: 25

memory access trace using pin tool

I just have an issue while using the intel's pin tool. I want the memory access trace of a c++ program and for that am using it. First I run c++ program (./a.out) using

../../../pin -t obj-intel64/pinatrace.so -- ./a.out

Now in the c++ I also printed the address of each variable. Now when I replace all the addresses in the file generated by pin with the actual variable name output by the file it gives me wrong sequence.

For example for a sum program where variable 'a' and 'b' are added and result is stored in 'c' and printed on console (just a small 5 lines code), In the file generated by pin 'b' exists 150 times and 'a' exists 33 times and 'c' exists 3 times. But in the code all variables are referred not more than twice. How can I get the actual memory access trace. Kindly can anyone help me please will really appreciate it.

Upvotes: 1

Views: 2982

Answers (1)

nitzanms
nitzanms

Reputation: 1718

It's not at all surprising that memory addresses on the stack are used several times. Consider the following code:

int main() {
  {
    int a = 0;
  }
  {
    int b = 0;
  }
}

If the assignments won't be optimized away, I can almost guarantee that the two assignments will be made to the same memory address.

Now consider the fact that before and possibly after your code executes, there's quite a bit runtime initialization, and it should be clear why what you're seeing is totally expected.

You can use the example provided in InstLibExamples/filter.cpp to see how to filter out memory tracing for certain IMGs.

Upvotes: 0

Related Questions