45
45
#include < sys/mman.h>
46
46
#include < sys/syscall.h>
47
47
#include < unistd.h>
48
+ #ifdef HAVE_LIBPFM
49
+ #include < perfmon/perf_event.h>
50
+ #endif // HAVE_LIBPFM
48
51
#endif
49
52
50
53
#define GET_AVAILABLE_OPCODE_CHECKER
@@ -1252,7 +1255,7 @@ std::vector<MCInst>
1252
1255
ExegesisX86Target::configurePerfCounter (long Request, bool SaveRegisters) const {
1253
1256
std::vector<MCInst> ConfigurePerfCounterCode;
1254
1257
if (SaveRegisters)
1255
- saveSyscallRegisters (ConfigurePerfCounterCode, 2 );
1258
+ saveSyscallRegisters (ConfigurePerfCounterCode, 3 );
1256
1259
ConfigurePerfCounterCode.push_back (
1257
1260
loadImmediate (X86::RDI, 64 , APInt (64 , getAuxiliaryMemoryStartAddress ())));
1258
1261
ConfigurePerfCounterCode.push_back (MCInstBuilder (X86::MOV32rm)
@@ -1264,9 +1267,13 @@ ExegesisX86Target::configurePerfCounter(long Request, bool SaveRegisters) const
1264
1267
.addReg (0 ));
1265
1268
ConfigurePerfCounterCode.push_back (
1266
1269
loadImmediate (X86::RSI, 64 , APInt (64 , Request)));
1270
+ #ifdef HAVE_LIBPFM
1271
+ ConfigurePerfCounterCode.push_back (
1272
+ loadImmediate (X86::RDX, 64 , APInt (64 , PERF_IOC_FLAG_GROUP)));
1273
+ #endif // HAVE_LIBPFM
1267
1274
generateSyscall (SYS_ioctl, ConfigurePerfCounterCode);
1268
1275
if (SaveRegisters)
1269
- restoreSyscallRegisters (ConfigurePerfCounterCode, 2 );
1276
+ restoreSyscallRegisters (ConfigurePerfCounterCode, 3 );
1270
1277
return ConfigurePerfCounterCode;
1271
1278
}
1272
1279
0 commit comments