Intel Pin:Invalid REG IARG_REG_VALUE reg: xmm0
Intel Pin:Invalid REG for IARG_REG_VALUE reg: xmm0
我正在制作一个跟踪程序的程序,但我遇到了标题中的错误。
有没有人能看懂点什么?
INS_InsertCall(ins, action, AFUNPTR(RegOpnd::at_call),
IARG_PTR, data,
IARG_PTR, this,
IARG_REG_VALUE, reg_,
IARG_END);
我检查过 IARG_REG_VALUE 与 xmm 寄存器不兼容。
我怎样才能得到这些信息?
正如 documentation 所说:
this cannot be used to retrieve the value of registers whose size is larger than ADDRINT (e.g. x87 FPU/XMM/YMM/ZMM/opmask)
您有两个选择:
- 测试寄存器的类型并使用
IARG_REG_CONST_REFERENCE
(或者IARG_REG_REFERENCE
如果你想修改寄存器)。
- 获取 CPU 上下文(如果您想修改其中的任何寄存器,请使用
IARG_CONST_CONTEXT
或 IARG_CONTEXT
)并检查上下文中的寄存器。
我猜第一个选项更有意义,所以它应该大致像下面的代码:
警告:以下代码尚未经过测试/编译...
仪器:
const unsigned int opnd_count = INS_OperandCount(ins);
for(unsigned int i=0; i < opnd_count;i++)
{
if (INS_OperandIsReg(ins,i))
{
REG r = INS_OperandReg(ins,i);
if ((r))
{
INS_InsertCall(ins, IPOINT_AFTER, (AFUNPTR)xmm_arg,
IARG_REG_CONST_REFERENCE, r,
IARG_REG_REFERENCE, r, // you might remove this one if you don't modify the reg.
IARG_UINT32, i,
IARG_UINT32, (r-REG_XMM_BASE), // note: REG_XMM_BASE = REG_XMM0
IARG_END);
}
}
}
分析:
// regConstRef: const reference on the register
// regRef: reference on the register
// opnd_indx: operand index (0 for the 1st inst. op.; 1 for the 2nd inst. op.)
// regno: register number: 0 = XMM0; 1 = XMM1, etc.
VOID xmm_arg(PIN_REGISTER* regConstRef, PIN_REGISTER* regRef, UINT32 opnd_indx, UINT32 regno)
{
// just "dump" the register
std::cout << "XMM" << regno << " operand_index: " << opnd_indx << " ";
for(unsigned int i=0;i< MAX_DWORDS_PER_PIN_REG;i++)
{
std::cout << std::setw(10) << regConstRef->dword[i] << " ";
}
std::cout << std::endl;
}
我正在制作一个跟踪程序的程序,但我遇到了标题中的错误。 有没有人能看懂点什么?
INS_InsertCall(ins, action, AFUNPTR(RegOpnd::at_call),
IARG_PTR, data,
IARG_PTR, this,
IARG_REG_VALUE, reg_,
IARG_END);
我检查过 IARG_REG_VALUE 与 xmm 寄存器不兼容。 我怎样才能得到这些信息?
正如 documentation 所说:
this cannot be used to retrieve the value of registers whose size is larger than ADDRINT (e.g. x87 FPU/XMM/YMM/ZMM/opmask)
您有两个选择:
- 测试寄存器的类型并使用
IARG_REG_CONST_REFERENCE
(或者IARG_REG_REFERENCE
如果你想修改寄存器)。 - 获取 CPU 上下文(如果您想修改其中的任何寄存器,请使用
IARG_CONST_CONTEXT
或IARG_CONTEXT
)并检查上下文中的寄存器。
我猜第一个选项更有意义,所以它应该大致像下面的代码:
警告:以下代码尚未经过测试/编译...
仪器:
const unsigned int opnd_count = INS_OperandCount(ins);
for(unsigned int i=0; i < opnd_count;i++)
{
if (INS_OperandIsReg(ins,i))
{
REG r = INS_OperandReg(ins,i);
if ((r))
{
INS_InsertCall(ins, IPOINT_AFTER, (AFUNPTR)xmm_arg,
IARG_REG_CONST_REFERENCE, r,
IARG_REG_REFERENCE, r, // you might remove this one if you don't modify the reg.
IARG_UINT32, i,
IARG_UINT32, (r-REG_XMM_BASE), // note: REG_XMM_BASE = REG_XMM0
IARG_END);
}
}
}
分析:
// regConstRef: const reference on the register
// regRef: reference on the register
// opnd_indx: operand index (0 for the 1st inst. op.; 1 for the 2nd inst. op.)
// regno: register number: 0 = XMM0; 1 = XMM1, etc.
VOID xmm_arg(PIN_REGISTER* regConstRef, PIN_REGISTER* regRef, UINT32 opnd_indx, UINT32 regno)
{
// just "dump" the register
std::cout << "XMM" << regno << " operand_index: " << opnd_indx << " ";
for(unsigned int i=0;i< MAX_DWORDS_PER_PIN_REG;i++)
{
std::cout << std::setw(10) << regConstRef->dword[i] << " ";
}
std::cout << std::endl;
}