Open luojiaqs opened 5 years ago
Hello,
First, no question is stupid:)
Second, please refer to https://github.com/SVF-tools/SVF/blob/206493694931caa8ff3133191e7a4dbb7832fd89/lib/Util/AnalysisUtil.cpp#L301
to understand printing the debug information of LLVM IR.
Hello,
First, no question is stupid:)
Second, please refer to https://github.com/SVF-tools/SVF/blob/206493694931caa8ff3133191e7a4dbb7832fd89/lib/Util/AnalysisUtil.cpp#L301
to understand printing the debug information of LLVM IR.
Thanks for your help.
I had read analysisUtil::getSourceLoc
before but give little attention ><
Basically, a struct type always a DICompositeType
type, and I just didn't know how to access to it.
Use FindDbgAddrUses
function I can get all @llvm.dbg.declare
inst.
and I find DICompositeType
in DIVar->getOperand(3)
sample code
bool instAnalysis (Instruction *inst){
if (isa<AllocaInst>(inst)) {
for (DbgInfoIntrinsic *DII : FindDbgAddrUses(const_cast<Instruction*>(inst))) {
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(DII)) {
DIVariable *DIVar = cast<DIVariable>(DDI->getVariable());
errs() << "num operand : " << DIVar->getNumOperands() << "\n";
if(DICompositeType *pp =dyn_cast<DICompositeType>(DIVar->getOperand(3))){
errs() << pp->getLine() << " : " << pp->getFilename() << "\n";
errs() << pp->getElements().size() << "\n";
pp->getElements()[0]->dump();
}
}
}
return false;
}
Hello, I'm new in LLVM, and I want to use svf to do some static analysis. I want to find where a struct is defined, Loc and source file. just like function's dbginfo.
but I cannot find any interface to get such information. How can I get such information with svf ? Apologize for my little stupid problem. ?