在英特尔PIN中查找RAW,WAR,WAW依赖项

时间:2018-02-18 02:49:07

标签: assembly x86 intel intel-pin

我正在尝试使用Pintool查找数据危害。我写了这个:

    TRACE_AddInstrumentFunction(Trace, 0); //called in main

class readStore  //This is for both read and write. Named read for historical reasons...
{
 public:
    UINT64 addr;
    std::vector<LEVEL_BASE::REG> vread_regs;
    std::vector<LEVEL_BASE::REG> vwrite_regs;
 };

Trace的函数定义:

   for(BBL bbl=TRACE_BblHead(trace);BBL_Valid(bbl);bbl= BBL_Next(bbl))
   {
    BBL_InsertCall(bbl, IPOINT_BEFORE, AFUNPTR(docount), IARG_UINT32, BBL_NumIns(bbl), IARG_END);

    for(INS ins = BBL_InsHead(bbl); INS_Valid(ins); ins=INS_Next(ins))
    {
    LEVEL_BASE::REG readReg;
            LEVEL_BASE::REG writeReg;
            readStore *rs_temp= new readStore;

            noRRegs=INS_MaxNumRRegs(ins);   //get count of read regs
            noWRegs=INS_MaxNumWRegs(ins);
            for(UINT32 i=0;i<noRRegs;i++)
            {
                    readReg =INS_RegR(ins,i);   //returns readR type
                    if(REG_is_gr_type(readReg))
                    {
                            rs_temp->vread_regs.push_back(readReg) ;
                    }
                    //may want to add else condition
            }
            for(UINT32 j=0;j<noWRegs;j++)   //store all write regs
            {
                    writeReg= INS_RegW(ins,j);
                    if(REG_is_gr_type(writeReg))
                    {
                            rs_temp->vwrite_regs.push_back(writeReg);
                    }

            }
            rs_temp->addr= INS_Address(ins);
            cout << rs_temp->addr;
            cout << "\n";
            readstore.push_back(*rs_temp);//array of objects with everything in it

我的想法是制作一个向量,用于存储所有指令IP,它们写入的寄存器以及它们读取的寄存器。我在仪器功能中完成了所有这些工作。之后在Fini函数中,我只使用正常的if-else条件计算危险。

我面临的问题是,当我尝试打印read_store向量的大小时,我得到一个非常小的数字(大约10000),而指令的总数大于780K。有人能告诉我哪里出错了吗?

0 个答案:

没有答案