Skip to content

Instantly share code, notes, and snippets.

@mahmoudimus
Forked from PollyP/intel_pintools_vs2019.md
Created December 31, 2022 02:37
Show Gist options
  • Save mahmoudimus/3a545980e4a59c8daf513cb66517d2cd to your computer and use it in GitHub Desktop.
Save mahmoudimus/3a545980e4a59c8daf513cb66517d2cd to your computer and use it in GitHub Desktop.
Building and Running Intel Pintools with VS 2019 on Windows 10

Building Intel pintools with Visual Studio 2019 on Windows 10

Setting up the Intel pin build environment

I started with a Windows 10 Enterprise Evaluation VM, version 1809, from here: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ Then I installed the needed tools:

  • Install Visual Studio Community 2019 Edition from https://visualstudio.microsoft.com/downloads/, version 16.4.2. Make sure to install the Desktop development for C++ workload.

  • Install GNU's make, version 4.2.1, using Cygwin's 64-bit installer. Cygwin installer link here: https://cygwin.com/install.html.

  • If needed, create VS 32- and 64-bit developer command windows shortcuts.

    My 32-bit shortcut: %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat""

    My 64-bit shortcut: %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"".

  • Install the Windows version of Intel pin tools from https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-downloads. I used Intel pin version pin-3.11-97998-g7ecce2dac-msvc-windows.

Building and running an example pintool to use with a 32-bit process

  • Open a VS 2019 32-bit developer command window

  • Cd to the source\tools\SimpleExamples folder in the Intel pin folder

  • Add the Cygwin bin directory to your path: set PATH=%PATH%;\cygwin64\bin

  • Build the pintool DLL: make obj-ia32/icount.dll TARGET=ia32

  • Now run the pintool against your application. In this case, I have the 32-bit version of pslist.exe from the System Internals Suite in my home directory:

    ..\..\..\pin.exe -t obj-ia32\icount.dll -- c:\Users\IEUser\pslist.exe

The instruction count will print out at the end of the pslist.exe output.

Building and running an example pintool to use with a 64-bit process

  • Open a VS 2019 64-bit developer command window

  • Cd to the source\tools\SimpleExamples folder in the Intel pin folder

  • Add the Cygwin bin directory to your path: set PATH=%PATH%;\cygwin64\bin

  • Build the pintool DLL: make obj-intel64/icount.dll TARGET=intel64

  • Now run the pintool against your application. In this case, I have the 64-bit version of pslist.exe from the System Internals Suite in my home directory:

    ..\..\..\pin.exe -t obj-intel64\icount.dll -- c:\Users\IEUser\pslist64.exe

The instruction count will print out at the end of the pslist64.exe output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment