diff options
author | Fangrui Song <maskray@google.com> | 2018-11-05 23:27:53 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-11-05 23:27:53 +0000 |
commit | 54d23a8eb7eac3445450bacbe7a6336197ccdbf5 (patch) | |
tree | 17377c11937d33a6022ff7fcb13db103b4396024 | |
parent | 0b5f8169b026f2faf2713892ecc9c9e48646f5a4 (diff) | |
download | bcm5719-llvm-54d23a8eb7eac3445450bacbe7a6336197ccdbf5.tar.gz bcm5719-llvm-54d23a8eb7eac3445450bacbe7a6336197ccdbf5.zip |
[DWARF] Support types CU list in .gdb_index dumping
Some executables have non-empty types CU list and -gdb-index would report "<error reporting>" before.
llvm-svn: 346181
-rw-r--r-- | llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h | 9 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp | 23 |
2 files changed, 29 insertions, 3 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h index 8d1ac5c83c2..073e02903c3 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h @@ -24,6 +24,7 @@ class DWARFGdbIndex { uint32_t Version; uint32_t CuListOffset; + uint32_t TuListOffset; uint32_t AddressAreaOffset; uint32_t SymbolTableOffset; uint32_t ConstantPoolOffset; @@ -34,6 +35,13 @@ class DWARFGdbIndex { }; SmallVector<CompUnitEntry, 0> CuList; + struct TypeUnitEntry { + uint64_t Offset; + uint64_t TypeOffset; + uint64_t TypeSignature; + }; + SmallVector<TypeUnitEntry, 0> TuList; + struct AddressEntry { uint64_t LowAddress; /// The low address. uint64_t HighAddress; /// The high address. @@ -55,6 +63,7 @@ class DWARFGdbIndex { uint32_t StringPoolOffset; void dumpCUList(raw_ostream &OS) const; + void dumpTUList(raw_ostream &OS) const; void dumpAddressArea(raw_ostream &OS) const; void dumpSymbolTable(raw_ostream &OS) const; void dumpConstantPool(raw_ostream &OS) const; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp index ebd6104ab87..1abd931e3b8 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cassert> @@ -33,6 +34,16 @@ void DWARFGdbIndex::dumpCUList(raw_ostream &OS) const { CU.Length); } +void DWARFGdbIndex::dumpTUList(raw_ostream &OS) const { + OS << formatv("\n Types CU list offset = {0:x}, has {1} entries:\n", + TuListOffset, TuList.size()); + uint32_t I = 0; + for (const TypeUnitEntry &TU : TuList) + OS << formatv(" {0}: offset = {1:x8}, type_offset = {2:x8}, " + "type_signature = {3:x16}\n", + I++, TU.Offset, TU.TypeOffset, TU.TypeSignature); +} + void DWARFGdbIndex::dumpAddressArea(raw_ostream &OS) const { OS << format("\n Address area offset = 0x%x, has %" PRId64 " entries:", AddressAreaOffset, (uint64_t)AddressArea.size()) @@ -94,6 +105,7 @@ void DWARFGdbIndex::dump(raw_ostream &OS) { if (HasContent) { OS << " Version = " << Version << '\n'; dumpCUList(OS); + dumpTUList(OS); dumpAddressArea(OS); dumpSymbolTable(OS); dumpConstantPool(OS); @@ -127,9 +139,14 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) { // CU Types are no longer needed as DWARF skeleton type units never made it // into the standard. - uint32_t CuTypesListSize = (AddressAreaOffset - CuTypesOffset) / 24; - if (CuTypesListSize != 0) - return false; + uint32_t TuListSize = (AddressAreaOffset - CuTypesOffset) / 24; + TuList.resize(TuListSize); + for (uint32_t I = 0; I < TuListSize; ++I) { + uint64_t CuOffset = Data.getU64(&Offset); + uint64_t TypeOffset = Data.getU64(&Offset); + uint64_t Signature = Data.getU64(&Offset); + TuList[I] = {CuOffset, TypeOffset, Signature}; + } uint32_t AddressAreaSize = (SymbolTableOffset - AddressAreaOffset) / 20; AddressArea.reserve(AddressAreaSize); |