How to Use Intel’s PIN program: A super simple tutorial

If you’re reading this, you probably already know what pin is for, but basically it is used to profile programs. You can use it to answer things like how many instructions does this executable have or how many branches occur, etc. It does this in most cases by inserting counters and other code while your executable is running. So let’s get to a quick demo.

I will be demonstrating with Linux, specifically with Ubuntu, because this was a headache on Windows. Note that you might need root permission to execute some of these commands, so if they don’t work, try re-running with sudo.

(1) Download the pin program tarball
Download the tool from here, making sure that you have a compatible version of gcc.

You can check your gcc version like so:

gcc --version

And get output similar to:

gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

If you don’t want to download through the browser, just use wget on the command line making sure to replace the link to the correct version.


(2) Untar it

Let me save you a quick Google:

tar -xzf pin-2.14-71313-gcc.4.4.7-linux.tar.gz

(3) Make a pintool

Pin uses these things called pintools to actually profile your program. As an analogy, think of pin as a game engine like Unreal, while the pintools are the games that are made with this engine like Batman: Arkham Knight.

The pintools you receive are actually just source at this point and need to be compiled by you. Thankfully, there’s the make the make tool to do that for you. Make sure you have it installed.

make --version

We will use the insmix tool in this example, which counts the number of x86 instructions that are executed by a program.

cd pin-2.14-71313-gcc.4.4.7-linux/source/tools/Insmix/

You should now have a new directory like obj-intel64 in the Insmix directory and it should contain

(4) Execute it!
We will run instrumentation on the ls command. Go back to the root directory of pin where you’ll find a shell script called

./ -t source/tools/Insmix/obj-intel64/ -- ls

This executes pin, using the pintool insmix on the executable ls. In your current directory you should see an output file called insmix.out. This file has statistics on the kinds of commands that have been executed. Consult the manual for insmix to see what they mean.

If you have any questions or errors running this, please leave a comment!


What are your thoughts?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s