Revert r282235 "[llvm-dwarfdump] - Teach dwarfdump to dump gdb-index section."

It broke BB:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15856

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282238 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
George Rimar 2016-09-23 10:12:56 +00:00
parent b9dfeea817
commit 53a7de61aa
9 changed files with 0 additions and 304 deletions

View File

@ -124,7 +124,6 @@ enum DIDumpType {
DIDT_AppleNamespaces,
DIDT_AppleObjC,
DIDT_CUIndex,
DIDT_GdbIndex,
DIDT_TUIndex,
};

View File

@ -20,7 +20,6 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
@ -42,7 +41,6 @@ class DWARFContext : public DIContext {
DWARFUnitSection<DWARFCompileUnit> CUs;
std::deque<DWARFUnitSection<DWARFTypeUnit>> TUs;
std::unique_ptr<DWARFUnitIndex> CUIndex;
std::unique_ptr<DWARFGdbIndex> GdbIndex;
std::unique_ptr<DWARFUnitIndex> TUIndex;
std::unique_ptr<DWARFDebugAbbrev> Abbrev;
std::unique_ptr<DWARFDebugLoc> Loc;
@ -151,7 +149,6 @@ public:
}
const DWARFUnitIndex &getCUIndex();
DWARFGdbIndex &getGdbIndex();
const DWARFUnitIndex &getTUIndex();
/// Get a pointer to the parsed DebugAbbrev object.
@ -223,7 +220,6 @@ public:
virtual const DWARFSection& getAppleNamespacesSection() = 0;
virtual const DWARFSection& getAppleObjCSection() = 0;
virtual StringRef getCUIndexSection() = 0;
virtual StringRef getGdbIndexSection() = 0;
virtual StringRef getTUIndexSection() = 0;
static bool isSupportedVersion(unsigned version) {
@ -276,7 +272,6 @@ class DWARFContextInMemory : public DWARFContext {
DWARFSection AppleNamespacesSection;
DWARFSection AppleObjCSection;
StringRef CUIndexSection;
StringRef GdbIndexSection;
StringRef TUIndexSection;
SmallVector<SmallString<32>, 4> UncompressedSections;
@ -323,7 +318,6 @@ public:
return AddrSection;
}
StringRef getCUIndexSection() override { return CUIndexSection; }
StringRef getGdbIndexSection() override { return GdbIndexSection; }
StringRef getTUIndexSection() override { return TUIndexSection; }
};

View File

@ -1,68 +0,0 @@
//===-- DWARFGdbIndex.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_DEBUGINFO_DWARFGDBINDEX_H
#define LLVM_LIB_DEBUGINFO_DWARFGDBINDEX_H
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
class DWARFGdbIndex {
uint32_t Version;
uint32_t CuListOffset;
uint32_t AddressAreaOffset;
uint32_t SymbolTableOffset;
uint32_t ConstantPoolOffset;
struct CompUnitEntry {
uint64_t Offset; // Offset of a CU in the .debug_info section.
uint64_t Length; // Length of that CU.
};
SmallVector<CompUnitEntry, 0> CuList;
struct AddressEntry {
uint64_t LowAddress; // The low address.
uint64_t HighAddress; // The high address.
uint32_t CuIndex; // The CU index.
};
SmallVector<AddressEntry, 0> AddressArea;
struct SymTableEntry {
uint32_t NameOffset; // Offset of the symbol's name in the constant pool.
uint32_t VecOffset; // Offset of the CU vector in the constant pool.
};
SmallVector<SymTableEntry, 0> SymbolTable;
// Each value is CU index + attributes.
SmallVector<std::pair<uint32_t, SmallVector<uint32_t, 0>>, 0>
ConstantPoolVectors;
StringRef ConstantPoolStrings;
uint32_t StringPoolOffset;
void dumpCUList(raw_ostream &OS) const;
void dumpAddressArea(raw_ostream &OS) const;
void dumpSymbolTable(raw_ostream &OS) const;
void dumpConstantPool(raw_ostream &OS) const;
bool parseImpl(DataExtractor Data);
public:
void dump(raw_ostream &OS);
void parse(DataExtractor Data);
bool HasContent = false;
bool HasError = false;
};
}
#endif // LLVM_LIB_DEBUGINFO_DWARFGDBINDEX_H

View File

