intel-pin

How to characterize a workload by obtaining the instruction type breakdown?

醉酒当歌 提交于 2021-02-15 07:44:35
问题 I want to obtain the percentage of memory read-write instructions in a test program, preferably dynamically. Apart from counting instructions in the gdb asm dump, which is static anyway, is there an easier way to obtain it? Valgrind provides total heap usage. Perf has some nice features but does not support WSL. Pin has an instruction count capability but it I am not sure if it supports WSL. 回答1: (Update: PIN reportedly doesn't work under WSL. But it doesn't require perf counters so it's

Log all instruction with intel pintool

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-08 02:25:51
问题 I have written this pintool: #include "pin.H" #include <iostream> #include <fstream> VOID Instruction(INS ins, VOID *v) { cout << INS_Disassemble(ins) << endl; } VOID Fini(INT32 code, VOID *v) { cout << "Fin" << endl; } int main(int argc, char *argv[]) { if( PIN_Init(argc,argv) ) { cout << "Erreur PIN_Init" << endl; return 0; } INS_AddInstrumentFunction(Instruction, 0); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); return 0; } I am printing all instructions. What i want to do now is to

Log all instruction with intel pintool

喜欢而已 提交于 2021-02-08 02:23:10
问题 I have written this pintool: #include "pin.H" #include <iostream> #include <fstream> VOID Instruction(INS ins, VOID *v) { cout << INS_Disassemble(ins) << endl; } VOID Fini(INT32 code, VOID *v) { cout << "Fin" << endl; } int main(int argc, char *argv[]) { if( PIN_Init(argc,argv) ) { cout << "Erreur PIN_Init" << endl; return 0; } INS_AddInstrumentFunction(Instruction, 0); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); return 0; } I am printing all instructions. What i want to do now is to

instruction point value of dynamic linking and static linking

允我心安 提交于 2020-07-09 11:54:09
问题 By using Intel's pin, I printed out the instruction pointer (ip) values for a program with dynamic linking and static linking. And I've found that their ip values are quite different, even though they are the same program. A program with static linking shows 0x400f50 for its very first ip value. but a program with dynamic linking shows 0x7f94f0762090 for its first ip value I am not sure why they have that quite a large gap. It would be appreciated if anyone could help me find out the reason

Intel Pin with C++14

こ雲淡風輕ζ 提交于 2020-01-14 13:55:49
问题 The Questions I have a few questions surrounding usage of Intel Pin with C++14 or other C++ verions. There are rarely any problems compiling code from older C++ with newer versions, but since Intel Pin is manipulates instruction level, is there any undesirable side effects that might come if I compile it with C++11 or C++14? If it's ok to compile with C++11 or C++14, how do I make a rule to enable a newer version of C++ for my tool only? How do I set GCC/G++ default C++ version to latest, if

Getting physical address in pin tool

拈花ヽ惹草 提交于 2020-01-12 10:49:31
问题 I'm using pin instrumentation tool to get memory traces. By my implementation result, I've found the traces indicate virtual address, not physical address. Is there any way to get physical address trace in Pin tool? Help! 回答1: The pin tool runs in user space and therefore it works with virtual addresses only. There is no way to get the physical addresses directly from the pin tool's API. An alternative approach to translate the virtual addresses to physical addresses would be to use the OS's

Modify application instruction in PIN

為{幸葍}努か 提交于 2020-01-04 15:26:55
问题 I am using Intel PIN to modify an instruction in my application. I am using the Safecopy() example from this link as a reference: https://software.intel.com/sites/landingpage/pintool/docs/81205/Pin/html/index.html#SafeCopy I have the following sample C program: int main() { asm(".byte 0x16"); return 0; } 0x16 is illegal in x86_64 and when I run the executable it displays the following error as expected: Illegal instruction (core dumped) I have a pintool which takes the above executable as

Can a PIN tool instrument a bash script that contains code to run other commands?

心不动则不痛 提交于 2019-12-25 03:36:14
问题 I wrote a PIN tool that can inject some code before and after a certain function in a binary image. It is working for a single binary image. Now , my objective is to instrument Xserver in Linux with that tool. I tried to instrument "startx" by the PIN tool and it did not work. Later, I found that startx is only a shell script that runs other commands. What steps I need to follow if I want to instrument xserver using PIN? Is it possible to instrument a shell script somehow using PIN? 回答1: If

intel Pin: analysis routine detects ah register instead of rsp (REG_STACK_PTR)

巧了我就是萌 提交于 2019-12-20 03:48:09
问题 I asked this question few days ago. I wanted to get the stack allocation size (after the function creation). The answer suggests to do: if((INS_Opcode(ins) == XED_ICLASS_ADD || INS_Opcode(ins) == XED_ICLASS_SUB) && REG(INS_OperandReg(ins, 0)) == REG_STACK_PTR && INS_OperandIsImmediate(ins, 1) Which in theory is correct and does make sense. But, it doesn't work in practice (correct me if I'm wrong here). It works perfectly fine if I remove REG(INS_OperandReg(ins, 0)) == REG_STACK_PTR check.

Errors compiling pin tool with python includes, getting error C2872: 'UINT32' : ambiguous symbol

▼魔方 西西 提交于 2019-12-19 10:25:24
问题 I'm trying to compile pin tool with Python.h and am getting more then 100 errors about ambiguous symbols. I tried to separate the include to different namespace but it generated many other errors. Same happens when including windows.h . All the errors looks like: D:\proj\Pin\source\include\pin\gen\types_core.TLH(67): error C2872: 'INT32' : ambiguous symbol could be 'C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h(72) : int INT32 or D:\proj\pin\Pin\source\include\pin\gen\types