3

我有最新版本的 Intel Pin 3.0 版本 76887。

我有一个支持 MPX 的玩具示例:

#include <stdio.h>
int g[10];
int main(int argc, char **argv) {
  int x = g[11];
  printf("%d\n", x);
  return 0;
}

当使用 gcc + MPX 编译时,我在反汇编中看到 MPX 指令objdump,并且该示例正确地向我写入了边界违规:

Saw a #BR! status 0 at 0x401798

现在我想计算使用 Intel Pin 的特定 MPX 指令的总数,例如BNDLDXBNDMK.

我的第一次尝试是使用随附的工具source/tools/SimpleExamples/trace.cpp。该工具向我展示NOPs了 MPX 指令的位置。

在我的第二次尝试中,我使用以下代码段编写了自己的工具:

xed_iclass_enum_t iclass = (xed_iclass_enum_t)INS_Opcode(ins);
if (iclass == XED_ICLASS_BNDMK)
    INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)countBndmk, IARG_END);

这不起作用,countBndmk 永远不会被调用。我用其他指令 iclass 仔细检查了我的代码,它们起作用了。很明显,存在 Pin(或 XED?)无法识别 MPX 指令的问题。


浏览文档,我注意到一个有趣的旋钮

KNOB<BOOL> knob_mpx_mode(KNOB_MODE_WRITEONCE,"supported:xed","xed_mpx_mode","0","Enable Intel(R) MPX instruction decoding")

这个旋钮似乎启用了 MPX 解码,0默认情况下是这样,我不知道如何通过命令行或在我的工具中启用它。我在代码或互联网中没有发现其他关于此问题的参考。


我知道我可以使用英特尔 SDE 转储包括 MPX 指令在内的调试跟踪。我想知道是否有办法在 Intel Pin 中启用 MPX。或者唯一的解决方案是自己解码操作码?

4

1 回答 1

0

回答可能有点晚,但似乎您只需将选项传递给 PIN。

一点背景:

在英特尔手册上有这一行(与 MPX 无关,但它提供了一个线索):

Add the knob support_jit_api to the Pin command line as Pin tool option:
    <Pin executable> <pin options> -t <Pin tool> -support_jit_api <Other Pin tool options> -- <Test application> <Test application options>

碰巧这个选项有一个现有的旋钮

KNOB<BOOL> LEVEL_PINCLIENT::KnobJitApi  (   KNOB_MODE_WRITEONCE     ,
"pintool:sym"   ,
"support_jit_api"   ,
"0"     ,
"Enables the Jitted Functions Support"  
)

由于 MPX 旋钮定义为:

KNOB<BOOL> knob_mpx_mode(KNOB_MODE_WRITEONCE,"supported:xed","xed_mpx_mode","0","Enable Intel(R) MPX instruction decoding")

我想你只需要将选项传递给 PIN:

<Pin executable> <pin options> -t <Pin tool> -xed_mpx_mode <Other Pin tool options> -- <Test application> <Test application options>

这些旋钮似乎是硬编码到 PIN / PinTools 上的。

于 2016-11-24T17:49:22.253 回答