diff options
Diffstat (limited to 'ELF/GdbIndex.h')
-rw-r--r-- | ELF/GdbIndex.h | 51 |
1 files changed, 5 insertions, 46 deletions
diff --git a/ELF/GdbIndex.h b/ELF/GdbIndex.h index c761ea173a8d..a36b92714def 100644 --- a/ELF/GdbIndex.h +++ b/ELF/GdbIndex.h @@ -17,48 +17,16 @@ namespace lld { namespace elf { -template <class ELFT> class InputSection; +class InputSection; // Struct represents single entry of address area of gdb index. -template <class ELFT> struct AddressEntry { - InputSectionBase<ELFT> *Section; +struct AddressEntry { + InputSectionBase *Section; uint64_t LowAddress; uint64_t HighAddress; size_t CuIndex; }; -// GdbIndexBuilder is a helper class used for extracting data required -// for building .gdb_index section from objects. -template <class ELFT> class GdbIndexBuilder : public llvm::LoadedObjectInfo { - typedef typename ELFT::uint uintX_t; - - InputSection<ELFT> *DebugInfoSec; - - std::unique_ptr<llvm::DWARFContext> Dwarf; - -public: - GdbIndexBuilder(InputSection<ELFT> *DebugInfoSec); - - // Extracts the compilation units. Each first element of pair is a offset of a - // CU in the .debug_info section and second is the length of that CU. - std::vector<std::pair<uintX_t, uintX_t>> readCUList(); - - // Extracts the vector of address area entries. Accepts global index of last - // parsed CU. - std::vector<AddressEntry<ELFT>> readAddressArea(size_t CurrentCU); - - // Method extracts public names and types. It returns list of name and - // gnu_pub* kind pairs. - std::vector<std::pair<StringRef, uint8_t>> readPubNamesAndTypes(); - -private: - // Method returns section file offset as a load addres for DWARF parser. That - // allows to find the target section index for address ranges. - uint64_t - getSectionLoadAddress(const llvm::object::SectionRef &Sec) const override; - std::unique_ptr<llvm::LoadedObjectInfo> clone() const override; -}; - // Element of GdbHashTab hash table. struct GdbSymbol { GdbSymbol(uint32_t Hash, size_t Offset) @@ -75,22 +43,13 @@ class GdbHashTab final { public: std::pair<bool, GdbSymbol *> add(uint32_t Hash, size_t Offset); + void finalizeContents(); size_t getCapacity() { return Table.size(); } GdbSymbol *getSymbol(size_t I) { return Table[I]; } private: - void expand(); - - GdbSymbol **findSlot(uint32_t Hash, size_t Offset); - - llvm::BumpPtrAllocator Alloc; + llvm::DenseMap<size_t, GdbSymbol *> Map; std::vector<GdbSymbol *> Table; - - // Size keeps the amount of filled entries in Table. - size_t Size = 0; - - // Initial size must be a power of 2. - static const int32_t InitialSize = 1024; }; } // namespace elf |