Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use python-pin error #8

Open
ling245100108 opened this issue May 10, 2015 · 6 comments
Open

use python-pin error #8

ling245100108 opened this issue May 10, 2015 · 6 comments

Comments

@ling245100108
Copy link

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)

@Kosmonit
Copy link

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

@ling245100108
Copy link
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.

@Kosmonit
Copy link

What branch did you use? Python_Pin or Python_Pin_Windows?

@ancat
Copy link
Collaborator

ancat commented May 11, 2015

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.

@tosanjay
Copy link

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.

@0xling
Copy link

0xling commented Dec 22, 2015

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants