DWARF: Fail gracefully when encountering unknown values in an abbrev.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 15 Sep 2011 04:00:58 +0000 (04:00 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 15 Sep 2011 04:00:58 +0000 (04:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139777 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/DWARFAbbreviationDeclaration.cpp

index 7bc942f63dd5e7dc97a1fd1718a76f0538e020c2..74c975304af19696eae744710bb3594fd2a3b4a5 100644 (file)
@@ -47,11 +47,16 @@ DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr,
 }
 
 void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
-  OS << '[' << getCode() << "] " << TagString(getTag()) << "\tDW_CHILDREN_"
+  const char *tagString = TagString(getTag());
+  OS << '[' << getCode() << "] " << (tagString ? tagString : "DW_TAG_Unknown")
+     << "\tDW_CHILDREN_"
      << (hasChildren() ? "yes" : "no") << '\n';
-  for (unsigned i = 0, e = Attributes.size(); i != e; ++i)
-    OS << '\t' << AttributeString(Attributes[i].getAttribute())
-       << '\t' << FormEncodingString(Attributes[i].getForm()) << '\n';
+  for (unsigned i = 0, e = Attributes.size(); i != e; ++i) {
+    const char *attrString = AttributeString(Attributes[i].getAttribute());
+    const char *formString = FormEncodingString(Attributes[i].getForm());
+    OS << '\t' << (attrString ? attrString : "DW_AT_Unknown")
+       << '\t' << (formString ? formString : "DW_FORM_Unknown") << '\n';
+  }
   OS << '\n';
 }