@ -13,7 +13,6 @@ add_llvm_library(LLVMDebugInfoDWARF
DWARFDebugMacro.cpp
DWARFDebugRangeList.cpp
DWARFFormValue.cpp
DWARFGdbIndex.cpp
DWARFTypeUnit.cpp
DWARFUnitIndex.cpp
DWARFUnit.cpp

View File

@ -256,12 +256,6 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH) {
}
}
if ((DumpType == DIDT_All || DumpType == DIDT_GdbIndex) &&
!getGdbIndexSection().empty()) {
OS << "\n.gnu_index contents:\n";
getGdbIndex().dump(OS);
}
if (DumpType == DIDT_All || DumpType == DIDT_AppleNames)
dumpAccelSection(OS, "apple_names", getAppleNamesSection(),
getStringSection(), isLittleEndian());
@ -301,16 +295,6 @@ const DWARFUnitIndex &DWARFContext::getTUIndex() {
return *TUIndex;
}
DWARFGdbIndex &DWARFContext::getGdbIndex() {
if (GdbIndex)
return *GdbIndex;
DataExtractor GdbIndexData(getGdbIndexSection(), true /*LE*/, 0);
GdbIndex = llvm::make_unique<DWARFGdbIndex>();
GdbIndex->parse(GdbIndexData);
return *GdbIndex;
}
const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {
if (Abbrev)
return Abbrev.get();
@ -734,7 +718,6 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
.Case("apple_objc", &AppleObjCSection.Data)
.Case("debug_cu_index", &CUIndexSection)
.Case("debug_tu_index", &TUIndexSection)
.Case("gdb_index", &GdbIndexSection)
// Any more debug info sections go here.
.Default(nullptr);
if (SectionData) {

View File

@ -1,175 +0,0 @@
//===-- DWARFGdbIndex.cpp -------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
using namespace llvm;
// .gdb_index section format reference:
// https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
void DWARFGdbIndex::dumpCUList(raw_ostream &OS) const {
OS << format("\n CU list offset = 0x%x, has %zu entries:", CuListOffset,
CuList.size())
<< '\n';
uint32_t I = 0;
for (const CompUnitEntry &CU : CuList)
OS << format(" %d: Offset = 0x%llx, Length = 0x%llx\n", I++, CU.Offset,
CU.Length);
}
void DWARFGdbIndex::dumpAddressArea(raw_ostream &OS) const {
OS << format("\n Address area offset = 0x%x, has %zu entries:",
AddressAreaOffset, AddressArea.size())
<< '\n';
for (const AddressEntry &Addr : AddressArea)
OS << format(
" Low address = 0x%llx, High address = 0x%llx, CU index = %d\n",
Addr.LowAddress, Addr.HighAddress, Addr.CuIndex);
}
void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
OS << format("\n Symbol table offset = 0x%x, size = %zu, filled slots:",
SymbolTableOffset, SymbolTable.size())
<< '\n';
uint32_t I = -1;
for (const SymTableEntry &E : SymbolTable) {
++I;
if (!E.NameOffset && !E.VecOffset)
continue;
OS << format(" %d: Name offset = 0x%x, CU vector offset = 0x%x\n", I,
E.NameOffset, E.VecOffset);
StringRef Name = ConstantPoolStrings.substr(
ConstantPoolOffset - StringPoolOffset + E.NameOffset);
auto CuVector = std::find_if(
ConstantPoolVectors.begin(), ConstantPoolVectors.end(),
[&](const std::pair<uint32_t, SmallVector<uint32_t, 0>> &V) {
return V.first == E.VecOffset;
});
assert(CuVector != ConstantPoolVectors.end() && "Invalid symbol table");
uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin();
OS << format(" String name: %s, CU vector index: %d\n", Name.data(),
CuVectorId);
}
}
void DWARFGdbIndex::dumpConstantPool(raw_ostream &OS) const {
OS << format("\n Constant pool offset = 0x%x, has %zu CU vectors:",
ConstantPoolOffset, ConstantPoolVectors.size());
uint32_t I = 0;
for (const auto &V : ConstantPoolVectors) {
OS << format("\n %d(0x%x): ", I++, V.first);
for (uint32_t Val : V.second)
OS << format("0x%x ", Val);
}
OS << '\n';
}
void DWARFGdbIndex::dump(raw_ostream &OS) {
if (HasError) {
OS << "\n<error parsing>\n";
return;
}
if (HasContent) {
OS << " Version = " << Version << '\n';
dumpCUList(OS);
dumpAddressArea(OS);
dumpSymbolTable(OS);
dumpConstantPool(OS);
}
}
bool DWARFGdbIndex::parseImpl(DataExtractor Data) {
uint32_t Offset = 0;
// Only version 7 is supported at this moment.
Version = Data.getU32(&Offset);
if (Version != 7)
return false;
CuListOffset = Data.getU32(&Offset);
uint32_t CuTypesOffset = Data.getU32(&Offset);
AddressAreaOffset = Data.getU32(&Offset);
SymbolTableOffset = Data.getU32(&Offset);
ConstantPoolOffset = Data.getU32(&Offset);
if (Offset != CuListOffset)
return false;
uint32_t CuListSize = (CuTypesOffset - CuListOffset) / 16;
CuList.reserve(CuListSize);
for (uint32_t i = 0; i < CuListSize; ++i) {
uint64_t CuOffset = Data.getU64(&Offset);
uint64_t CuLength = Data.getU64(&Offset);
CuList.push_back({CuOffset, CuLength});
}
// 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 AddressAreaSize = (SymbolTableOffset - AddressAreaOffset) / 20;
AddressArea.reserve(AddressAreaSize);
for (uint32_t i = 0; i < AddressAreaSize; ++i) {
uint64_t LowAddress = Data.getU64(&Offset);
uint64_t HighAddress = Data.getU64(&Offset);
uint32_t CuIndex = Data.getU32(&Offset);
AddressArea.push_back({LowAddress, HighAddress, CuIndex});
}
// The symbol table. This is an open addressed hash table. The size of the
// hash table is always a power of 2.
// Each slot in the hash table consists of a pair of offset_type values. The
// first value is the offset of the symbol's name in the constant pool. The
// second value is the offset of the CU vector in the constant pool.
// If both values are 0, then this slot in the hash table is empty. This is ok
// because while 0 is a valid constant pool index, it cannot be a valid index
// for both a string and a CU vector.
uint32_t SymTableSize = (ConstantPoolOffset - SymbolTableOffset) / 8;
SymbolTable.reserve(SymTableSize);
uint32_t CuVectorsTotal = 0;
for (uint32_t i = 0; i < SymTableSize; ++i) {
uint32_t NameOffset = Data.getU32(&Offset);
uint32_t CuVecOffset = Data.getU32(&Offset);
SymbolTable.push_back({NameOffset, CuVecOffset});
if (NameOffset || CuVecOffset)
++CuVectorsTotal;
}
// The constant pool. CU vectors are stored first, followed by strings.
// The first value is the number of CU indices in the vector. Each subsequent
// value is the index and symbol attributes of a CU in the CU list.
for (uint32_t i = 0; i < CuVectorsTotal; ++i) {
ConstantPoolVectors.emplace_back(0, SmallVector<uint32_t, 0>());
auto &Vec = ConstantPoolVectors.back();
Vec.first = Offset - ConstantPoolOffset;
uint32_t Num = Data.getU32(&Offset);
for (uint32_t j = 0; j < Num; ++j)
Vec.second.push_back(Data.getU32(&Offset));
}
ConstantPoolStrings = Data.getData().drop_front(Offset);
StringPoolOffset = Offset;
return true;
}
void DWARFGdbIndex::parse(DataExtractor Data) {
HasContent = !Data.getData().empty();
HasError = HasContent && !parseImpl(Data);
}

View File

@ -1,35 +0,0 @@
RUN: llvm-dwarfdump -debug-dump=gdb_index %p/Inputs/dwarfdump-gdbindex-v7.elf-x86-64 | FileCheck %s
; test.cpp:
; int main() { return 0; }
; test2.cpp:
; int main2() { return 0; }
; Compiled with:
; gcc -gsplit-dwarf -c test.cpp test2.cpp
; gold --gdb-index test.o test2.o -o dwarfdump-gdbindex-v7.elf-x86-64
; gcc version 5.3.1 20160413, GNU gold (GNU Binutils for Ubuntu 2.26) 1.11
; Info about gdb-index: https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
; CHECK-LABEL: .gnu_index contents:
; CHECK: Version = 7
; CHECK: CU list offset = 0x18, has 2 entries:
; CHECK-NEXT: 0: Offset = 0x0, Length = 0x34
; CHECK-NEXT: 1: Offset = 0x34, Length = 0x34
; CHECK: Address area offset = 0x38, has 2 entries:
; CHECK-NEXT: Low address = 0x4000e8, High address = 0x4000f3, CU index = 0
; CHECK-NEXT: Low address = 0x4000f3, High address = 0x4000fe, CU index = 1
; CHECK: Symbol table offset = 0x60, size = 1024, filled slots:
; CHECK-NEXT: 489: Name offset = 0x1d, CU vector offset = 0x0
; CHECK-NEXT: String name: main, CU vector index: 0
; CHECK-NEXT: 754: Name offset = 0x22, CU vector offset = 0x8
; CHECK-NEXT: String name: int, CU vector index: 1
; CHECK-NEXT: 956: Name offset = 0x26, CU vector offset = 0x14
; CHECK-NEXT: String name: main2, CU vector index: 2
; CHECK: Constant pool offset = 0x2060, has 3 CU vectors:
; CHECK-NEXT: 0(0x0): 0x30000000
; CHECK-NEXT: 1(0x8): 0x90000000 0x90000001
; CHECK-NEXT: 2(0x14): 0x30000001

View File

@ -71,7 +71,6 @@ static cl::opt<DIDumpType> DumpType(
clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo",
".debug_str_offsets.dwo"),
clEnumValN(DIDT_CUIndex, "cu_index", ".debug_cu_index"),
clEnumValN(DIDT_GdbIndex, "gdb_index", ".gdb_index"),
clEnumValN(DIDT_TUIndex, "tu_index", ".debug_tu_index"), clEnumValEnd));
static void error(StringRef Filename, std::error_code EC) {