summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-11-12 01:41:52 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-11-12 01:41:52 +0000
commit5b9bf49c6f6d6016c912719a035e527f56c3a3c3 (patch)
treefea2ce21e33cbde1f82a49f3f34fd02b62515675 /llvm/lib
parent9815be30426035d1c4e457c628952c4edef9124e (diff)
downloadbcm5719-llvm-5b9bf49c6f6d6016c912719a035e527f56c3a3c3.tar.gz
bcm5719-llvm-5b9bf49c6f6d6016c912719a035e527f56c3a3c3.zip
dwarfdump: Dump the contents of DWP indexes
llvm-svn: 252842
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp87
1 files changed, 82 insertions, 5 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
index 172fb9279d4..a050d82c295 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -9,6 +9,9 @@
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorHandling.h"
+
namespace llvm {
bool DWARFUnitIndex::Header::parse(DataExtractor IndexData,
@@ -21,10 +24,7 @@ bool DWARFUnitIndex::Header::parse(DataExtractor IndexData,
}
void DWARFUnitIndex::Header::dump(raw_ostream &OS) const {
- OS << "Index header:\n" << format(" version: %u\n", Version)
- << format(" columns: %u\n", NumColumns)
- << format(" units: %u\n", NumUnits)
- << format(" buckets: %u\n", NumBuckets);
+ OS << format("version = %u slots = %u\n\n", Version, NumBuckets);
}
bool DWARFUnitIndex::parse(DataExtractor IndexData) {
@@ -32,8 +32,85 @@ bool DWARFUnitIndex::parse(DataExtractor IndexData) {
if (!Header.parse(IndexData, &Offset))
return false;
+ Rows = llvm::make_unique<HashRow[]>(Header.NumBuckets);
+ auto Contribs =
+ llvm::make_unique<HashRow::SectionContribution *[]>(Header.NumUnits);
+ ColumnKinds = llvm::make_unique<DwarfSection[]>(Header.NumColumns);
+
+ // Read Hash Table of Signatures
+ for (unsigned i = 0; i != Header.NumBuckets; ++i)
+ Rows[i].Signature = IndexData.getU64(&Offset);
+
+ // Read Parallel Table of Indexes
+ for (unsigned i = 0; i != Header.NumBuckets; ++i) {
+ auto Index = IndexData.getU32(&Offset);
+ if (!Index)
+ continue;
+ Rows[i].Contributions =
+ llvm::make_unique<HashRow::SectionContribution[]>(Header.NumColumns);
+ Contribs[Index - 1] = Rows[i].Contributions.get();
+ }
+
+ // Read the Column Headers
+ for (unsigned i = 0; i != Header.NumColumns; ++i)
+ ColumnKinds[i] = static_cast<DwarfSection>(IndexData.getU32(&Offset));
+
+ // Read Table of Section Offsets
+ for (unsigned i = 0; i != Header.NumUnits; ++i) {
+ auto *Contrib = Contribs[i];
+ for (unsigned i = 0; i != Header.NumColumns; ++i) {
+ Contrib[i].Offset = IndexData.getU32(&Offset);
+ }
+ }
+
+ // Read Table of Section Sizes
+ for (unsigned i = 0; i != Header.NumUnits; ++i) {
+ auto *Contrib = Contribs[i];
+ for (unsigned i = 0; i != Header.NumColumns; ++i) {
+ Contrib[i].Size = IndexData.getU32(&Offset);
+ }
+ }
+
return true;
}
-void DWARFUnitIndex::dump(raw_ostream &OS) const { Header.dump(OS); }
+StringRef DWARFUnitIndex::getColumnHeader(DwarfSection DS) {
+#define CASE(DS) \
+ case DW_SECT_##DS: \
+ return #DS;
+ switch (DS) {
+ CASE(INFO);
+ CASE(TYPES);
+ CASE(ABBREV);
+ CASE(LINE);
+ CASE(LOC);
+ CASE(STR_OFFSETS);
+ CASE(MACINFO);
+ CASE(MACRO);
+ }
+ llvm_unreachable("unknown DwarfSection");
+}
+
+void DWARFUnitIndex::dump(raw_ostream &OS) const {
+ Header.dump(OS);
+ OS << "Index Signature ";
+ for (unsigned i = 0; i != Header.NumColumns; ++i)
+ OS << format(" %-24s", getColumnHeader(ColumnKinds[i]));
+ OS << "\n----- ------------------";
+ for (unsigned i = 0; i != Header.NumColumns; ++i)
+ OS << " ------------------------";
+ OS << '\n';
+ for (unsigned i = 0; i != Header.NumBuckets; ++i) {
+ auto &Row = Rows[i];
+ if (auto *Contribs = Row.Contributions.get()) {
+ OS << format("%5u 0x%016" PRIx64 " ", i, Row.Signature);
+ for (unsigned i = 0; i != Header.NumColumns; ++i) {
+ auto &Contrib = Contribs[i];
+ OS << format("[0x%08u, 0x%08u) ", Contrib.Offset,
+ Contrib.Offset + Contrib.Size);
+ }
+ OS << '\n';
+ }
+ }
+}
}
OpenPOWER on IntegriCloud