Pin supports two modes of instrumentation called JIT mode and Probe mode. JIT mode supports all features of Pin, while Probe mode supports a limited feature set but is far faster, adding almost no overhead to program's running time. JIT mode uses a just-in-time compiler to recompile all program code and insert instrumentation, while Probe mode uses code trampolines for instrumentation.
Pin was designed for tool portability, and despite JIT compiling from one ISA to the same ISA (and not using a single intermediate representation for all code), most of its APIs are architecture and operating system independent. It was also designed to be portable itself, carefully isolating platform-specific code from generic code, allowing the fast adaptation of Pin to new platforms. Approximately half of the code is generic and the rest is either architecture or OS dependent.3
Pin uses many techniques to optimize instrumentation and analysis code, using techniques such as inlining, liveness analysis and smart register spilling. Pin performs these optimizations automatically whenever possible, without needing users to insert any extra code to allow inlining. Naturally, some optimizations still require user hints, and some code structures are easier to inline than others. Direct linking of jitted code sections, a technique called trace linking, and register binding reconciliation, which minimizes register spilling and remapping, are also used.
Pin’s API and implementation are focused on making pin tools easy to write. Pin takes full responsibility for assuring that the instrumentation code from the pin tool does not affect the application state. Also, the API enables instrumentation code to request many pieces of information from Pin. For example, the instrumentation code in the pin tool can use the Pin API to get the memory address being accessed by an instruction, without having to examine the instruction in detail.
There are many Pintools that are used for varying tasks.
There are many other tools available to collect resource usage of running programs on the system such as Bell Lab’s strapon tool and Dyninst tool etc. Bell Lab’s tool uses the strap on technology which runs a tool to collect resources simultaneously with the program but this tool is only compatible with the programs which allow other programs to run simultaneously with them.6 Furthermore, Dyninst tool uses binary rewriting of the program’s executable and implementable commands inside the program to check for resource usage and is very efficient. However, it is very unstable as it is a relatively new tool and crashes on large scale programs.7 Lastly, Intel Pin tool uses static binary instrumentation and runs the program as a part of itself while keeping track of all its resources.8 This approach is more suitable for an antivirus as it can easily run all the processes under itself and can kill programs if they reach a maximum allocated limit as defined by the antivirus.
"Programming Languages Software Award". www.sigplan.org. http://www.sigplan.org/Awards/Software/ ↩
Analyzing Parallel Programs with Pin http://www.jaleels.org/ajaleel/publications/ieeeComputer10.pdf ↩
Pin: Building Customized Program Analysis Tools with Dynamic Instrumentation http://ursuletz.com/people/faculty/pdfs/p190-luk.pdf ↩
CMP$im: A Pin-Based On-The-Fly Multi-Core Cache Simulator http://www.ece.umd.edu/~blj/papers/mobs2008.pdf ↩
PinPlay: a framework for deterministic replay and reproducible analysis of parallel programs http://delivery.acm.org/10.1145/1780000/1772958/p2-patil.pdf ↩
Gupta, Chandrashekhar (2007). "Building secure products and solutions". Bell Labs Technical Journal. 12 (3): 21-38. doi:10.1002/bltj.20247. S2CID 30412754. /wiki/Doi_(identifier) ↩
Lee, Schulz (2007). "Dynamic binary instrumentation and data aggregation on large scale systems". International Journal of Parallel Programming. 35 (3): 207–232. doi:10.1007/s10766-007-0036-3. S2CID 6653468. /wiki/Doi_(identifier) ↩
Bach, M.; Charney, M.; Cohn, R.; Demikhovsky, E.; Devor, T.; Hazelwood, K.; Jaleel, A.; Luk, Chi-Keung; Lyons, G. (March 2010). "Analyzing Parallel Programs with PIN". Computer. 43 (3): 34–41. doi:10.1109/MC.2010.60. ISSN 0018-9162. S2CID 15155077. /wiki/Doi_(identifier) ↩