Extract subprogram and compile unit information from the debug info attached to an instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83491 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-10-07 22:04:08 +00:00
parent b07c171624
commit beab41b874
2 changed files with 33 additions and 1 deletions

View File

@ -679,7 +679,10 @@ bool getLocationInfo(const Value *V, std::string &DisplayName,
/// processType - Process DIType.
void processType(DIType DT);
/// processSubprogram - Enumberate DISubprogram.
/// processLexicalBlock - Process DILexicalBlock.
void processLexicalBlock(DILexicalBlock LB);
/// processSubprogram - Process DISubprogram.
void processSubprogram(DISubprogram SP);
/// processStopPoint - Process DbgStopPointInst.

View File

@ -966,6 +966,12 @@ void DIFactory::InsertDeclare(Value *Storage, DIVariable D,
/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(Module &M) {
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
MetadataContext &TheMetadata = M.getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
if (!MDDbgKind)
return;
#endif
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI)
for (BasicBlock::iterator BI = (*FI).begin(), BE = (*FI).end(); BI != BE;
@ -980,6 +986,18 @@ void DebugInfoFinder::processModule(Module &M) {
processRegionEnd(DRE);
else if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
processDeclare(DDI);
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
else if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) {
DILocation Loc(L);
DIScope S(Loc.getScope().getNode());
if (S.isCompileUnit())
addCompileUnit(DICompileUnit(S.getNode()));
else if (S.isSubprogram())
processSubprogram(DISubprogram(S.getNode()));
else if (S.isLexicalBlock())
processLexicalBlock(DILexicalBlock(S.getNode()));
}
#endif
}
NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv");
@ -1021,6 +1039,17 @@ void DebugInfoFinder::processType(DIType DT) {
}
}
/// processLexicalBlock
void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
if (LB.isNull())
return;
DIScope Context = LB.getContext();
if (Context.isLexicalBlock())
return processLexicalBlock(DILexicalBlock(Context.getNode()));
else
return processSubprogram(DISubprogram(Context.getNode()));
}
/// processSubprogram - Process DISubprogram.
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
if (SP.isNull())