[LLVMdev] Problem on instrumentation

15102925731 zhenkaixd at 126.com
Sun Apr 8 21:45:23 PDT 2012


Hi,
I also want to insert a function call at the interested area, and do something in the called function which is written by myself.

First you need to determine the  INSTRUCTION where you want to insert your function to. you can do this by writing some code like,
for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI)
                                for(BasicBlock::iterator II = BI->begin(),IE = BI->end();II != IE; ++II)
                                
then use the insertBefore or insertAfter function.

I wonder how is your "instrumented code" like. Because I can insert a function that is wrapped in the module, but
the function may be wrapped so poorly that when I run the pass, the programme broke down.








--

            祝好!
 
  甄凯
------------------------------------------------------------------------------------------------------
2012-04-09
------------------------------------------------------------------------------------------------------
Name: 甄凯(ZhenKai)
Homepage:http://www.renren.com/262729393
Email: zhenkaixd at 126.com or 846227103 at qq.com
TEL: 15810729006(Beijing)
Address: Room I-406, Central Building, Tsinghua University, Beijing, China. 100084.

At 2012-04-09 11:27:26,Zhoujinguo <zhoujinguo1988 at yahoo.cn> wrote:

| Hi,


I am instrumenting a piece of code. I want to insert a function call at the interested area, and do something in the called function which is written by myself.


I have succeed on implementing the pass, and getting the instrmented code. However, I am not sure where to put this function, and what kind of linkage I should use for this function.


Currently I use External linkage which is implemented as following:


LLVMContext& context=M.getContext();
FunctionType* FT=FunctionType::get(Type::getInt32Ty(context),false);
Function* F=Function::Create(FT,Function::ExternalLinkage,"myFunctionCall",&M);


Is it OK? And also, where should I put the function "int myFunctionCall()"?


Thank you very much. I am expecting for your reply.


Regards
Andy
|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120409/5881db8f/attachment.html>


More information about the llvm-dev mailing list