安装和使用 Intel PIn
来源:互联网 发布:各协议端口号 编辑:程序博客网 时间:2024/05/26 09:53
一、 安装
在官网http://www.pintool.org/下载压缩包然后解压就行了
Building the Example Tools for Linux
To build allexamples in a directory:
$ cd source/tools/ManualExamples
$ make all
To build and run a specific example (e.g., inscount0):
$ cd source/tools/ManualExamples
$ make inscount0.test
To build a specific example without running it (e.g., inscount0):
$ cd source/tools/ManualExamples
$ make obj-intel64/inscount0.so
The above applies to the Intel(R) 64 architecture. For the IA-32architecture, use "obj-ia32" instead of "obj-intel64":
$ cd source/tools/ManualExamples$ make obj-ia32/inscount0.so
二、在windows上安装并运行一个例子
1. 之前的Pin版本中,支持通过MicrosoftVisual Studio 2010的命令行运行nmake之类的批处理命令,从Pin 2.12版本开始,需要基于cygwin make来进行编译
2. Cygwin安装的时候,默认不安装make工具,所以在安装Cygwin时要选择安装make工具
3. 安装好Cygwin之后,将其安装目录下的bin目录,如“D:\cygwin\bin”加入到环境变量path中(最好加在其他所有变量之前,这样保证可以先用Cygwin进行解析),之后就可以直接在cmd中使用Cygwin的命令。例如:tar, ls, grep,make等
4. 下载的Pin是个压缩包,解压即可。将Pin解压后的文件夹的位置(pin.exe上面一层文件夹)加入到path中,即可在命令行中使用Pin命令。
5. 进入到source/tools/ManualExamples中,用make命令(同linux)可以编译所有例子。编译好后进入对应的32位或64位平台的文件夹中可以看到生成文件,windows下大多数生成的都是dll文件。然后使用pin命令pin -t itrace.dll --"test.exe"即可运行itrace这个例子对test.exe(是自己编的一个exe放到相同目录下了,如果在其他地方要用完整的路径)进行分析,这个例子是会输出所有的test.exe的指令的地址到文件itrace.out中。运行完后可以查看该文件。
该例子代码是source/tools/ManualExamples/itrace.cpp:
#include <stdio.h>#include "pin.H"FILE * trace;// This function is called before every instruction is executed// and prints the IPVOID printip(VOID *ip) { fprintf(trace, "%p\n", ip); }// Pin calls this function every time a new instruction is encounteredVOID Instruction(INS ins, VOID *v){ // Insert a call to printip before every instruction, and pass it the IP INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)printip, IARG_INST_PTR, IARG_END);}// This function is called when the application exitsVOID Fini(INT32 code, VOID *v){ fprintf(trace, "#eof\n"); fclose(trace);}/*Print Help Message */INT32 Usage(){ PIN_ERROR("This Pintool prints the IPs of every instruction executed\n" + KNOB_BASE::StringKnobSummary() + "\n"); return -1;}int main(int argc, char * argv[]){ trace = fopen("itrace.out", "w"); // Initialize pin if (PIN_Init(argc, argv)) return Usage(); // Register Instruction to be called to instrument instructions INS_AddInstrumentFunction(Instruction, 0); // Register Fini to be called when the application exits PIN_AddFiniFunction(Fini, 0); // Start the program, never returns PIN_StartProgram(); return 0;}
生成的结果文件:
- 安装和使用 Intel PIn
- intel强力分析工具Pin的使用入门(1)
- intel pin 工具使用的指导与学习收获
- intel MKL的安装和使用
- Intel Pin抓取Hadoop 和Spark 中java进程
- Intel Pin 学习总结
- Intel Pin架构
- Intel Pin-JIT模式和Probe模式下库函数的替换
- 高性能Numpy/Scipy:使用Intel MKL和Intel Compilers
- pin的安装
- intel vtune的安装与使用
- ubuntu 安装intel iofrt 和icc编译器
- PIN的基本使用
- pin的使用
- 使用VC6 和intel compiler 编译 boost_1_33_1
- pin
- PIN的经验和技巧
- AT命令和PIN码
- Android超炫特效:ListView item拖拽效果(上)
- opencv2.46 vs2010配置
- QT Creator2.7与vs2008
- 如何取得打好TAG的代码
- NYOJ 2
- 安装和使用 Intel PIn
- FORM 开发环境设置
- 《算法设计手册》面试题解答 第二章
- webdriver切换窗口
- Javah 常见错误记录
- jQuery 中 $.fn.extend 与$.extend 的区别
- 完美洗牌算法学习
- iOS7 Release Note提到的一些变更
- [混迹IT职场系列]一、转正的那些事儿