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. RegardsAndy -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120409/434b017b/attachment.html>
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>
Hi, I 've already added you in my QQ list. I'm wondering how you wrapped your self-written function in llvm-like language so it can be recognized when you call it in the pass? Best regards! -- 祝好! 甄凯 ------------------------------------------------------------------------------------------------------ 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 12:45:23,15102925731 <zhenkaixd at 126.com> wrote: 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/81794ce9/attachment.html>
Possibly Parallel Threads
- [LLVMdev] Problem on instrumentation
- [LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
- [LLVMdev] How to compile a linux module into .bc file using clang or llvm command?
- [LLVMdev] HELP: Clang options needed in command to compile device driver into linux module.
- [LLVMdev] How to compile a linux module into .bc file using clang or llvm command?