<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"> My friends,<br><br>I ran a function pass on a .bc file, intending to insert a CallInst to my self-made check function.<br><br>The compilation is successful. BUT after I ran that pass on the .bc file,<b> the size of the file didn't get any bigger!!</b><br><b>Does this mean my instrumentation work failed??</b><br><br>BTW the opt command I use is <b>"opt -load ../../../Debug+Asserts/lib/Hello.so -hello <hello.bc> -o hello.bc"</b><br><b>Does this command mean to run hello pass on hello.bc and send the result to hello.bc???</b><br><br>The source code of the function pass is as follow. <br>// for each function traverse the instruction in it<br> for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI)<br> {<br> for(BasicBlock::iterator II = BI->begin(),IE = BI->end();II != IE; ++II)<br> {<br> // we only care the instruction that call for functions and it can be cast to CallInst<br> if(CallInst * III = dyn_cast<CallInst>(II))<br> {<br> // if the callInst is calling for puts function<br> if(III->getCalledFunction()!=NULL&&III->getCalledFunction()->getName()=="puts")<br> {<br> errs() <<III->getCalledFunction()->getName()<<" function found!\n";<br> // declare the extern function£¨int check()£© that I want to instrument in the .bc file<br> Function *check = cast<Function>(III->getCalledFunction()->getParent()->getOrInsertFunction("check", <br> Type::getInt32Ty(III->getCalledFunction()->getParent()->getContext()),<br> (Type *)0));<br> // Create the CallInst to call for the check function!<br>CallInst *callcheck = CallInst::Create(check,"CallCheck");<br> // insert the CallInst right before II<br> callcheck->insertBefore(II);<br><br> errs() <<"INSERT SUCCEEDED!!!!!!!!\n";<br> }<br> else<br> {<br> errs() <<"it's not main function!\n"<<"it is:"<<III->getCalledFunction()->getName()<<'\n';<br> }<br> } <br> }<br><br> <br><br><div>--<br><div>
<div>
<div><font color="#c0c0c0" size="2">
<div><font color="#c0c0c0"><font size="3"> <span style="COLOR: #000000"> ×£ºÃ£¡</span></font></font></div><span style="COLOR: #000000">
<div> </div>
<div><font size="3"> Õç¿</font></div>
<div>
<div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div></div>
<div><font color="#c0c0c0"><font size="3">2012-04-10</font></font></div></span></font></div>
<div><font color="#c0c0c0"><font size="3">------------------------------------------------------------------------------------------------------</font></font></div>
<div><font color="#c0c0c0"><font size="3">Name: Õç¿(ZhenKai)<br>Homepage:http://www.renren.com/262729393</font></font></div>
<div><font color="#c0c0c0"><font size="3">Email: </font><a href="mailto:zhenkaixd@126.com" target="_blank" _listener="1901"><font color="#0066cc" size="3">zhenkaixd@126.com</font></a><font size="3"> or <a href="mailto:846227103@qq.com">846227103@qq.com</a></font></font></div>
<div><font color="#c0c0c0" size="3">TEL: 15810729006(Beijing)<br>Address: Room I-406, Central Building, Tsinghua University, Beijing, China. 100084.</font></div></div></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>