I have the latest version of Intel Pin 3.0 version 76887.
I have an MPX-enabled toy example:
#include <stdio.h>
int g[10];
int main(int argc, char **argv) {
int x = g[11];
printf("%d\n", x);
return 0;
}
When compiled with gcc + MPX, I see MPX instructions in the disassembly via objdump
, and the example correctly writes me a bounds violation:
Saw a #BR! status 0 at 0x401798
Now I'd like to count the total number of specific MPX instructions using Intel Pin, e.g., BNDLDX
and BNDMK
.
My first attempt was using the shipped tool source/tools/SimpleExamples/trace.cpp
. This tool showed me NOPs
at places of MPX instructions.
In my second attempt, I wrote my own tool with the following snippet:
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);
This doesn't work, countBndmk is never called. I double-checked my code with other instruction iclasses, and they worked. So clearly there is a problem of Pin (or XED?) not recognizing MPX instructions.
Browsing the docs, I noticed an interesting knob
KNOB<BOOL> knob_mpx_mode(KNOB_MODE_WRITEONCE,"supported:xed","xed_mpx_mode","0","Enable Intel(R) MPX instruction decoding")
This knob seems to enable MPX decoding and is 0
by default, and I don't know how to enable it per command-line or in my tool. I found no other references to this problem in code or internet.
I know I could use Intel SDE to dump the debug trace including MPX instructions. I wonder if there is a way to enable MPX in Intel Pin. Or the only solution is to decode opcodes myself?