[llvm] r337026 - [dwarfdump] Add pretty printer for accelerator table based on Atom.
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 13 10:21:52 PDT 2018
Author: jdevlieghere
Date: Fri Jul 13 10:21:51 2018
New Revision: 337026
URL: http://llvm.org/viewvc/llvm-project?rev=337026&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
llvm/trunk/lib/BinaryFormat/Dwarf.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
llvm/trunk/test/tools/dsymutil/X86/objc.test
Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.h?rev=337026&r1=337025&r2=337026&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Dwarf.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.h Fri Jul 13 10:21:51 2018
@@ -540,6 +540,10 @@ bool isValidFormForVersion(Form F, unsig
/// 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:
Modified: llvm/trunk/lib/BinaryFormat/Dwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/BinaryFormat/Dwarf.cpp?rev=337026&r1=337025&r2=337026&view=diff
==============================================================================
--- llvm/trunk/lib/BinaryFormat/Dwarf.cpp (original)
+++ llvm/trunk/lib/BinaryFormat/Dwarf.cpp Fri Jul 13 10:21:51 2018
@@ -571,6 +571,17 @@ StringRef llvm::dwarf::AttributeValueStr
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:
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp?rev=337026&r1=337025&r2=337026&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp Fri Jul 13 10:21:51 2018
@@ -183,12 +183,18 @@ bool AppleAcceleratorTable::dumpName(Sco
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
Modified: llvm/trunk/test/tools/dsymutil/X86/objc.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/X86/objc.test?rev=337026&r1=337025&r2=337026&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/X86/objc.test (original)
+++ llvm/trunk/test/tools/dsymutil/X86/objc.test Fri Jul 13 10:21:51 2018
@@ -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: ]
More information about the llvm-commits
mailing list