1

As you might know, PIN is a dynamic binary instrumentation tool. By using Pin for example, I can instrument every load and store in my application. I was wondering If there is a similar tool which injects code at compile time (Using a higher level of information, not requiring us to write the LLVM pass), rather than at runtime like Pin. I am especially interested for such kind of tool for LLVM.

Charles
  • 50,943
  • 13
  • 104
  • 142
pythonic
  • 20,589
  • 43
  • 136
  • 219

1 Answers1

1

You could write LLVM passes of your own and apply them on your code to "instrument" it during compile time. These work on LLVM IR and produce LLVM IR, so for some tasks this will be a very natural thing to do and for other tasks it might be cumbersome or difficult (because of the differences between LLVM and IR and the source language). It depends.

Harel
  • 327
  • 1
  • 5
  • As If I didn't already know that, genius :)! I was talking about a tool that can do it for you at somewhat a higher level, for example I tell the tool to do so and so at each load and so and so at each store. Ofcourse I can write my own pass, but that was not my question. – pythonic Sep 21 '12 at 15:41
  • So why not take that approach? What do you have in mind that would better suit your needs? – Harel Sep 21 '12 at 15:42
  • Because its more difficult to do it myself, than let a tool write a pass for me. I just need to say it to do so and so for some event, just like in case of Pin. So basically I want a tool that can create a pass for us. – pythonic Sep 21 '12 at 15:44
  • 1
    Based on my experience with LLVM passes and my more limited experience with the Pin APIs, they're quite similar, I don't think there's such a big difference. One nice trick is to use llc -march=c++ to produce LLVM C++ API code that constructs the IR for the C/C++ code you feed it (does that make sense?), if like most mortals you find it easier to code what you want to do in C/C++ than to call the C++ API to produce the IR for it, that can come in very handy. – Harel Sep 21 '12 at 15:46