[lld] r290042 - [ELF] - Use DWARFDebugPubTable parser class intead of hand-written parsing.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 17 02:18:05 PST 2016
Author: grimar
Date: Sat Dec 17 04:18:05 2016
New Revision: 290042
URL: http://llvm.org/viewvc/llvm-project?rev=290042&view=rev
Log:
[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.
Modified:
lld/trunk/ELF/GdbIndex.cpp
Modified: lld/trunk/ELF/GdbIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/GdbIndex.cpp?rev=290042&r1=290041&r2=290042&view=diff
==============================================================================
--- lld/trunk/ELF/GdbIndex.cpp (original)
+++ lld/trunk/ELF/GdbIndex.cpp Sat Dec 17 04:18:05 2016
@@ -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<ELFT>::readPubNamesAndTy
std::vector<std::pair<StringRef, uint8_t>> 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;
}
More information about the llvm-commits
mailing list