return 0;
if (Elt < DbgNode->getNumOperands())
- if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(DbgNode->getOperand(Elt)))
+ if (ConstantInt *CI
+ = dyn_cast_or_null<ConstantInt>(DbgNode->getOperand(Elt)))
return CI->getZExtValue();
return 0;
return 0;
}
+void DIDescriptor::replaceFunctionField(unsigned Elt, Function *F) {
+ if (DbgNode == 0)
+ return;
+
+ if (Elt < DbgNode->getNumOperands()) {
+ MDNode *Node = const_cast<MDNode*>(DbgNode);
+ Node->replaceOperandWith(Elt, F);
+ }
+}
+
unsigned DIVariable::getNumAddrElements() const {
- if (getVersion() <= llvm::LLVMDebugVersion8)
+ if (getVersion() <= LLVMDebugVersion8)
return DbgNode->getNumOperands()-6;
- if (getVersion() == llvm::LLVMDebugVersion9)
+ if (getVersion() == LLVMDebugVersion9)
return DbgNode->getNumOperands()-7;
return DbgNode->getNumOperands()-8;
}
/// getInlinedAt - If this variable is inlined then return inline location.
MDNode *DIVariable::getInlinedAt() const {
- if (getVersion() <= llvm::LLVMDebugVersion9)
+ if (getVersion() <= LLVMDebugVersion9)
return NULL;
return dyn_cast_or_null<MDNode>(DbgNode->getOperand(7));
}
}
}
-/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
+/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
/// suitable to hold function specific information.
NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, DISubprogram Fn) {
SmallString<32> Name = StringRef("llvm.dbg.lv.");
if (FName.startswith(StringRef(&One, 1)))
FName = FName.substr(1);
fixupObjcLikeName(FName, Name);
-
+
return M.getOrInsertNamedMetadata(Name.str());
}
SmallVector<Value *, 16> Elts;
// Insert inlined scope as 7th element.
for (unsigned i = 0, e = DV->getNumOperands(); i != e; ++i)
- i == 7 ?
- Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext))):
+ i == 7 ?
+ Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext))):
Elts.push_back(DV->getOperand(i));
return DIVariable(MDNode::get(VMContext, Elts));
}
if (D.isLexicalBlockFile())
return getDISubprogram(DILexicalBlockFile(Scope).getContext());
-
+
if (D.isLexicalBlock())
return getDISubprogram(DILexicalBlock(Scope).getContext());
//===----------------------------------------------------------------------===//
/// processModule - Process entire module and collect debug info.
-void DebugInfoFinder::processModule(Module &M) {
+void DebugInfoFinder::processModule(const Module &M) {
if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
DICompileUnit CU(CU_Nodes->getOperand(i));
}
}
- 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;
- ++BI) {
- if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
+ for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
+ for (Function::const_iterator FI = (*I).begin(), FE = (*I).end();
+ FI != FE; ++FI)
+ for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end();
+ BI != BE; ++BI) {
+ if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
processDeclare(DDI);
DebugLoc Loc = BI->getDebugLoc();
}
/// processDeclare - Process DbgDeclareInst.
-void DebugInfoFinder::processDeclare(DbgDeclareInst *DDI) {
+void DebugInfoFinder::processDeclare(const DbgDeclareInst *DDI) {
MDNode *N = dyn_cast<MDNode>(DDI->getVariable());
if (!N) return;
void DIDescriptor::print(raw_ostream &OS) const {
if (!DbgNode) return;
- OS << "[" << dwarf::TagString(getTag()) << ']';
+ if (const char *Tag = dwarf::TagString(getTag()))
+ OS << "[ " << Tag << " ]";
if (this->isSubrange()) {
DISubrange(DbgNode).printInternal(OS);
- } else if (this->isScope()) {
- DIScope(DbgNode).printInternal(OS);
} else if (this->isCompileUnit()) {
DICompileUnit(DbgNode).printInternal(OS);
} else if (this->isFile()) {
DIGlobalVariable(DbgNode).printInternal(OS);
} else if (this->isVariable()) {
DIVariable(DbgNode).printInternal(OS);
+ } else if (this->isObjCProperty()) {
+ DIObjCProperty(DbgNode).printInternal(OS);
+ } else if (this->isScope()) {
+ DIScope(DbgNode).printInternal(OS);
}
}
<< ", align " << getAlignInBits()
<< ", offset " << getOffsetInBits();
if (isBasicType())
- if (const char *Enc =
+ if (const char *Enc =
dwarf::AttributeEncodingString(DIBasicType(DbgNode).getEncoding()))
OS << ", enc " << Enc;
OS << "]";
}
void DISubprogram::printInternal(raw_ostream &OS) const {
- StringRef Res = getName();
- if (!Res.empty())
- OS << " [" << Res << ']';
-
// TODO : Print context
-
OS << " [line " << getLineNumber() << ']';
if (isLocalToUnit())
if (getScopeLineNumber() != getLineNumber())
OS << " [scope " << getScopeLineNumber() << "]";
+
+ StringRef Res = getName();
+ if (!Res.empty())
+ OS << " [" << Res << ']';
}
void DIGlobalVariable::printInternal(raw_ostream &OS) const {
OS << " [line " << getLineNumber() << ']';
}
+void DIObjCProperty::printInternal(raw_ostream &OS) const {
+ StringRef Name = getObjCPropertyName();
+ if (!Name.empty())
+ OS << " [" << Name << ']';
+
+ OS << " [line " << getLineNumber()
+ << ", properties " << getUnsignedField(6) << ']';
+}
+
static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS,
const LLVMContext &Ctx) {
if (!DL.isUnknown()) { // Print source line info.
}
}
}
-
-//===----------------------------------------------------------------------===//
-// DIDescriptor: vtable anchors for all descriptors.
-//===----------------------------------------------------------------------===//
-
-void DIScope::anchor() { }
-
-void DICompileUnit::anchor() { }
-
-void DIFile::anchor() { }
-
-void DIType::anchor() { }
-
-void DIBasicType::anchor() { }
-
-void DIDerivedType::anchor() { }
-
-void DICompositeType::anchor() { }
-
-void DISubprogram::anchor() { }
-
-void DILexicalBlock::anchor() { }
-
-void DINameSpace::anchor() { }
-
-void DILexicalBlockFile::anchor() { }