Skip to content

Commit

Permalink
[Symbolize] Keep SymbolDescs with the same address and improve getNam…
Browse files Browse the repository at this point in the history
…eFromSymbolTable heuristic

I'll follow up with better heuristics or tests.

llvm-svn: 357683
  • Loading branch information
MaskRay committed Apr 4, 2019
1 parent 094c726 commit e2622b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ bool SymbolizableObjectFile::getNameFromSymbolTable(SymbolRef::Type Type,
const auto &SymbolMap = Type == SymbolRef::ST_Function ? Functions : Objects;
if (SymbolMap.empty())
return false;
SymbolDesc SD = { Address, Address };
SymbolDesc SD = {Address, UINT64_C(-1)};
// SymbolDescs are sorted by (Addr,Size), if several SymbolDescs share the
// same Addr, pick the one with the largest Size. This helps us avoid symbols
// with no size information (Size=0).
auto SymbolIterator = SymbolMap.upper_bound(SD);
if (SymbolIterator == SymbolMap.begin())
return false;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class SymbolizableObjectFile : public SymbolizableModule {
// the following symbol.
uint64_t Size;

friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
return s1.Addr < s2.Addr;
bool operator<(const SymbolDesc &RHS) const {
return Addr != RHS.Addr ? Addr < RHS.Addr : Size < RHS.Size;
}
};
std::map<SymbolDesc, StringRef> Functions;
Expand Down

0 comments on commit e2622b3

Please sign in to comment.