Search code examples
c++intelintel-pin

Intel Pin with PinPlay RTN_InsertCall callback not executing on replay


I'm using Intel's Pin API with the Pinplay replay framework, and am having trouble getting the following to execute when performing a replay:

VOID Arg1Before(char *name, ADDRINT arg1) {
  tracefile << name << "(" << arg1 << ")" << endl;
}

VOID Routine(RTN rtn, VOID *v) {
  RTN_Open(rtn);
  if (RTN_Name(rtn) == "malloc") {
    RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)Arg1Before,
                   IARG_ADDRINT, "malloc",
                   IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
                   IARG_END); 
  }
  RTN_Close(rtn);
}

This is functionally similar to Pin's SimpleExamples/malloctrace.cpp example program.

The pinball being replayed was created with:

$PIN_ROOT/pin -t $PIN_ROOT/extras/pinplay/bin/intel64/pinplay-malloctracer.so \
    -log -log:basename pinball/foo -- /usr/bin/ls

And replayed using:

$PIN_ROOT/pin -xyzzy -reserve_memory pinball/foo.address \
    -t $PIN_ROOT/extras/pinplay/bin/intel64/pinplay-malloctracer.so \
    -replay -replay:basename pinball/foo \
    -- ../pin-2.14/extras/pinplay/bin/intel64/nullapp

Debugging has shown that Routine() is being called appropriately, but the inserted call is never being executed.

My operating system is RHEL.


Solution

  • I have faced the same problem, got the answer here, if you are using python scripts to log the program, you just need to provide the -log:image_ops option to it. It would be something like

    $pinpoints.py --cfg test.cfg --log_options="-log:image_ops" -l 
    

    Also please check your routine instrumentation function. I think it should be

    RTN_Name(rtn) == "__libc_malloc"