]> granicus.if.org Git - llvm/commitdiff
[Symbolize] Keep SymbolDescs with the same address and improve getNameFromSymbolTable...
authorFangrui Song <maskray@google.com>
Thu, 4 Apr 2019 11:08:45 +0000 (11:08 +0000)
committerFangrui Song <maskray@google.com>
Thu, 4 Apr 2019 11:08:45 +0000 (11:08 +0000)
I'll follow up with better heuristics or tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357683 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
lib/DebugInfo/Symbolize/SymbolizableObjectFile.h

index fc09be251e1a840e68bef0892e1dd322ca7c312c..889b0c1d8be32172cdc80b227dd4b5d8bfce992d 100644 (file)
@@ -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;
index d5ad8d0d3c4d6001e479e50fb95cafa2320e7594..d811dc2d01e84bd1dcb71a2780647643e10ae989 100644 (file)
@@ -75,8 +75,8 @@ private:
     // 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;