2017년 12월 6일 수요일

[Pin tool] 메뉴얼 해석

=======================================================
  • Pin 3.5 User Guide
Pin is a tool for the instrumentation of programs. It supports the Linux*, OS X* and Windows* operating systems and executables for the IA-32, Intel(R) 64 and Intel(R) Many Integrated Core architectures.
-> Pin은 프로그램의 측정을위한 도구이다.  IA-32, Intel(R)64, Intel(R), 통합 코어 아키텍쳐에 실행 가능한 파일들 그리고 Linux, OS X * 및 Windows * 운영 체제들을 지원한다.

Pin allows a tool to insert arbitrary code (written in C or C++) in arbitrary places in the executable. The code is added dynamically while the executable is running. This also makes it possible to attach Pin to an already running process.
-> Pin은 실행 가능한 파일에 임임의 공간에 임의의 코드(C 또는 C++로 작성된)를 삽입하기 위한 도구로 사용된다. 삽입된 코드는 실행 가능한 파일이 실행중에 동적으로 추가된다. 또한 이미 실행중인 프로세스에 Pin에 붙이는 것도 가능하다.

Pin provides a rich API that abstracts away the underlying instruction set idiosyncracies and allows context information such as register contents to be passed to the injected code as parameters. Pin automatically saves and restores the registers that are overwritten by the injected code so the application continues to work. Limited access to symbol and debug information is available as well.
-> Pin은 기본 명령어 세트의 특이성을 추상화하고 레지스터 내용 등의 컨텍스트 정보를 주입 된 코드에 매개 변수로 전달할 수있는 풍부한 API를 제공한다. Pin은 응용프로그램이 계속 작동하도록 삽입된 코드에 의해 무시된 레지스터를 자동으로 저장되고 복구된다. 심볼과 디버그 정보의 접근도 제한되있다.

Pin includes the source code for a large number of example instrumentation tools like basic block profilers, cache simulators, instruction trace generators, etc. It is easy to derive new tools using the examples as a template
-> Pin은 basic block profilers, cache simulators, instruction trace generators, 그외 수 많은 양의 측정 도구 예제 소스 코드를 포함한다. 이 샘플들은 예제 탬플릿으로 사용하여 새로운 도구를 이끌어 내기 쉽다.

Tutorial Sections
  • How to Instrument With Pin
  • Examples
  • Callbacks
  • Modifying Application Instructions
  • The Pin Advanced Debugging Extensions
  • Applying a Pintool to an Application
  • Debugging Tips for Debugging a Pintool
  • Recording Messages from a Pintool
  • Performance Considerations
  • Memory management
  • PinTools Information and Restrictions
  • Building Tools on windows
  • Libraries for Windows
  • Libraries for Linux
  • Installation
  • Building Your Own Tool
  • Pin's makefile Infrastructure
  • Feedback
  • Disclaimer and Legal Information


How to Instrument With Pin(핀을 사용하여 측정하는 방법)
  • Pin
  • Pintools
  • Observations
  • Instrumentation Granularity
  • Managed platforms support
  • Symbols
  • Floating Point Support in Analysis Routines
  • Instrumenting Multi-threaded Applications
  • Avoiding Deadlocks in Multi-threaded Applications
The best way to think about Pin is as a "just in time" (JIT) compiler. The input to this compiler is not bytecode, however, but a regular executable
-> Pin에 대한 최선의 방법은 "just in time"(JIT) 컴파일러 이다. 하지만 이 컴파일러의 입력은 바이트코드가 아니다. 그러나 일반 실행 파일이다.

Pin intercepts the execution of the first instruction of the executable and generates ("compiles") new code for the straight line code sequence starting at this instruction.
-> Pin은 실행 파일의 첫번째  명령의 실행을 차단하고 이 명령에서 시작하는 straight line code sequence를 위한 새로운 코드를 발생(컴파일)시킨다.

It then transfers control to the generated sequence. The generated code sequence is almost identical to the original one, but Pin ensures that it regains control when a branch exits the sequence.
-> 그 후 생성된 sequence 제어로 이동한다. 발생된 code sequence는 원래 코드 순서와 거의 동일하다. 그러나 Pin은 분기 sequence를 종료할 때 제어를 회복하는 것을 보장한다.

After regaining control, Pin generates more code for the branch target and continues execution. Pin makes this efficient by keeping all of the generated code in memory so it can be reused and directly branching from one sequence to another.
-> 제어가 복구된 후에 Pin은 분기된 코드를 더 생성하고 실행을 계속한다. Pin은
하나의 시퀀스에서 다른 시퀀스로부터 직접 분기하고 재사용 하기 할 수 있게 메모리에 생성된 코드 전부를 보관하는 것이 효율적이다.

In JIT mode, the only code ever executed is the generated code. The original code is only used for reference. When generating code, Pin gives the user an opportunity to inject their own code (instrumentation).
-> JIT 모드에서 실행된 코드는 생성된 코드이다. 원래 코드는 참조를 위해 사용되어진다.
코드가 생성될 때 Pin은 사용자 자신의 코드(instrumentation)를 주입 할 수 있는 기회를 제공한다.

