I would like to add several unit tests to my code, also as I load plug ins I don't always have access to the code I'm running. The test I would really like to check is if the function I'm calling is lock free ?
Is there any hook, or way to test if between a point A and B in my program there was a call to a non lock free function ?
Another less complicated function is how to hook all calls to locking functions (like locks, system calls ...). I know how to hook calls to malloc on windows but nothing else.
Thank you for your help
You can't.
You could substitute a different implementation of pthread_lock
but code could make direct calls to e.g. futex
, and if you replace that the code could still call it directly with syscall(SYS_futex,...)
. You could profile the code or use something like strace
to detect all such calls, but that still wouldn't tell you if the code implements its own custom spinlock in assembly.