2

I want to trace the mutex variables in my rust program(e.g. which mutex called lock() and unlock() methods). And I think there're static methods.

1
  • Why not instrument every call instruction and see if the call target is your function of choice?
    – sudhackar
    Commented May 15, 2023 at 10:32

1 Answer 1

1

In instruction instrumentation function, you can check if the instruction is indeed a call instruction. Something like -

if (INS_IsCall(ins))
    {
        if (INS_IsDirectCall(ins))
        {

Then get the name of the routine:

if (RTN_FindNameByAddress(INS_DirectBranchOrCallTargetAddress(ins)) 
== "yourfavouritefun")
do something;
        }
}

And you can obviously log the caller.

VOID Instruction(INS ins, VOID *v) {
ADDRINT insaddress = INS_Address(ins);
if (RTN_FindNameByAddress(insaddress))
  do something more;
....
1
  • So how to find the callers of instruction (i.e., how to distinguish different callers of the same instruction)?
    – roo jack
    Commented Jun 20, 2023 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.