From 607fa711b2c9023daea909b539322250a79dec8a Mon Sep 17 00:00:00 2001 From: George Rimar Date: Sat, 17 Dec 2016 10:18:05 +0000 Subject: [PATCH] [ELF] - Use DWARFDebugPubTable parser class intead of hand-written parsing. DWARFDebugPubTable was introduced recently and allows us to get rid of code duplication in LLD. llvm-svn: 290042 --- lld/ELF/GdbIndex.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lld/ELF/GdbIndex.cpp b/lld/ELF/GdbIndex.cpp index d34c4b0..74ebcf9 100644 --- a/lld/ELF/GdbIndex.cpp +++ b/lld/ELF/GdbIndex.cpp @@ -59,7 +59,7 @@ //===----------------------------------------------------------------------===// #include "GdbIndex.h" - +#include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h" #include "llvm/Object/ELFObjectFile.h" using namespace llvm; @@ -95,22 +95,11 @@ GdbIndexBuilder::readPubNamesAndTypes() { std::vector> Ret; for (StringRef D : Data) { - DataExtractor PubNames(D, IsLE, 0); - uint32_t Offset = 0; - while (PubNames.isValidOffset(Offset)) { - // Skip length, version, unit offset and size. - Offset += 14; - while (Offset < D.size()) { - uint32_t DieRef = PubNames.getU32(&Offset); - if (DieRef == 0) - break; - uint8_t Flags = PubNames.getU8(&Offset); - const char *Name = PubNames.getCStr(&Offset); - Ret.push_back({Name, Flags}); - } - } + DWARFDebugPubTable PubTable(D, IsLE, true); + for (const DWARFDebugPubTable::Set &S : PubTable.getData()) + for (const DWARFDebugPubTable::Entry &E : S.Entries) + Ret.push_back({E.Name, E.Descriptor.toBits()}); } - return Ret; } -- 2.7.4