I'm working on a project that needs to get statistics of memory access pattern of a program. (by memory access pattern, I mean a accessing probability distribution of different regions of memory)
I used Intel Pintool and have got the address of all instructions(Instruction Pointer) and the all memory addresses that is accessed in these instructions. The statistics are like this: in the format of:
fprintf(trace,"%p: R/W %p\n", ip, addr); //IP Read/Write addr
0x7f096b04e2d3: W 0x7fff17713f68
0x7f096b051a70: W 0x7fff17713f60
0x7f096b051a74: W 0x7fff17713f58
0x7f096b051a76: W 0x7fff17713f50
0x7f096b051a78: W 0x7fff17713f48
0x7f096b051a7a: W 0x7fff17713f40
0x7f096b051a7c: W 0x7fff17713f38
0x7f096b051a8f: R 0x7f096b26fe70
0x7f096b051a96: W 0x7f096b26fc98
0x7f096b051aa7: R 0x7f096b270000
The questions is, in the perspective of CPU, these address are all Virtual Addr, which cannot be used if I want to get the physical memory access pattern.
Do you have any ideas?
I'm not sure if you can do that in Pin, but I don't think so. You might want to check out pagemap. This should at least give you a resource to translate the virtual addresses to physical addresses although you'll have to process it a little. From the documentation: