Skip to content

use python-pin error #8

Open
Open

Description

@ling245100108

I try convert the simplest pintools: inscount0.cpp to python. But It has a segment error:
C: Tool (or Pin) caused signal 11 at PC 0x7f946f1dd8b9
I don't know what's wrong with me.
Here is the python source I write:

import sys, pin

info = file("count.out", "w")

count = 0

def docount(ins_info):
global count
count = count + 1

def instruction(ins):
pin.INS_InsertCall(pin.IPOINT_BEFORE, ins, docount)

def fini():
global count
info.writelines(str(count))
info.close()

pin.INS_AddInstrumentFunction(instruction, 0)
pin.AddFiniFunction(fini, 0)

Activity

  1. Kosmonit commented on May 10, 2015

    @Kosmonit

    Please write your full configuration version OS, pintool, c++ and other?

  2. ling245100108 commented on May 10, 2015

    @ling245100108
    Author

    I use ubuntu 14.04 x86_x64
    Linux LING 3.16.0-33-generic #44~14.04.1-Ubuntu SMP Fri Mar 13 10:33:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    pin is pin-2.14-71313-gcc.4.4.7-linux

    gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

    And I can run your all examples for example strace.py . I only want to write some python myself.

  3. Kosmonit commented on May 10, 2015

    @Kosmonit

    What branch did you use? Python_Pin or Python_Pin_Windows?

  4. ancat commented on May 11, 2015

    @ancat
    Collaborator

    I didn't test this out, but you should be able to increment count in your instruction function, without needing to insert a new call at every instruction (since you are instrumenting every instruction anyway). Not exactly a great solution, but it should stop the segfault. I'll have a closer look at some point this week.

  5. tosanjay commented on Dec 11, 2015

    @tosanjay

    I am a new-comer as far as Pintools are concerned, but from what you are suggesting, i guess it may give erroneous results. You are suggesting to increment count in "instrumentation code", which is called only first time when an instruction is about to execute. If the same instruction is executed again, instrumentation routine will not be invoked and you may not increase the count because you have not registered any analysis callback. This is what I understood from the PIN doc. I will be happy to know if I am wrong here.

  6. 0xling commented on Dec 22, 2015

    @0xling

    @tosanjay I agree with you. so we need register a callback in function Instrument().

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions