Forum Discussion

hErd's avatar
hErd
Icon for New Contributor rankNew Contributor
11 months ago
Solved

How to analyse lock acquire and release using intel pin instrumentation

I am analyzing C++ codes to find data races in them using intel pin

Now I found some inbuilt functions in Intel Pin like INS_IsMemoryRead and INS_IsMemoryWrite to determine if a instruction is memory read or write respectively Now I want to achive the same for lock acquire and lock release (only for C++ pthread_mutex) but I didn't find any such function

So I disassembled the lock acquire statement and found a lock prefix and a cmpxchg statement

So I decided to use lockPrefix function of Intel Pin to determine if the instruction has lock prefix and INS_Opcode function to check if xed value is cmpxchg and then check if the adress being written to has value 1 then we can say lock acquire is successful

But I believe there is something simpler and also have doubts regarding correctness of my approach

7 Replies