2

I compiled a C program using -m32 gcc option . I want to profile this program using a Pin tool . My kernel is 64 bit.

I have tried :-

1) pin -t64 <64-bit toolname> -t <32-bit toolname> -- <application>

2) pin -t <32-bit toolname> -- <application>

3) pin -t <64-bit toolname> -- <application>

I have the same .cpp tool file for both the tools compiled differently for 32 bit and 64 bit architectures.

Case 3 invoked an error 'unable to load .. Check the architecture type' . Cases 1 and 2 , the command was successful but produced some unexpected output , for ex names of images written into a file is empty in this case but contains proper results when executed with a 64-bit application . Which is the correct way to set up the pin tool for this case?

Neitsa
  • 7,693
  • 1
  • 28
  • 45
G Ashwin
  • 23
  • 1
  • 6
  • You're invoking pin in the correct way in cases 2 and 1 (case 1 is for complex process tree flows). I suspect the issue is not Pin itself but something in the Pintool. Can you share a minimal reproducer of the issue? – nitzanms Feb 18 '16 at 12:18

3 Answers3

2

well i found a workaround to compile the 32bit library of pin ( i mean instcount0 ) in 64bit arch.

i did modify the config file related to building the library.

i have pin located in /opt/ so , i edited

/opt/pin-3.0-76991-gcc-linux/source/tools/Config

at line 38

# Define the architecture of the target
# ; TARGET ?= $(HOST_ARCH)
TARGET = ia32
ifeq ($(TARGET),ia32)
    BITS := 32
else
    BITS := 64
endif

i just changed the target to ia32. works just fine after build .

asm
  • 58
  • 6
0

There are a few caveats to know when starting a program under pin control:

1) The pintool must be compiled in the same architecture than the instrumented program (so, if your program is 32-bit, your pin tool must be 32-bit).

2) Ensure your system is setup to execute 32-bit programs on a 64-bit OS (some linux systems still need ia32-libs and / or need to be prepared for executing 32-bit programs (e.g. sudo dpkg --add-architecture i386)

3) Ensure you have all required libraries for PIN

4) Use pin.sh

Your command should be:

  • pin -t pintool.so -- <program> <program-options>

If you still have problems it is probably a problem with your pintool code rather than pin itself.

Did you tried one of the simple example (like inscount) on your program ?

Neitsa
  • 7,693
  • 1
  • 28
  • 45
  • I have taken care of all the four cases you have mentioned , even the given inscount.so doesn't give any output for the 32-bit executable. What can be the error then? As given , I have compiled it separately for 32-bit architecture. But then for my tool , I collect information about branches and functions which come properly but file that contains the names of images is empty. – G Ashwin Feb 18 '16 at 09:54
0

Check the version of your PIN binary.

file PIN_DIR/pin

I downloaded PIN kit from this link. My PIN binary is 32-bit. If yours is 64-bit version, you can modify codes that check system architecture in pin.sh, and run

PIN_DIR/pin.sh

That should give you a 32-bit version PIN binary.

Bruce Shen
  • 572
  • 3
  • 13