DWARF: Make DIE printing more bulletproof.

llvm-svn: 139786
This commit is contained in:
Benjamin Kramer 2011-09-15 05:43:00 +00:00
parent e8cdaddcf8
commit 9bca64ff2a
1 changed files with 18 additions and 5 deletions

View File

@ -31,8 +31,12 @@ void DWARFDebugInfoEntryMinimal::dump(raw_ostream &OS,
OS << format("\n0x%8.8x: ", Offset); OS << format("\n0x%8.8x: ", Offset);
if (abbrCode) { if (abbrCode) {
if (AbbrevDecl) { if (AbbrevDecl) {
OS.indent(indent) << TagString(AbbrevDecl->getTag()) const char *tagString = TagString(getTag());
<< format(" [%u] %c\n", abbrCode, if (tagString)
OS.indent(indent) << tagString;
else
OS.indent(indent) << format("DW_TAG_Unknown_%x", getTag());
OS << format(" [%u] %c\n", abbrCode,
AbbrevDecl->hasChildren() ? '*' : ' '); AbbrevDecl->hasChildren() ? '*' : ' ');
// Dump all data in the .debug_info for the attributes // Dump all data in the .debug_info for the attributes
@ -67,8 +71,17 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS,
uint16_t form, uint16_t form,
unsigned indent) const { unsigned indent) const {
OS << format("0x%8.8x: ", *offset_ptr); OS << format("0x%8.8x: ", *offset_ptr);
OS.indent(indent+2) << AttributeString(attr) OS.indent(indent+2);
<< " [" << FormEncodingString(form) << ']'; const char *attrString = AttributeString(attr);
if (attrString)
OS << attrString;
else
OS << format("DW_AT_Unknown_%x", attr);
const char *formString = FormEncodingString(form);
if (formString)
OS << " [" << formString << ']';
else
OS << format(" [DW_FORM_Unknown_%x]", form);
DWARFFormValue formValue(form); DWARFFormValue formValue(form);