Index: llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -14,6 +14,7 @@ #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" #include @@ -101,7 +102,7 @@ bool isFormClass(FormClass FC) const; const DWARFUnit *getUnit() const { return U; } - void dump(raw_ostream &OS) const; + void dump(raw_ostream &OS, DIDumpOptions DumpOpts = DIDumpOptions()) const; /// Extracts a value in \p Data at offset \p *OffsetPtr. /// Index: llvm/lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -55,7 +55,7 @@ unsigned AddressSize, unsigned Indent) { if (Ranges.empty()) return; - + for (const auto &Range: Ranges) { OS << '\n'; OS.indent(Indent); @@ -90,12 +90,12 @@ DWARFUnit *U = Die.getDwarfUnit(); DWARFFormValue formValue(Form); - + if (!formValue.extractValue(U->getDebugInfoExtractor(), OffsetPtr, U)) return; - + OS << "\t("; - + StringRef Name; std::string File; auto Color = syntax::Enumerator; @@ -108,14 +108,14 @@ } } else if (Optional Val = formValue.getAsUnsignedConstant()) Name = AttributeValueString(Attr, *Val); - + if (!Name.empty()) WithColor(OS, Color) << Name; else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) OS << *formValue.getAsUnsignedConstant(); else - formValue.dump(OS); - + formValue.dump(OS, DumpOpts); + // We have dumped the attribute raw value. For some attributes // having both the raw value and the pretty-printed value is // interesting. These attributes are handled below. @@ -129,7 +129,7 @@ dumpRanges(OS, Die.getAddressRanges(), U->getAddressByteSize(), sizeof(BaseIndent)+Indent+4); } - + OS << ")\n"; } @@ -311,11 +311,11 @@ DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor(); const uint32_t Offset = getOffset(); uint32_t offset = Offset; - + if (debug_info_data.isValidOffset(offset)) { uint32_t abbrCode = debug_info_data.getULEB128(&offset); WithColor(OS, syntax::Address).get() << format("\n0x%8.8x: ", Offset); - + if (abbrCode) { auto AbbrevDecl = getAbbreviationDeclarationPtr(); if (AbbrevDecl) { @@ -342,7 +342,7 @@ dumpAttribute(OS, *this, &offset, AttrSpec.Attr, AttrSpec.Form, Indent, DumpOpts); } - + DWARFDie child = getFirstChild(); if (RecurseDepth > 0 && child) { while (child) { Index: llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -396,7 +396,7 @@ return true; } -void DWARFFormValue::dump(raw_ostream &OS) const { +void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { uint64_t UValue = Value.uval; bool CURelativeOffset = false; @@ -481,7 +481,10 @@ OS << Value.uval; break; case DW_FORM_strp: - OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)UValue); + if (!DumpOpts.Brief) + OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)UValue); + else + OS << format(" .debug_str = ", (uint32_t)UValue); dumpString(OS); break; case DW_FORM_strx: @@ -540,7 +543,7 @@ break; } - if (CURelativeOffset) { + if (CURelativeOffset && !DumpOpts.Brief) { OS << " => {"; WithColor(OS, syntax::Address).get() << format("0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));