0

ピンツールにこのグローバル変数があり、命令 (インストルメンテーション関数) 内でその内容を取得したいと考えています。

UINT32 windowCnt=0;

LOCALFUN VOID Instruction(INS ins, VOID *v)
{

    const AFUNPTR InsRefFun = ((wcount % 2)==0 ? (AFUNPTR) InsRef_Skip : (AFUNPTR) InsRef);



    INS_InsertIfCall(
       ins, IPOINT_BEFORE, (AFUNPTR)InsRefFun,
       IARG_THREAD_ID,
       IARG_INST_PTR,
       IARG_END);
  ...
}

これどうやってするの?GLOBALVAR、LOCALVAR、const、および static を試しましたが、正しい値が返されませんでした。

4

1 に答える 1

0

静的グローバル変数 (ファイル スコープで) が機能するはずです。

static UINT32 foo = 0;

それ以外の場合は、 INS_AddInstrumentFunctionの 2 番目のパラメーターを使用できます。

int main(int argc, char * argv[])
{
    // Initialize pin
    if (PIN_Init(argc, argv)) return Usage();

    UINT32 foo = 0;

    // Register Instruction to be called to instrument instructions
    INS_AddInstrumentFunction(Instruction, &foo);

    // Register Fini to be called when the application exits
    PIN_AddFiniFunction(Fini, 0);

    // Start the program, never returns
    PIN_StartProgram();

    return 0;
}

そして、あなたのインストルメンテーション機能では、何かに沿って:

// Pin calls this function every time a new instruction is encountered
VOID Instruction(INS ins, VOID *v)
{
    if(v == NULL)
        return;

    UINT32 myfoo = *((UINT32*)v); //in c++: myFoo = *reinterptet_cast<UINT32*>(v)

    // Insert a call to doSomething before every instruction, no arguments are passed
    INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)doSomething, IARG_END);
}
于 2016-11-24T18:14:45.777 に答える