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.
-
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.
-
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.
@PollyP Thanks great share. I used pin version 3.20 facing issues "make: *** [../../../source/tools/Config/makefile.default.rules:217: obj-intel64/icount.obj] Error 2" make files are not created inside obj-intel64 folder. Can you please confirm whether the same works in pin version 3.20 ?
C:\pin-3.20-98437-gf02b61307-msvc-windows\source\tools\SimpleExamples>make obj-intel64/icount.dll TARGET=intel64
mkdir -p obj-intel64/
cl /EHs- /EHa- /wd4530 /DTARGET_WINDOWS /nologo /Gy /Oi- /GR- /GS- /DPIN_CRT=1 /D_WINDOWS_H_PATH_="C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" /D__LP64__ /Zc:threadSafeInit- /Zc:sizedDealloc- /wd5208 /DTARGET_IA32E /DHOST_IA32E /I../../../source/include/pin /I../../../source/include/pin/gen -I../../../extras/stlport/include -I../../../extras -I../../../extras/libstdc++/include -I../../../extras/crt/include -I../../../extras/crt -I../../../extras/crt/include/arch-x86_64 -I../../../extras/crt/include/kernel/uapi -I../../../extras/crt/include/kernel/uapi/asm-x86 /FIinclude/msvc_compat.h /I../../../extras/components/include /I../../../extras/xed-intel64/include/xed /I../../../source/tools/Utils /I../../../source/tools/InstLib /MD /O2 /c /Foobj-intel64/icount.obj icount.cpp
icount.cpp
../../../extras/stlport/include\stl/char_traits.h(83): error C2118: negative subscript
make: *** [../../../source/tools/Config/makefile.default.rules:217: obj-intel64/icount.obj] Error 2