<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div style="RIGHT: auto">Hi All,</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">Can we extract name of variable name from "MDNode" ?</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">1. Neither temp_MDNode->getName() nor temp_MDNode->getValueName() give me "global_int" which is name of a variable.</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">2. I tried below ways as well.</div>
<div style="RIGHT: auto">DIVariable DV(mdnode1);<BR>Value *v = mdnode1->getOperand(0)<VAR id=yui-ie-cursor></VAR>;//gives add 0x69<BR></div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">3. I have written below code to reach till variable name.</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> LLVMIname is </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> const CallInst *CI = dyn_cast<CallInst>(Insn);</div>
<div style="RIGHT: auto"> const Value* LLVMIValue = cast<CallInst>(Insn)->getCalledValue();<BR> const Function *LLVMIFunc= dyn_cast<Function>(LLVMIValue);</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> if( LLVMIname.compare("llvm.dbg.declare") == 0 )<BR><FONT style="RIGHT: auto" face="bookman old style, new york, times, serif"> {<BR> <FONT style="RIGHT: auto" face="Courier New, courier, monaco, monospace, sans-serif"> int x = 0;<BR> int numoperands = CI->getNumArgOperands();<BR> for( unsigned i = 0; i != numoperands;
++i)<BR> {<BR> Value *v = CI->getOperand(i);<BR> if( i == 1) //points to metadata for variable name<BR> {<BR> MDNode *mdnode = (MDNode *)CI->getOperand(1);<BR> int numoperds= mdnode->getNumOperands();//4
operands<BR> for( unsigned x = 0; x != numoperds; ++x)<BR> {<BR> Value *v = mdnode->getOperand(x);<BR> if( x == 2)//name of variable<BR> {<BR> MDNode
*mdnode1 = (MDNode *)mdnode->getOperand(2);//mdnode1->dump() gives variable name.<BR> std::pair<unsigned, MDNode *> mynode( Insn->getDebugLoc().getLine(), mdnode1);<BR> linenum_varmdnode.push_back( mynode);<BR> </FONT></FONT></div>
<div style="RIGHT: auto"><FONT style="RIGHT: auto" face="bookman old style, new york, times, serif"><FONT style="RIGHT: auto" face="Courier New, courier, monaco, monospace, sans-serif"> //DIVariable DV(mdnode1);//not working<BR> //Value *v = mdnode1->getOperand(0);//, not working. gives add 0x69<BR></FONT> <FONT style="RIGHT: auto" face="Courier New, courier, monaco,
monospace, sans-serif"> }<BR> }//for operands mdnode<BR> } <BR> }//for operands mdnode<BR></FONT></FONT></div>
<div style="RIGHT: auto"><FONT style="RIGHT: auto" face="bookman old style, new york, times, serif"><FONT style="RIGHT: auto" face="Courier New, courier, monaco, monospace, sans-serif">3. When I give "temp_MDNode->dump()" on gdb, it displays below output ==> </div>
<div style="RIGHT: auto">metadata !"global_int"</div>
<div style="RIGHT: auto">If I can collect this in a string, that too is OK for me. </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">Thanks & Regards,</div>
<div style="RIGHT: auto">Pankaj</div>
<div style="RIGHT: auto"> </div></FONT></FONT></div></body></html>