diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-07-13 17:21:51 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-07-13 17:21:51 +0000 |
commit | 327e7a16083c0bec70841288876815554e5f4367 (patch) | |
tree | 46bdb32e11eb2d64e903b3d9b16a3d7e7792edc4 | |
parent | e86e6efea18ee10893b9f0d659482dbfdfe25e00 (diff) | |
download | bcm5719-llvm-327e7a16083c0bec70841288876815554e5f4367.tar.gz bcm5719-llvm-327e7a16083c0bec70841288876815554e5f4367.zip |
[dwarfdump] Add pretty printer for accelerator table based on Atom.
For instance, When dumping .apple_types, the second atom represents the
DW_TAG. In addition to printing the raw value, we now also pretty print
the value if the ATOM tells us how.
llvm-svn: 337026
-rw-r--r-- | llvm/include/llvm/BinaryFormat/Dwarf.h | 4 | ||||
-rw-r--r-- | llvm/lib/BinaryFormat/Dwarf.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 12 | ||||
-rw-r--r-- | llvm/test/tools/dsymutil/X86/objc.test | 2 |
4 files changed, 25 insertions, 4 deletions
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 15724a9444a..9036f405eae 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -540,6 +540,10 @@ bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk = true); /// for attribute Attr. StringRef AttributeValueString(uint16_t Attr, unsigned Val); +/// Returns the symbolic string representing Val when used as a value +/// for atom Atom. +StringRef AtomValueString(uint16_t Atom, unsigned Val); + /// Describes an entry of the various gnu_pub* debug sections. /// /// The gnu_pub* kind looks like: diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp index a2e86c7a014..5984de73ae6 100644 --- a/llvm/lib/BinaryFormat/Dwarf.cpp +++ b/llvm/lib/BinaryFormat/Dwarf.cpp @@ -571,6 +571,17 @@ StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) { return StringRef(); } +StringRef llvm::dwarf::AtomValueString(uint16_t Atom, unsigned Val) { + switch (Atom) { + case DW_ATOM_null: + return "NULL"; + case DW_ATOM_die_tag: + return TagString(Val); + } + + return StringRef(); +} + StringRef llvm::dwarf::IndexString(unsigned Idx) { switch (Idx) { default: diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index 0ded97cabf2..4582e036f9f 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -183,12 +183,18 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W, ListScope DataScope(W, ("Data " + Twine(Data)).str()); unsigned i = 0; for (auto &Atom : AtomForms) { - W.startLine() << format("Atom[%d]: ", i++); - if (Atom.extractValue(AccelSection, DataOffset, FormParams)) + W.startLine() << format("Atom[%d]: ", i); + if (Atom.extractValue(AccelSection, DataOffset, FormParams)) { Atom.dump(W.getOStream()); - else + if (Optional<uint64_t> Val = Atom.getAsUnsignedConstant()) { + StringRef Str = dwarf::AtomValueString(HdrData.Atoms[i].first, *Val); + if (!Str.empty()) + W.getOStream() << " (" << Str << ")"; + } + } else W.getOStream() << "Error extracting the value"; W.getOStream() << "\n"; + i++; } } return true; // more entries follow diff --git a/llvm/test/tools/dsymutil/X86/objc.test b/llvm/test/tools/dsymutil/X86/objc.test index 7acb7c7f0bb..47dfef56b24 100644 --- a/llvm/test/tools/dsymutil/X86/objc.test +++ b/llvm/test/tools/dsymutil/X86/objc.test @@ -5,7 +5,7 @@ CHECK: .apple_types contents: CHECK: String: 0x00000066 "A" CHECK-NEXT: Data 0 [ CHECK-NEXT: Atom[0]: 0x0000012d -CHECK-NEXT: Atom[1]: 0x0013 +CHECK-NEXT: Atom[1]: 0x0013 (DW_TAG_structure_type) CHECK-NEXT: Atom[2]: 0x02 CHECK-NEXT: Atom[3]: 0x0b87b15a CHECK-NEXT: ] |