Pin instruments all instructions that are actually excuted. It does not matter in what section they reside. Although there are some exceptions for conditional branches, generally speaking, if an instruction is never executed then it will not be instrumented.
-> 실제로 실행된 모든 명령들은 Pin으로 측정한다. 어느 섹션에 그들이 존재하는지 중요하지 않다. 비록 그들은 조건 분기에는 몇가지 예외가 있지만 일반적으로 명령이 실행되지 않으면 명령은 인스트루먼트되지 않는다.

  • Pintools
Conceptually, instrumentation consists of two components:
-> 개념적으로 Instrumentation은 두가지의 Component로 구성되어 있다

    • A mechanism that decides where and what code is inserted
-> 어디에 어떤 코드가 삽입되는지를 결정하는 메커니즘
    • The code to execute at insertion points
-> 삽입 지점에서 실행되는 코드

These two components are instrumentation and analysis code. Both components live in a single executable, a Pintool. Pintools can be thought of as plugins that can modify the code generation process inside Pin.
-> 이러한 두 Components는 계측 과 분석 코드이다. 두 Component 는 단일 실행파일, Pintool에 존재한다. Pintool은 Pin 내 코드 생성 프로세스를 변경할 수 있는 플러그인이라고 생각 할 수 있다.

The Pintool registers instrumentation callback routines with Pin that are called from Pin whenever new code needs to be generated. This instrumentation callback routine represents the instrumentation component. It inspects the code to be generated, investigates its static properties, and decides if and where to inject calls to analysis functions.
-> Pintool은 언제든 새로운 코드가 생성되기 위해 필요한 Pin으로 부터 호출된 Pin과 함께 계측(instrumentation)  콜백 루틴을 등록한다. 이 계측(instrumentation)  콜백 루틴은 계측 component를 나타낸다. 생성된 코드를 검사하고, 정적 속성을 검사하여 분석 함수에 호출을 어디에 삽입할지 결정한다.

The analysis function gathers data about the application. Pin makes sure that the integer and floating point register state is saved and restored as necessary and allow arguments to be passed to the functions.
-> 분석 함수는 응용프로그램에 대한 데이터를 수집한다. Pin은 정수, 소수점 레지스터의 상태가 필요에 따라 저장 및 복원되고 함수에 전달되는 것을 허용한다.

The Pintool can also register notification callback routines for events such as thread creation or forking. These callbacks are generally used to gather data or tool initialization or clean up.
-> 또한 Pintool은 스레드 생성 또는 포크와 같은 이벤트를 위한 알림 콜백 루틴을 등록할 수 있다. 이 콜백은 일반적으로 데이터 수집 또는 도구 초기화 및 정리를 위해 사용된다.

  • Observations
Since a Pintool works like a plugin, it must run in the same address space as Pin and the executable to be instrumented. Hence the Pintool has access to all of the executable's data. It also shares file descriptors and other process information with the executable.
-> Pintool은 플러그인 처럼 동작하기 때문에 Pin과 계측 가능한 실행파일이 같은 주소 공간에서 실행한다. 따라서 Pintool은 모든 실행 파일의 데이터를 엑세스 할 수 있다. 또한 파일 디스크립터 및 실행파일과 기타 프로세스 정보를 공유한다.

Pin and the Pintool control a program starting with the very first instruction. For executables compiled with shared libraries this implies that the execution of the dynamic loader and all shared libraries will be visible to the Pintool.
-> Pin과 Pintool은 첫 번째 명령에서 프로그램 시작을 제어한다. 공유 라이브러리로 컴파일된 실행파일인 경우 이것은 동적 로더 및 모든 공유라이브러리의 실행이 Pintool에 표시되는 것을 의미한다.

When writing tools, it is more important to tune the analysis code than the instrumentation code. This is because the instrumentation is executed once, but analysis code is called many times.
-> 도구를 쓸 때 측정 코드보다 분석 코드를 조정하는 것이 중요하다. 이것은 측정이 1 회 실행되지만, 분석 코드가 여러 번 호출되기 때문이다.



  • Instrumentation Granularity

As described above, Pin's instrumentation is "just in time" (JIT). Instrumentation occurs immediately before a code sequence is executed for the first time. We call this mode of operation trace instrumentation .
-> 전술 한 바와 같이, Pin의 측정은 "just in time" 이다. 계측은 코드 시퀀스가 처음  실행되기 전에 즉시 발생한다. 우리는 작업 모드를 Trace instrumentation이라고 부른다.

Trace instrumentation lets the Pintool inspect and instrument an executable one trace at a time. Traces usually begin at the target of a taken branch and end with an unconditional branch, including calls and returns. Pin guarantees that a trace is only entered at the top, but it may contain multiple exits.
-> Trace instrumentation는 Pintool 점검과 도구


If a branch joins the middle of a trace, Pin constructs a new trace that begins with the branch target. Pin breaks the trace into basic blocks, BBLs. A BBL is a single entrance, single exit sequence of instructions. Branches to the middle of a bbl begin a new trace and hence a new BBL. It is often possible to insert a single analysis call for a BBL, instead of one analysis call for every instruction. Reducing the number of analysis calls makes instrumentation more efficient. Trace instrumentation utilizes the


https://software.intel.com/sites/landingpage/pintool/docs/97503/Pin/html/index.html#INSTRUMENTING

댓글 없음:

댓글 쓰기