[llvm] r183213 - [llvm-symbolizer] Avoid calling slow getSymbolSize for Mach-O files. Assume that symbols with zero size are in fact large enough.
Alexey Samsonov
vonosmas at gmail.com
Wed Jun 24 14:01:16 PDT 2015
On Wed, Jun 24, 2015 at 1:29 PM, Rafael EspĂndola <
rafael.espindola at gmail.com> wrote:
> Would it make sense to use object::computeSymbolSizes now?
>
Definitely. llvm-symbolizer has an interesting special case for ELF,
though: if regular symbol table is missing,
we iterate over dynamic symbol table, and call getSymbolSize() for each
symbol from there. Do you think we
should add smth. like computeDynamicSymbolSizes?
>
> On 4 June 2013 at 03:57, Alexey Samsonov <samsonov at google.com> wrote:
> > Author: samsonov
> > Date: Tue Jun 4 02:57:38 2013
> > New Revision: 183213
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=183213&view=rev
> > Log:
> > [llvm-symbolizer] Avoid calling slow getSymbolSize for Mach-O files.
> Assume that symbols with zero size are in fact large enough.
> >
> > Modified:
> > llvm/trunk/test/DebugInfo/llvm-symbolizer.test
> > llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
> > llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
> >
> > Modified: llvm/trunk/test/DebugInfo/llvm-symbolizer.test
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=183213&r1=183212&r2=183213&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/test/DebugInfo/llvm-symbolizer.test (original)
> > +++ llvm/trunk/test/DebugInfo/llvm-symbolizer.test Tue Jun 4 02:57:38
> 2013
> > @@ -1,4 +1,5 @@
> > RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64 0x400559" > %t.input
> > +RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64 0x400436" >> %t.input
> > RUN: echo "%p/Inputs/dwarfdump-test4.elf-x86-64 0x62c" >> %t.input
> > RUN: echo "%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x710" >> %t.input
> > RUN: echo "\"%p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x633" >>
> %t.input
> > @@ -10,8 +11,12 @@ REQUIRES: shell
> >
> > CHECK: main
> > CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test.cc:16
> > +
> > +CHECK: _start
> > +
> > CHECK: _Z1cv
> > CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test4-part1.cc:2
> > +
> > CHECK: inlined_h
> > CHECK-NEXT: dwarfdump-inl-test.h:2
> > CHECK-NEXT: inlined_g
> >
> > Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=183213&r1=183212&r2=183213&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
> > +++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Tue Jun 4
> 02:57:38 2013
> > @@ -15,6 +15,7 @@
> > #include "llvm/ADT/STLExtras.h"
> > #include "llvm/Object/MachO.h"
> > #include "llvm/Support/Casting.h"
> > +#include "llvm/Support/FileSystem.h"
> > #include "llvm/Support/Path.h"
> >
> > #include <sstream>
> > @@ -63,7 +64,11 @@ ModuleInfo::ModuleInfo(ObjectFile *Obj,
> > SymbolAddress == UnknownAddressOrSize)
> > continue;
> > uint64_t SymbolSize;
> > - if (error(si->getSize(SymbolSize)) || SymbolSize ==
> UnknownAddressOrSize)
> > + // Getting symbol size is linear for Mach-O files, so avoid it.
> > + if (isa<MachOObjectFile>(Obj))
> > + SymbolSize = 0;
> > + else if (error(si->getSize(SymbolSize)) ||
> > + SymbolSize == UnknownAddressOrSize)
> > continue;
> > StringRef SymbolName;
> > if (error(si->getName(SymbolName)))
> > @@ -80,11 +85,14 @@ bool ModuleInfo::getNameFromSymbolTable(
> > std::string &Name, uint64_t
> &Addr,
> > uint64_t &Size) const {
> > const SymbolMapTy &M = Type == SymbolRef::ST_Function ? Functions :
> Objects;
> > - SymbolDesc SD = { Address, Address + 1 };
> > - SymbolMapTy::const_iterator it = M.find(SD);
> > - if (it == M.end())
> > + if (M.empty())
> > return false;
> > - if (Address < it->first.Addr || Address >= it->first.AddrEnd)
> > + SymbolDesc SD = { Address, Address };
> > + SymbolMapTy::const_iterator it = M.upper_bound(SD);
> > + --it;
> > + // Assume that symbols with zero size are large enough.
> > + if (it->first.Addr < it->first.AddrEnd &&
> > + it->first.AddrEnd <= Address)
> > return false;
> > Name = it->second.str();
> > Addr = it->first.Addr;
> > @@ -236,9 +244,12 @@ LLVMSymbolizer::getOrCreateModuleInfo(co
> > if (isa<MachOObjectFile>(Obj)) {
> > const std::string &ResourceName =
> > getDarwinDWARFResourceForModule(ModuleName);
> > - ObjectFile *ResourceObj = getObjectFile(ResourceName);
> > - if (ResourceObj != 0)
> > - DbgObj = ResourceObj;
> > + bool ResourceFileExists = false;
> > + if (!sys::fs::exists(ResourceName, ResourceFileExists) &&
> > + ResourceFileExists) {
> > + if (ObjectFile *ResourceObj = getObjectFile(ResourceName))
> > + DbgObj = ResourceObj;
> > + }
> > }
> > Context = DIContext::getDWARFContext(DbgObj);
> > assert(Context);
> >
> > Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=183213&r1=183212&r2=183213&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h (original)
> > +++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h Tue Jun 4 02:57:38
> 2013
> > @@ -84,7 +84,7 @@ private:
> > uint64_t Addr;
> > uint64_t AddrEnd;
> > friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
> > - return s1.AddrEnd <= s2.Addr;
> > + return s1.Addr < s2.Addr;
> > }
> > };
> > typedef std::map<SymbolDesc, StringRef> SymbolMapTy;
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150624/b3e66b82/attachment.html>
More information about the llvm-commits
mailing list