Skip to content

Commit

Permalink
[dwarfdump] Improve -diff option by hiding more data.
Browse files Browse the repository at this point in the history
The -diff option makes it easy to diff dwarf by hiding addresses and
offsets. However not all of them were hidden, which should be fixed by
this patch.

Differential revision: https://reviews.llvm.org/D51593

llvm-svn: 341377
  • Loading branch information
JDevlieghere committed Sep 4, 2018
1 parent 76c4c3a commit 8814523
Show file tree
Hide file tree
Showing 3 changed files with 501 additions and 9 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
Expand Up @@ -244,15 +244,17 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
else
formValue.dump(OS, DumpOpts);

std::string Space = DumpOpts.ShowAddresses ? " " : "";

// 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.
if (Attr == DW_AT_specification || Attr == DW_AT_abstract_origin) {
if (const char *Name = Die.getAttributeValueAsReferencedDie(Attr).getName(
DINameKind::LinkageName))
OS << " \"" << Name << '\"';
OS << Space << "\"" << Name << '\"';
} else if (Attr == DW_AT_type) {
OS << " \"";
OS << Space << "\"";
dumpTypeName(OS, Die);
OS << '"';
} else if (Attr == DW_AT_APPLE_property_attribute) {
Expand Down
15 changes: 8 additions & 7 deletions llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
Expand Up @@ -387,16 +387,16 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
switch (Form) {
case DW_FORM_exprloc:
case DW_FORM_block:
OS << format("<0x%" PRIx64 "> ", UValue);
AddrOS << format("<0x%" PRIx64 "> ", UValue);
break;
case DW_FORM_block1:
OS << format("<0x%2.2x> ", (uint8_t)UValue);
AddrOS << format("<0x%2.2x> ", (uint8_t)UValue);
break;
case DW_FORM_block2:
OS << format("<0x%4.4x> ", (uint16_t)UValue);
AddrOS << format("<0x%4.4x> ", (uint16_t)UValue);
break;
case DW_FORM_block4:
OS << format("<0x%8.8x> ", (uint32_t)UValue);
AddrOS << format("<0x%8.8x> ", (uint32_t)UValue);
break;
default:
break;
Expand All @@ -407,7 +407,7 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
// UValue contains size of block
const uint8_t *EndDataPtr = DataPtr + UValue;
while (DataPtr < EndDataPtr) {
OS << format("%2.2x ", *DataPtr);
AddrOS << format("%2.2x ", *DataPtr);
++DataPtr;
}
} else
Expand Down Expand Up @@ -501,8 +501,9 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
if (CURelativeOffset) {
if (DumpOpts.Verbose)
OS << " => {";
WithColor(OS, HighlightColor::Address).get()
<< format("0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
if (DumpOpts.ShowAddresses)
WithColor(OS, HighlightColor::Address).get()
<< format("0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
if (DumpOpts.Verbose)
OS << "}";
}
Expand Down

0 comments on commit 8814523

Please sign in to comment.