Pin (programa computacional)
# Pin (programa computacional)

Pin is a dynamic binary instrumentation framework for the IA-32, x86-64 and IA-64 instruction set architectures that enables the creation of dynamic program analysis tools. Some tools built with Pin are Intel Parallel Inspector, Intel Parallel Amplifier and Intel Parallel Advisor.

The tools created using Pin, called Pintools, can be used to perform program analysis on user space applications in Linux and Windows. As a dynamic binary instrumentation tool, instrumentation is performed at run time on the compiled binary files. Thus, it requires no recompiling of source code and can support instrumenting programs that dynamically generate code.

Pin was originally created as a tool for computer architecture analysis, but its flexible API and an active community (called "Pinheads") have created a diverse set of tools for security, emulation and parallel program analysis.

Pin is developed and supported by Intel, and is supplied free of charge for non-commercial use together with a kit of reference tools.

## Perspectiva general

Pin realiza instrumentación tomando el control del programa justo después de ser cargado en la memoria. Este entonces realiza recompilación Just-In-Time (JIT) en pequeñas secciones de código binario antes de que se ejecute. Nuevas instrucciones, las cuales realizan el análisis, son añadidas al código recompilado. Esas nuevas instrucciones provienen de Pintool. Un largo arreglo de técnicas de optimización son para obtener el más bajo posible consumo de tiempo y memoria en uso. Para junio del 2010, El consumo promedio de Pin es 30% (sin correr una pintool).

Pin es una plataforma para crear herramientas de análisis. Una herramienta pin incluye instrumentación, análisis y retrollamado routines. Rutinas de instrumentación son llamadas cuando el código que no ha sido recompilado esta por ser ejecutado, y habilita la inserción de rutinas de análisis. Rutinas de análisis son llamadas cuando el código al que están asociadas se está ejecutando. Rutinas de Retrollamado son llamadas cuando condiciones específicas son encontradas, o cuando cierto evento a ocurrido. Pin provee una extensa API para instrumentación en muchos niveles de abstracción, desde una instrucción a un completo módulo binario. Además soporta retrollamado para muchos eventos como carga de librerías, llamadas al sistema, eventos como señales/excepciones y creación de hilos.

## Características

### Modos de Instrumentación

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 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.

### Independencia de plataformas

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.

### Optimizaciones

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.

### Facilidad de uso

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.

## Herramientas

There are many Pintools that are used for varying tasks.

* Components of Intel Parallel Studio make heavy use of pintools for memory debugging, performance analysis, multithreading correctness analysis and parallelization preparation.
* Intel Software Development Emulator is a pintool that enables the development of applications using instruction set extensions that are not currently implemented in hardware.
* CMP$IM is a cache profiler built using pin.
* PinPlay enables the capture and deterministic replay of the running of multithreaded programs under pin. Capturing the running of a program helps developers overcome the non-determinism inherent in multithreading.
* Pin itself comes with many example tools that make use of its abilities. These tools are licensed under a BSD-like license.
