return 0;
if (Elt < DbgNode->getNumOperands())
- if (ConstantInt *CI = dyn_cast<ConstantInt>(DbgNode->getOperand(Elt)))
+ if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(DbgNode->getOperand(Elt)))
return CI->getZExtValue();
return 0;
case dwarf::DW_TAG_typedef:
case dwarf::DW_TAG_pointer_type:
case dwarf::DW_TAG_reference_type:
+ case dwarf::DW_TAG_rvalue_reference_type:
case dwarf::DW_TAG_const_type:
case dwarf::DW_TAG_volatile_type:
case dwarf::DW_TAG_restrict_type:
return DbgNode && getTag() == dwarf::DW_TAG_enumerator;
}
+/// isObjCProperty - Return true if the specified tag is DW_TAG
+bool DIDescriptor::isObjCProperty() const {
+ return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property;
+}
//===----------------------------------------------------------------------===//
// Simple Descriptor Constructors and other Methods
//===----------------------------------------------------------------------===//
return true;
}
+/// Verify - Verify that an ObjC property is well formed.
+bool DIObjCProperty::Verify() const {
+ if (!DbgNode)
+ return false;
+ unsigned Tag = getTag();
+ if (Tag != dwarf::DW_TAG_APPLE_property) return false;
+ DIType Ty = getType();
+ if (!Ty.Verify()) return false;
+
+ // Don't worry about the rest of the strings for now.
+ return true;
+}
+
/// Verify - Verify that a type descriptor is well formed.
bool DIType::Verify() const {
if (!DbgNode)
unsigned Tag = getTag();
if (!isBasicType() && Tag != dwarf::DW_TAG_const_type &&
Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type &&
- Tag != dwarf::DW_TAG_reference_type && Tag != dwarf::DW_TAG_restrict_type
- && Tag != dwarf::DW_TAG_vector_type && Tag != dwarf::DW_TAG_array_type
- && Tag != dwarf::DW_TAG_enumeration_type
- && Tag != dwarf::DW_TAG_subroutine_type
- && getFilename().empty())
+ Tag != dwarf::DW_TAG_reference_type &&
+ Tag != dwarf::DW_TAG_rvalue_reference_type &&
+ Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_vector_type &&
+ Tag != dwarf::DW_TAG_array_type &&
+ Tag != dwarf::DW_TAG_enumeration_type &&
+ Tag != dwarf::DW_TAG_subroutine_type &&
+ getFilename().empty())
return false;
return true;
}
// it's a reference then it's just the size of the field. Pointer types
// have no need of this since they're a different type of qualification
// on the type.
- if (BaseType.getTag() == dwarf::DW_TAG_reference_type)
+ if (BaseType.getTag() == dwarf::DW_TAG_reference_type ||
+ BaseType.getTag() == dwarf::DW_TAG_rvalue_reference_type)
return getSizeInBits();
else if (BaseType.isDerivedType())
return DIDerivedType(BaseType).getOriginalTypeSize();
return getSizeInBits();
}
+/// getObjCProperty - Return property node, if this ivar is associated with one.
+MDNode *DIDerivedType::getObjCProperty() const {
+ if (getVersion() <= LLVMDebugVersion11 || DbgNode->getNumOperands() <= 10)
+ return NULL;
+ return dyn_cast_or_null<MDNode>(DbgNode->getOperand(10));
+}
+
/// isInlinedFnArgument - Return true if this variable provides debugging
/// information for an inlined function arguments.
bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
return DIType(DbgNode).getFilename();
if (isFile())
return DIFile(DbgNode).getFilename();
- assert(0 && "Invalid DIScope!");
- return StringRef();
+ llvm_unreachable("Invalid DIScope!");
}
StringRef DIScope::getDirectory() const {
return DIType(DbgNode).getDirectory();
if (isFile())
return DIFile(DbgNode).getDirectory();
- assert(0 && "Invalid DIScope!");
- return StringRef();
+ llvm_unreachable("Invalid DIScope!");
}
DIArray DICompileUnit::getEnumTypes() const {
// DIDescriptor: dump routines for all descriptors.
//===----------------------------------------------------------------------===//
+/// dump - Print descriptor to dbgs() with a newline.
+void DIDescriptor::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
/// print - Print descriptor.
void DIDescriptor::print(raw_ostream &OS) const {
- OS << "[" << dwarf::TagString(getTag()) << "] ";
- OS.write_hex((intptr_t) &*DbgNode) << ']';
+ if (!DbgNode) return;
+
+ OS << "[" << dwarf::TagString(getTag()) << ']';
+
+ 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()) {
+ DIFile(DbgNode).printInternal(OS);
+ } else if (this->isEnumerator()) {
+ DIEnumerator(DbgNode).printInternal(OS);
+ } else if (this->isBasicType()) {
+ DIType(DbgNode).printInternal(OS);
+ } else if (this->isDerivedType()) {
+ DIDerivedType(DbgNode).printInternal(OS);
+ } else if (this->isCompositeType()) {
+ DICompositeType(DbgNode).printInternal(OS);
+ } else if (this->isSubprogram()) {
+ DISubprogram(DbgNode).printInternal(OS);
+ } else if (this->isGlobalVariable()) {
+ DIGlobalVariable(DbgNode).printInternal(OS);
+ } else if (this->isVariable()) {
+ DIVariable(DbgNode).printInternal(OS);
+ }
+}
+
+void DISubrange::printInternal(raw_ostream &OS) const {
+ OS << " [" << getLo() << ", " << getHi() << ']';
+}
+
+void DIScope::printInternal(raw_ostream &OS) const {
+ OS << " [" << getDirectory() << "/" << getFilename() << ']';
}
-/// print - Print compile unit.
-void DICompileUnit::print(raw_ostream &OS) const {
- if (getLanguage())
- OS << " [" << dwarf::LanguageString(getLanguage()) << "] ";
+void DICompileUnit::printInternal(raw_ostream &OS) const {
+ DIScope::printInternal(OS);
+ if (unsigned Lang = getLanguage())
+ OS << " [" << dwarf::LanguageString(Lang) << ']';
+}
- OS << " [" << getDirectory() << "/" << getFilename() << "]";
+void DIEnumerator::printInternal(raw_ostream &OS) const {
+ OS << " [" << getName() << " :: " << getEnumValue() << ']';
}
-/// print - Print type.
-void DIType::print(raw_ostream &OS) const {
+void DIType::printInternal(raw_ostream &OS) const {
if (!DbgNode) return;
StringRef Res = getName();
if (!Res.empty())
- OS << " [" << Res << "] ";
+ OS << " [" << Res << "]";
- unsigned Tag = getTag();
- OS << " [" << dwarf::TagString(Tag) << "] ";
+ // TODO: Print context?
- // TODO : Print context
- OS << " ["
- << "line " << getLineNumber() << ", "
- << getSizeInBits() << " bits, "
- << getAlignInBits() << " bit alignment, "
- << getOffsetInBits() << " bit offset"
- << "] ";
+ OS << " [line " << getLineNumber()
+ << ", size " << getSizeInBits()
+ << ", align " << getAlignInBits()
+ << ", offset " << getOffsetInBits();
+ if (isBasicType())
+ OS << ", enc "
+ << dwarf::AttributeEncodingString(DIBasicType(DbgNode).getEncoding());
+ OS << "]";
if (isPrivate())
- OS << " [private] ";
+ OS << " [private]";
else if (isProtected())
- OS << " [protected] ";
+ OS << " [protected]";
if (isForwardDecl())
- OS << " [fwd] ";
-
- if (isBasicType())
- DIBasicType(DbgNode).print(OS);
- else if (isDerivedType())
- DIDerivedType(DbgNode).print(OS);
- else if (isCompositeType())
- DICompositeType(DbgNode).print(OS);
- else {
- OS << "Invalid DIType\n";
- return;
- }
-
- OS << "\n";
-}
-
-/// print - Print basic type.
-void DIBasicType::print(raw_ostream &OS) const {
- OS << " [" << dwarf::AttributeEncodingString(getEncoding()) << "] ";
+ OS << " [fwd]";
}
-/// print - Print derived type.
-void DIDerivedType::print(raw_ostream &OS) const {
- OS << "\n\t Derived From: "; getTypeDerivedFrom().print(OS);
+void DIDerivedType::printInternal(raw_ostream &OS) const {
+ DIType::printInternal(OS);
+ OS << " [from " << getTypeDerivedFrom().getName() << ']';
}
-/// print - Print composite type.
-void DICompositeType::print(raw_ostream &OS) const {
+void DICompositeType::printInternal(raw_ostream &OS) const {
+ DIType::printInternal(OS);
DIArray A = getTypeArray();
OS << " [" << A.getNumElements() << " elements]";
}
-/// print - Print subprogram.
-void DISubprogram::print(raw_ostream &OS) const {
+void DISubprogram::printInternal(raw_ostream &OS) const {
StringRef Res = getName();
if (!Res.empty())
- OS << " [" << Res << "] ";
-
- unsigned Tag = getTag();
- OS << " [" << dwarf::TagString(Tag) << "] ";
+ OS << " [" << Res << ']';
// TODO : Print context
- OS << " [" << getLineNumber() << "] ";
+
+ OS << " [line " << getLineNumber() << ']';
if (isLocalToUnit())
- OS << " [local] ";
+ OS << " [local]";
if (isDefinition())
- OS << " [def] ";
+ OS << " [def]";
- OS << "\n";
+ if (getScopeLineNumber() != getLineNumber())
+ OS << " [scope " << getScopeLineNumber() << "]";
}
-/// print - Print global variable.
-void DIGlobalVariable::print(raw_ostream &OS) const {
- OS << " [";
+void DIGlobalVariable::printInternal(raw_ostream &OS) const {
StringRef Res = getName();
if (!Res.empty())
- OS << " [" << Res << "] ";
+ OS << " [" << Res << ']';
- unsigned Tag = getTag();
- OS << " [" << dwarf::TagString(Tag) << "] ";
+ OS << " [line " << getLineNumber() << ']';
// TODO : Print context
- OS << " [" << getLineNumber() << "] ";
if (isLocalToUnit())
- OS << " [local] ";
+ OS << " [local]";
if (isDefinition())
- OS << " [def] ";
+ OS << " [def]";
+}
- if (isGlobalVariable())
- DIGlobalVariable(DbgNode).print(OS);
- OS << "]\n";
+void DIVariable::printInternal(raw_ostream &OS) const {
+ StringRef Res = getName();
+ if (!Res.empty())
+ OS << " [" << Res << ']';
+
+ OS << " [line " << getLineNumber() << ']';
}
static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS,
}
}
-/// print - Print variable.
-void DIVariable::print(raw_ostream &OS) const {
- StringRef Res = getName();
- if (!Res.empty())
- OS << " [" << Res << "] ";
-
- OS << " [" << getLineNumber() << "] ";
- getType().print(OS);
- OS << "\n";
-
- // FIXME: Dump complex addresses
-}
-
-/// dump - Print descriptor to dbgs() with a newline.
-void DIDescriptor::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print compile unit to dbgs() with a newline.
-void DICompileUnit::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print type to dbgs() with a newline.
-void DIType::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print basic type to dbgs() with a newline.
-void DIBasicType::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print derived type to dbgs() with a newline.
-void DIDerivedType::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print composite type to dbgs() with a newline.
-void DICompositeType::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print subprogram to dbgs() with a newline.
-void DISubprogram::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print global variable.
-void DIGlobalVariable::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
-/// dump - Print variable.
-void DIVariable::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
/// fixupObjcLikeName - Replace contains special characters used
/// in a typical Objective-C names with '.' in a given string.
static void fixupObjcLikeName(StringRef Str, SmallVectorImpl<char> &Out) {
DICompileUnit CU(CU_Nodes->getOperand(i));
addCompileUnit(CU);
if (CU.getVersion() > LLVMDebugVersion10) {
- DIArray GVs = CU.getGlobalVariables();
- for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
- DIGlobalVariable DIG(GVs.getElement(i));
- if (addGlobalVariable(DIG))
- processType(DIG.getType());
- }
- DIArray SPs = CU.getSubprograms();
- for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
- processSubprogram(DISubprogram(SPs.getElement(i)));
- DIArray EnumTypes = CU.getEnumTypes();
- for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
- processType(DIType(EnumTypes.getElement(i)));
- DIArray RetainedTypes = CU.getRetainedTypes();
- for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)
- processType(DIType(RetainedTypes.getElement(i)));
- return;
+ DIArray GVs = CU.getGlobalVariables();
+ for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
+ DIGlobalVariable DIG(GVs.getElement(i));
+ if (addGlobalVariable(DIG))
+ processType(DIG.getType());
+ }
+ DIArray SPs = CU.getSubprograms();
+ for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
+ processSubprogram(DISubprogram(SPs.getElement(i)));
+ DIArray EnumTypes = CU.getEnumTypes();
+ for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
+ processType(DIType(EnumTypes.getElement(i)));
+ DIArray RetainedTypes = CU.getRetainedTypes();
+ for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)
+ processType(DIType(RetainedTypes.getElement(i)));
+ return;
}
}
}