summaryrefslogtreecommitdiff
path: root/tools/llvm-symbolizer
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-06-07 15:25:27 +0000
committerAlexey Samsonov <samsonov@google.com>2013-06-07 15:25:27 +0000
commitb6564648a5d1601bef26a1eb3c9ef04ee1d1745f (patch)
treee29d977460f25e95da157bf3572d4d370cf732a0 /tools/llvm-symbolizer
parenta77376dae1e26572f94aa52b63f89749b785bc33 (diff)
downloadllvm-b6564648a5d1601bef26a1eb3c9ef04ee1d1745f.tar.gz
llvm-b6564648a5d1601bef26a1eb3c9ef04ee1d1745f.tar.bz2
llvm-b6564648a5d1601bef26a1eb3c9ef04ee1d1745f.tar.xz
[llvm-symbolizer] rewrite r183213 in a more clear way
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-symbolizer')
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.cpp13
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp
index fcbc84e0c0..7fccedf1c4 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.cpp
+++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp
@@ -64,7 +64,8 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx)
SymbolAddress == UnknownAddressOrSize)
continue;
uint64_t SymbolSize;
- // Getting symbol size is linear for Mach-O files, so avoid it.
+ // Getting symbol size is linear for Mach-O files, so assume that symbol
+ // occupies the memory range up to the following symbol.
if (isa<MachOObjectFile>(Obj))
SymbolSize = 0;
else if (error(si->getSize(SymbolSize)) ||
@@ -76,7 +77,7 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx)
// FIXME: If a function has alias, there are two entries in symbol table
// with same address size. Make sure we choose the correct one.
SymbolMapTy &M = SymbolType == SymbolRef::ST_Function ? Functions : Objects;
- SymbolDesc SD = { SymbolAddress, SymbolAddress + SymbolSize };
+ SymbolDesc SD = { SymbolAddress, SymbolSize };
M.insert(std::make_pair(SD, SymbolName));
}
}
@@ -89,14 +90,14 @@ bool ModuleInfo::getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address,
return false;
SymbolDesc SD = { Address, Address };
SymbolMapTy::const_iterator it = M.upper_bound(SD);
+ if (it == M.begin())
+ return false;
--it;
- // Assume that symbols with zero size are large enough.
- if (it->first.Addr < it->first.AddrEnd &&
- it->first.AddrEnd <= Address)
+ if (it->first.Size != 0 && it->first.Addr + it->first.Size <= Address)
return false;
Name = it->second.str();
Addr = it->first.Addr;
- Size = it->first.AddrEnd - it->first.Addr;
+ Size = it->first.Size;
return true;
}
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.h b/tools/llvm-symbolizer/LLVMSymbolize.h
index e35bdf916f..188331bfa6 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.h
+++ b/tools/llvm-symbolizer/LLVMSymbolize.h
@@ -82,7 +82,9 @@ private:
struct SymbolDesc {
uint64_t Addr;
- uint64_t AddrEnd;
+ // If size is 0, assume that symbol occupies the whole memory range up to
+ // the following symbol.
+ uint64_t Size;
friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
return s1.Addr < s2.Addr;
}