Skip to content

Instantly share code, notes, and snippets.

@PollyP
Last active December 19, 2023 14:52
Show Gist options
  • Save PollyP/e50959ab97b15c83d4506dcf38753ef5 to your computer and use it in GitHub Desktop.
Save PollyP/e50959ab97b15c83d4506dcf38753ef5 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.

@MrBeanc
Copy link

MrBeanc commented Jun 17, 2022

Hello, could you share your version's pin-tool with me? I can't find the version of 3.11 on the Internet. The problem of failed installation bothered me for a long time ,thank you very much. My email is [email protected]

@PollyP
Copy link
Author

PollyP commented Jun 17, 2022

Hi @MrBeanc, it appears that you can still grab the pin tools from Intel's server even though they have removed the links from the pintools download page.

Linux/Mac: https://software.intel.com/sites/landingpage/pintool/downloads/pin-3.11-97998-g7ecce2dac-gcc-linux.tar.gz
Windows: https://software.intel.com/sites/landingpage/pintool/downloads/pin-3.11-97998-g7ecce2dac-msvc-windows.zip

@MrBeanc
Copy link

MrBeanc commented Jun 18, 2022

So great !!! I installed successfully using your method. Before that, I spent a lot of time on the wrong version. Thank you very much :)

@PollyP
Copy link
Author

PollyP commented Jun 19, 2022

Good deal @MrBeanc, thanks for letting me know

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