<div dir="ltr"><div>Alexander, </div>Have you seen the asan bootstrap failure? <div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/4853/steps/check-llvm%20asan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/4853/steps/check-llvm%20asan/logs/stdio</a><br></div><div><br></div><div><pre style="font-family:'Courier New',courier,monotype,monospace;color:rgb(0,0,0);font-size:medium"><span class="">==13115==ERROR: AddressSanitizer: stack-use-after-return on address 0x7fb5eea00ba8 at pc 0x0000004700f0 bp 0x7fff07b1f0d0 sp 0x7fff07b1e890
READ of size 16 at 0x7fb5eea00ba8 thread T0
#0 0x4700ef in memcmp /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:334
#1 0x4c5736 in darwinDsymMatchesBinary /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp:310:11
#2 0x4c5736 in llvm::symbolize::LLVMSymbolizer::lookUpDsymFile(std::string const&, llvm::object::MachOObjectFile const*, std::string const&) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp:333
#3 0x4c9af3 in llvm::symbolize::LLVMSymbolizer::getOrCreateObjects(std::string const&, std::string const&) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp:361:16
#4 0x4c18af in llvm::symbolize::LLVMSymbolizer::getOrCreateModuleInfo(std::string const&) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp:425:24
#5 0x4bfe4e in llvm::symbolize::LLVMSymbolizer::symbolizeCode(std::string const&,</span><span class=""> unsigned long) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp:173:22
</span><span class=""> #6 0x4d7682 in main /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp:144:18
#7 0x7fb5f1ac7ec4 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#8 0x4207e7 in _start (/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm_build_asan/bin/llvm-symbolizer+0x4207e7)
Address 0x7fb5eea00ba8 is located in stack of thread T0 at offset 40 in frame
#0 0x53700f in llvm::object::MachOObjectFile::getUuid() const /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/Object/MachOObjectFile.cpp:2424
This frame has 1 object(s):
[32, 56) 'Uuid' <== Memory access at offset 40 is inside this variable</span></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 16, 2014 at 5:50 PM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com" target="_blank">glider@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: glider<br>
Date: Thu Oct 16 19:50:19 2014<br>
New Revision: 220004<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220004&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=220004&view=rev</a><br>
Log:<br>
[llvm-symbolizer] Introduce the -dsym-hint option.<br>
<br>
llvm-symbolizer will consult one of the .dSYM paths passed via -dsym-hint<br>
if it fails to find the .dSYM bundle at the default location.<br>
<br>
Added:<br>
llvm/trunk/test/tools/llvm-symbolizer/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Info.plist (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/DWARF/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/DWARF/dsym-test-exe-second (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-second (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Info.plist (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/DWARF/<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/DWARF/dsym-test-exe (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c (with props)<br>
llvm/trunk/test/tools/llvm-symbolizer/dsym.test<br>
Modified:<br>
llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst<br>
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp<br>
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h<br>
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp<br>
<br>
Modified: llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst?rev=220004&r1=220003&r2=220004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst?rev=220004&r1=220003&r2=220004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst (original)<br>
+++ llvm/trunk/docs/CommandGuide/llvm-symbolizer.rst Thu Oct 16 19:50:19 2014<br>
@@ -92,6 +92,13 @@ OPTIONS<br>
input (see example above). If architecture is not specified in either way,<br>
address will not be symbolized. Defaults to empty string.<br>
<br>
+.. option:: -dsym-hint=<path/to/file.dSYM><br>
+<br>
+ (Darwin-only flag). If the debug info for a binary isn't present in the default<br>
+ location, look for the debug info at the .dSYM path provided via the<br>
+ ``-dsym-hint`` flag. This flag can be used multiple times.<br>
+<br>
+<br>
EXIT STATUS<br>
-----------<br>
<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe?rev=220004&view=auto</a><br>
==============================================================================<br>
Binary file - no diff available.<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe<br>
------------------------------------------------------------------------------<br>
svn:executable = *<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe<br>
------------------------------------------------------------------------------<br>
svn:mime-type = application/octet-stream<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Info.plist<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Info.plist?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Info.plist?rev=220004&view=auto</a><br>
==============================================================================<br>
Binary file - no diff available.<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Info.plist<br>
------------------------------------------------------------------------------<br>
svn:mime-type = application/xml<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/DWARF/dsym-test-exe-second<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/DWARF/dsym-test-exe-second?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/DWARF/dsym-test-exe-second?rev=220004&view=auto</a><br>
==============================================================================<br>
Binary file - no diff available.<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-differentname.dSYM/Contents/Resources/DWARF/dsym-test-exe-second<br>
------------------------------------------------------------------------------<br>
svn:mime-type = application/octet-stream<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-second<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-second?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-second?rev=220004&view=auto</a><br>
==============================================================================<br>
Binary file - no diff available.<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-second<br>
------------------------------------------------------------------------------<br>
svn:executable = *<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe-second<br>
------------------------------------------------------------------------------<br>
svn:mime-type = application/octet-stream<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Info.plist<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Info.plist?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Info.plist?rev=220004&view=auto</a><br>
==============================================================================<br>
Binary file - no diff available.<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Info.plist<br>
------------------------------------------------------------------------------<br>
svn:mime-type = application/xml<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/DWARF/dsym-test-exe<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/DWARF/dsym-test-exe?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/DWARF/dsym-test-exe?rev=220004&view=auto</a><br>
==============================================================================<br>
Binary file - no diff available.<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test-exe.dSYM/Contents/Resources/DWARF/dsym-test-exe<br>
------------------------------------------------------------------------------<br>
svn:mime-type = application/octet-stream<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c?rev=220004&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c (added)<br>
+++ llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c Thu Oct 16 19:50:19 2014<br>
@@ -0,0 +1,8 @@<br>
+// clang -c dsym-test.c -g<br>
+// clang dsym-test.o -g -o dsym-test-exe<br>
+// dsymutil dsym-test-exe<br>
+// clang dsym-test.o -g -o dsym-test-exe-second<br>
+// dsymutil dsym-test-exe-second -o dsym-test-exe-differentname.dSYM<br>
+int main() {<br>
+ return 0;<br>
+}<br>
<br>
Propchange: llvm/trunk/test/tools/llvm-symbolizer/Inputs/dsym-test.c<br>
------------------------------------------------------------------------------<br>
svn:eol-style = LF<br>
<br>
Added: llvm/trunk/test/tools/llvm-symbolizer/dsym.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/dsym.test?rev=220004&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/dsym.test?rev=220004&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-symbolizer/dsym.test (added)<br>
+++ llvm/trunk/test/tools/llvm-symbolizer/dsym.test Thu Oct 16 19:50:19 2014<br>
@@ -0,0 +1,14 @@<br>
+RUN: echo "%p/Inputs/dsym-test-exe 0x0000000100000f90" > %t.input<br>
+RUN: echo "%p/Inputs/dsym-test-exe-second 0x0000000100000f90" >> %t.input<br>
+RUN: llvm-symbolizer < %t.input | FileCheck %s --check-prefix=CHECK-NOHINT<br>
+RUN: llvm-symbolizer -dsym-hint=%p/Inputs/dsym-test-exe-differentname.dSYM < %t.input | FileCheck %s --check-prefix=CHECK-HINT<br>
+<br>
+CHECK-NOHINT: main<br>
+CHECK-NOHINT: dsym-test.c<br>
+CHECK-NOHINT: main<br>
+CHECK-NOHINT: ??:0:0<br>
+<br>
+CHECK-HINT: main<br>
+CHECK-HINT: dsym-test.c<br>
+CHECK-HINT: main<br>
+CHECK-HINT: dsym-test.c<br>
<br>
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=220004&r1=220003&r2=220004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=220004&r1=220003&r2=220004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)<br>
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Thu Oct 16 19:50:19 2014<br>
@@ -207,14 +207,21 @@ std::string LLVMSymbolizer::symbolizeDat<br>
<br>
void LLVMSymbolizer::flush() {<br>
DeleteContainerSeconds(Modules);<br>
- BinaryForPath.clear();<br>
+ ObjectPairForPathArch.clear();<br>
ObjectFileForArch.clear();<br>
}<br>
<br>
-static std::string getDarwinDWARFResourceForPath(const std::string &Path) {<br>
- StringRef Basename = sys::path::filename(Path);<br>
- const std::string &DSymDirectory = Path + ".dSYM";<br>
- SmallString<16> ResourceName = StringRef(DSymDirectory);<br>
+// For Path="/path/to/foo" and Basename="foo" assume that debug info is in<br>
+// /path/to/foo.dSYM/Contents/Resources/DWARF/foo.<br>
+// For Path="/path/to/bar.dSYM" and Basename="foo" assume that debug info is in<br>
+// /path/to/bar.dSYM/Contents/Resources/DWARF/foo.<br>
+static<br>
+std::string getDarwinDWARFResourceForPath(<br>
+ const std::string &Path, const std::string &Basename) {<br>
+ SmallString<16> ResourceName = StringRef(Path);<br>
+ if (sys::path::extension(Path) != ".dSYM") {<br>
+ ResourceName += ".dSYM";<br>
+ }<br>
sys::path::append(ResourceName, "Contents", "Resources", "DWARF");<br>
sys::path::append(ResourceName, Basename);<br>
return ResourceName.str();<br>
@@ -265,9 +272,8 @@ static bool findDebugBinary(const std::s<br>
return false;<br>
}<br>
<br>
-static bool getGNUDebuglinkContents(const Binary *Bin, std::string &DebugName,<br>
+static bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,<br>
uint32_t &CRCHash) {<br>
- const ObjectFile *Obj = dyn_cast<ObjectFile>(Bin);<br>
if (!Obj)<br>
return false;<br>
for (const SectionRef &Section : Obj->sections()) {<br>
@@ -294,57 +300,91 @@ static bool getGNUDebuglinkContents(cons<br>
return false;<br>
}<br>
<br>
-LLVMSymbolizer::BinaryPair<br>
-LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {<br>
- const auto &I = BinaryForPath.find(Path);<br>
- if (I != BinaryForPath.end())<br>
+static<br>
+bool darwinDsymMatchesBinary(const MachOObjectFile *DbgObj,<br>
+ const MachOObjectFile *Obj) {<br>
+ ArrayRef<uint8_t> dbg_uuid = DbgObj->getUuid();<br>
+ ArrayRef<uint8_t> bin_uuid = Obj->getUuid();<br>
+ if (dbg_uuid.empty() || bin_uuid.empty())<br>
+ return false;<br>
+ return !memcmp(dbg_uuid.data(), bin_uuid.data(), dbg_uuid.size());<br>
+}<br>
+<br>
+ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,<br>
+ const MachOObjectFile *MachExeObj, const std::string &ArchName) {<br>
+ // On Darwin we may find DWARF in separate object file in<br>
+ // resource directory.<br>
+ std::vector<std::string> DsymPaths;<br>
+ StringRef Filename = sys::path::filename(ExePath);<br>
+ DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename));<br>
+ for (const auto &Path : Opts.DsymHints) {<br>
+ DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename));<br>
+ }<br>
+ for (const auto &path : DsymPaths) {<br>
+ ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(path);<br>
+ std::error_code EC = BinaryOrErr.getError();<br>
+ if (EC != errc::no_such_file_or_directory && !error(EC)) {<br>
+ OwningBinary<Binary> B = std::move(BinaryOrErr.get());<br>
+ ObjectFile *DbgObj =<br>
+ getObjectFileFromBinary(B.getBinary().get(), ArchName);<br>
+ const MachOObjectFile *MachDbgObj =<br>
+ dyn_cast<const MachOObjectFile>(DbgObj);<br>
+ if (!MachDbgObj) continue;<br>
+ if (darwinDsymMatchesBinary(MachDbgObj, MachExeObj)) {<br>
+ addOwningBinary(std::move(B));<br>
+ return DbgObj;<br>
+ }<br>
+ }<br>
+ }<br>
+ return nullptr;<br>
+}<br>
+<br>
+LLVMSymbolizer::ObjectPair<br>
+LLVMSymbolizer::getOrCreateObjects(const std::string &Path,<br>
+ const std::string &ArchName) {<br>
+ const auto &I = ObjectPairForPathArch.find(std::make_pair(Path, ArchName));<br>
+ if (I != ObjectPairForPathArch.end())<br>
return I->second;<br>
- Binary *Bin = nullptr;<br>
- Binary *DbgBin = nullptr;<br>
+ ObjectFile *Obj = nullptr;<br>
+ ObjectFile *DbgObj = nullptr;<br>
ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(Path);<br>
if (!error(BinaryOrErr.getError())) {<br>
- OwningBinary<Binary> &ParsedBinary = BinaryOrErr.get();<br>
- // Check if it's a universal binary.<br>
- Bin = ParsedBinary.getBinary().get();<br>
- addOwningBinary(std::move(ParsedBinary));<br>
- if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {<br>
- // On Darwin we may find DWARF in separate object file in<br>
- // resource directory.<br>
- const std::string &ResourcePath =<br>
- getDarwinDWARFResourceForPath(Path);<br>
- BinaryOrErr = createBinary(ResourcePath);<br>
- std::error_code EC = BinaryOrErr.getError();<br>
- if (EC != errc::no_such_file_or_directory && !error(EC)) {<br>
- OwningBinary<Binary> B = std::move(BinaryOrErr.get());<br>
- DbgBin = B.getBinary().get();<br>
- addOwningBinary(std::move(B));<br>
- }<br>
+ OwningBinary<Binary> &B = BinaryOrErr.get();<br>
+ Obj = getObjectFileFromBinary(B.getBinary().get(), ArchName);<br>
+ if (!Obj) {<br>
+ ObjectPair Res = std::make_pair(nullptr, nullptr);<br>
+ ObjectPairForPathArch[std::make_pair(Path, ArchName)] = Res;<br>
+ return Res;<br>
}<br>
+ addOwningBinary(std::move(B));<br>
+ if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj))<br>
+ DbgObj = lookUpDsymFile(Path, MachObj, ArchName);<br>
// Try to locate the debug binary using .gnu_debuglink section.<br>
- if (!DbgBin) {<br>
+ if (!DbgObj) {<br>
std::string DebuglinkName;<br>
uint32_t CRCHash;<br>
std::string DebugBinaryPath;<br>
- if (getGNUDebuglinkContents(Bin, DebuglinkName, CRCHash) &&<br>
+ if (getGNUDebuglinkContents(Obj, DebuglinkName, CRCHash) &&<br>
findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath)) {<br>
BinaryOrErr = createBinary(DebugBinaryPath);<br>
if (!error(BinaryOrErr.getError())) {<br>
OwningBinary<Binary> B = std::move(BinaryOrErr.get());<br>
- DbgBin = B.getBinary().get();<br>
+ DbgObj = getObjectFileFromBinary(B.getBinary().get(), ArchName);<br>
addOwningBinary(std::move(B));<br>
}<br>
}<br>
}<br>
}<br>
- if (!DbgBin)<br>
- DbgBin = Bin;<br>
- BinaryPair Res = std::make_pair(Bin, DbgBin);<br>
- BinaryForPath[Path] = Res;<br>
+ if (!DbgObj)<br>
+ DbgObj = Obj;<br>
+ ObjectPair Res = std::make_pair(Obj, DbgObj);<br>
+ ObjectPairForPathArch[std::make_pair(Path, ArchName)] = Res;<br>
return Res;<br>
}<br>
<br>
ObjectFile *<br>
-LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName) {<br>
+LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin,<br>
+ const std::string &ArchName) {<br>
if (!Bin)<br>
return nullptr;<br>
ObjectFile *Res = nullptr;<br>
@@ -382,18 +422,16 @@ LLVMSymbolizer::getOrCreateModuleInfo(co<br>
ArchName = ArchStr;<br>
}<br>
}<br>
- BinaryPair Binaries = getOrCreateBinary(BinaryName);<br>
- ObjectFile *Obj = getObjectFileFromBinary(Binaries.first, ArchName);<br>
- ObjectFile *DbgObj = getObjectFileFromBinary(Binaries.second, ArchName);<br>
+ ObjectPair Objects = getOrCreateObjects(BinaryName, ArchName);<br>
<br>
- if (!Obj) {<br>
+ if (!Objects.first) {<br>
// Failed to find valid object file.<br>
Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr));<br>
return nullptr;<br>
}<br>
- DIContext *Context = DIContext::getDWARFContext(*DbgObj);<br>
+ DIContext *Context = DIContext::getDWARFContext(*Objects.second);<br>
assert(Context);<br>
- ModuleInfo *Info = new ModuleInfo(Obj, Context);<br>
+ ModuleInfo *Info = new ModuleInfo(Objects.first, Context);<br>
Modules.insert(make_pair(ModuleName, Info));<br>
return Info;<br>
}<br>
<br>
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=220004&r1=220003&r2=220004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=220004&r1=220003&r2=220004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h (original)<br>
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h Thu Oct 16 19:50:19 2014<br>
@@ -39,13 +39,14 @@ public:<br>
bool PrintInlining : 1;<br>
bool Demangle : 1;<br>
std::string DefaultArch;<br>
+ std::vector<std::string> DsymHints;<br>
Options(bool UseSymbolTable = true,<br>
FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName,<br>
bool PrintInlining = true, bool Demangle = true,<br>
std::string DefaultArch = "")<br>
- : UseSymbolTable(UseSymbolTable), PrintFunctions(PrintFunctions),<br>
- PrintInlining(PrintInlining), Demangle(Demangle),<br>
- DefaultArch(DefaultArch) {}<br>
+ : UseSymbolTable(UseSymbolTable),<br>
+ PrintFunctions(PrintFunctions), PrintInlining(PrintInlining),<br>
+ Demangle(Demangle), DefaultArch(DefaultArch) {}<br>
};<br>
<br>
LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}<br>
@@ -62,11 +63,15 @@ public:<br>
void flush();<br>
static std::string DemangleName(const std::string &Name);<br>
private:<br>
- typedef std::pair<Binary*, Binary*> BinaryPair;<br>
+ typedef std::pair<ObjectFile*, ObjectFile*> ObjectPair;<br>
<br>
ModuleInfo *getOrCreateModuleInfo(const std::string &ModuleName);<br>
- /// \brief Returns pair of pointers to binary and debug binary.<br>
- BinaryPair getOrCreateBinary(const std::string &Path);<br>
+ ObjectFile *lookUpDsymFile(const std::string &Path, const MachOObjectFile *ExeObj,<br>
+ const std::string &ArchName);<br>
+<br>
+ /// \brief Returns pair of pointers to object and debug object.<br>
+ ObjectPair getOrCreateObjects(const std::string &Path,<br>
+ const std::string &ArchName);<br>
/// \brief Returns a parsed object file for a given architecture in a<br>
/// universal binary (or the binary itself if it is an object file).<br>
ObjectFile *getObjectFileFromBinary(Binary *Bin, const std::string &ArchName);<br>
@@ -83,9 +88,10 @@ private:<br>
<br>
// Owns module info objects.<br>
std::map<std::string, ModuleInfo *> Modules;<br>
- std::map<std::string, BinaryPair> BinaryForPath;<br>
std::map<std::pair<MachOUniversalBinary *, std::string>, ObjectFile *><br>
ObjectFileForArch;<br>
+ std::map<std::pair<std::string, std::string>, ObjectPair><br>
+ ObjectPairForPathArch;<br>
<br>
Options Opts;<br>
static const char kBadString[];<br>
<br>
Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=220004&r1=220003&r2=220004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=220004&r1=220003&r2=220004&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)<br>
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Thu Oct 16 19:50:19 2014<br>
@@ -19,6 +19,7 @@<br>
#include "llvm/ADT/StringRef.h"<br>
#include "llvm/Support/CommandLine.h"<br>
#include "llvm/Support/Debug.h"<br>
+#include "llvm/Support/FileSystem.h"<br>
#include "llvm/Support/ManagedStatic.h"<br>
#include "llvm/Support/PrettyStackTrace.h"<br>
#include "llvm/Support/Signals.h"<br>
@@ -61,6 +62,11 @@ ClBinaryName("obj", cl::init(""),<br>
cl::desc("Path to object file to be symbolized (if not provided, "<br>
"object file should be specified for each input line)"));<br>
<br>
+static cl::list<std::string><br>
+ClDsymHint("dsym-hint", cl::ZeroOrMore,<br>
+ cl::desc("Path to .dSYM bundles to search for debug info for the "<br>
+ "object files"));<br>
+<br>
static bool parseCommand(bool &IsData, std::string &ModuleName,<br>
uint64_t &ModuleOffset) {<br>
const char *kDataCmd = "DATA ";<br>
@@ -119,6 +125,14 @@ int main(int argc, char **argv) {<br>
cl::ParseCommandLineOptions(argc, argv, "llvm-symbolizer\n");<br>
LLVMSymbolizer::Options Opts(ClUseSymbolTable, ClPrintFunctions,<br>
ClPrintInlining, ClDemangle, ClDefaultArch);<br>
+ for (const auto &hint : ClDsymHint) {<br>
+ if (sys::path::extension(hint) == ".dSYM") {<br>
+ Opts.DsymHints.push_back(hint);<br>
+ } else {<br>
+ errs() << "Warning: invalid dSYM hint: \"" << hint <<<br>
+ "\" (must have the '.dSYM' extension).\n";<br>
+ }<br>
+ }<br>
LLVMSymbolizer Symbolizer(Opts);<br>
<br>
bool IsData = false;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>