@@ -60,6 +60,20 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
60
60
" , filled slots:" ,
61
61
SymbolTableOffset, (uint64_t )SymbolTable.size ())
62
62
<< ' \n ' ;
63
+
64
+ const auto FindCuVectorId = [&](uint32_t VecOffset) {
65
+ // Entries in ConstantPoolVectors are sorted by their offset in constant
66
+ // pool, see how ConstantPoolVectors is populated in parseImpl.
67
+ const auto *It =
68
+ llvm::lower_bound (ConstantPoolVectors, VecOffset,
69
+ [](const auto &ConstantPoolEntry, uint32_t Offset) {
70
+ return ConstantPoolEntry.first < Offset;
71
+ });
72
+ assert (It != ConstantPoolVectors.end () && It->first == VecOffset &&
73
+ " Invalid symbol table" );
74
+ return It - ConstantPoolVectors.begin ();
75
+ };
76
+
63
77
uint32_t I = -1 ;
64
78
for (const SymTableEntry &E : SymbolTable) {
65
79
++I;
@@ -72,13 +86,7 @@ void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {
72
86
StringRef Name = ConstantPoolStrings.substr (
73
87
ConstantPoolOffset - StringPoolOffset + E.NameOffset );
74
88
75
- auto CuVector = llvm::find_if (
76
- ConstantPoolVectors,
77
- [&](const std::pair<uint32_t , SmallVector<uint32_t , 0 >> &V) {
78
- return V.first == E.VecOffset ;
79
- });
80
- assert (CuVector != ConstantPoolVectors.end () && " Invalid symbol table" );
81
- uint32_t CuVectorId = CuVector - ConstantPoolVectors.begin ();
89
+ const uint32_t CuVectorId = FindCuVectorId (E.VecOffset );
82
90
OS << format (" String name: %s, CU vector index: %d\n " , Name.data (),
83
91
CuVectorId);
84
92
}
0 commit comments