0

i am struggling On finding a function with prototype mul(float,float) i try to use RTN_FindByName but the output is still empty.

VOID Arg1Before(CHAR * name, ADDRINT size)
{
    TraceFile << name << "(" << size << ")" << endl;
}
VOID MulAfter(ADDRINT ret)
{
    TraceFile << "  returns " << ret << endl;
}
VOID Image(IMG img, VOID *v)
{
// Instrument the mul() and div() functions.  Print the input argument
// of each mul() or div(), and the return value of mul().
//
//  Find the mul() function.
RTN mulRtn = RTN_FindByName(img, MUL);
if (RTN_Valid(mulRtn))
{
    RTN_Open(mulRtn);
    // Instrument mul() to print the input argument value and the return value.
    RTN_InsertCall(mulRtn, IPOINT_BEFORE, (AFUNPTR)Arg1Before,
                   IARG_ADDRINT, MUL,
                   IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
                   IARG_END);
    RTN_InsertCall(mulRtn, IPOINT_AFTER, (AFUNPTR)MulAfter,
                   IARG_FUNCRET_EXITPOINT_VALUE, IARG_END);
    RTN_Close(mulRtn);
}
}

There, MUL is a constant which is "mul". Obviously, i have included pin.H. the problem is that my traceFile is still empty

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • However, when i look for malloc instead of my function, it works successfully. i don't understand – Dufy Teguia Jan 09 '21 at 23:12
  • The function name might be decorated. Try to have a look with `objdump` or loop over all the RTNs and get their names with `RTN_Name` (andf see if you have something containing "mul" in it). Be sure sure to call `PIN_InitSymbols()` at the very start of your `main` function. – Neitsa Jan 11 '21 at 15:37
  • Thanks. the function was decorated as you said. so i found a way to undecorate it before usage – Dufy Teguia Jan 14 '21 at 06:45

0 Answers0