<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 18, 2017, at 11:40 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Sep 14, 2017 at 10:03 AM Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br class="">
Date: Thu Sep 14 10:01:53 2017<br class="">
New Revision: 313272<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=313272&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=313272&view=rev</a><br class="">
Log:<br class="">
llvm-dwarfdump: support dumping static archives.<br class="">
<br class="">
Added:<br class="">
llvm/trunk/test/tools/llvm-dwarfdump/X86/archive.test<br class="">
Modified:<br class="">
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br class="">
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp<br class="">
<br class="">
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=313272&r1=313271&r2=313272&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=313272&r1=313271&r2=313272&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)<br class="">
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Thu Sep 14 10:01:53 2017<br class="">
@@ -230,9 +230,6 @@ void DWARFContext::dump(raw_ostream &OS,<br class="">
<br class="">
// Print UUID header.<br class="">
const auto *ObjFile = DObj->getFile();<br class="">
- if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All)<br class="">
- outs() << ObjFile->getFileName() << ":\tfile format "<br class="">
- << ObjFile->getFileFormatName() << "\n\n";<br class="">
if (DumpType & DIDT_UUID)<br class="">
dumpUUID(OS, *ObjFile);<br class="">
<br class="">
<br class="">
Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/archive.test<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/archive.test?rev=313272&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/archive.test?rev=313272&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/archive.test (added)<br class="">
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/archive.test Thu Sep 14 10:01:53 2017<br class="">
@@ -0,0 +1,5 @@<br class="">
+RUN: llvm-dwarfdump --debug-info %S/../../dsymutil/Inputs/libfat-test.a | FileCheck %s<br class="">
+CHECK: libfat-test.a(x86_64)(fat-test.o): file format Mach-O 64-bit x86-64<br class="">
+CHECK: .debug_info contents:<br class="">
+CHECK: libfat-test.a(i386)(fat-test.o): file format Mach-O 32-bit i386<br class="">
+CHECK: .debug_info contents:<br class="">
<br class="">
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=313272&r1=313271&r2=313272&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=313272&r1=313271&r2=313272&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)<br class="">
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu Sep 14 10:01:53 2017<br class="">
@@ -15,6 +15,7 @@<br class="">
#include "llvm/ADT/Triple.h"<br class="">
#include "llvm/DebugInfo/DIContext.h"<br class="">
#include "llvm/DebugInfo/DWARF/DWARFContext.h"<br class="">
+#include "llvm/Object/Archive.h"<br class="">
#include "llvm/Object/MachOUniversal.h"<br class="">
#include "llvm/Object/ObjectFile.h"<br class="">
#include "llvm/Object/RelocVisitor.h"<br class="">
@@ -123,22 +124,51 @@ static bool verifyObjectFile(ObjectFile<br class="">
}<br class="">
<br class="">
static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,<br class="">
+ std::function<bool(ObjectFile &, Twine)> HandleObj);<br class="">
+<br class="">
+static bool handleArchive(StringRef Filename, Archive &Arch,<br class="">
+ std::function<bool(ObjectFile &, Twine)> HandleObj) {<br class="">
+ bool Result = true;<br class="">
+ Error Err = Error::success();<br class="">
+ for (auto Child : Arch.children(Err)) {<br class="">
+ auto BuffOrErr = Child.getMemoryBufferRef();<br class="">
+ error(Filename, errorToErrorCode(BuffOrErr.takeError()));<br class="">
+ auto NameOrErr = Child.getName();<br class="">
+ error(Filename, errorToErrorCode(NameOrErr.takeError()));<br class="">
+ std::string Name = (Filename + "(" + NameOrErr.get() + ")").str();<br class="">
+ Result &= handleBuffer(Name, BuffOrErr.get(), HandleObj);<br class="">
+ }<br class="">
+ error(Filename, errorToErrorCode(std::move(Err)));<br class="">
+<br class="">
+ return Result;<br class="">
+}<br class="">
+<br class="">
+static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,<br class="">
std::function<bool(ObjectFile &, Twine)> HandleObj) {<br class="">
Expected<std::unique_ptr<Binary>> BinOrErr = object::createBinary(Buffer);<br class="">
- if (!BinOrErr)<br class="">
- error(Filename, errorToErrorCode(BinOrErr.takeError()));<br class="">
+ error(Filename, errorToErrorCode(BinOrErr.takeError()));<br class="">
<br class="">
bool Result = true;<br class="">
if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get()))<br class="">
Result = HandleObj(*Obj, Filename);<br class="">
else if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get()))<br class="">
for (auto &ObjForArch : Fat->objects()) {<br class="">
- auto MachOOrErr = ObjForArch.getAsObjectFile();<br class="">
- error(Filename, errorToErrorCode(MachOOrErr.takeError()));<br class="">
- if (!HandleObj(**MachOOrErr,<br class="">
- Filename + " (" + ObjForArch.getArchFlagName() + ")"))<br class="">
- Result = false;<br class="">
+ std::string ObjName =<br class="">
+ (Filename + "(" + ObjForArch.getArchFlagName() + ")").str();<br class="">
+ if (auto MachOOrErr = ObjForArch.getAsObjectFile()) {<br class="">
+ Result &= HandleObj(**MachOOrErr, ObjName);<br class="">
+ continue;<br class="">
+ } else<br class=""></blockquote><div class=""><br class="">Drop the else after continue<br class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ consumeError(MachOOrErr.takeError());<br class="">
+ if (auto ArchiveOrErr = ObjForArch.getAsArchive()) {<br class="">
+ error(ObjName, errorToErrorCode(ArchiveOrErr.takeError()));<br class="">
+ Result &= handleArchive(ObjName, *ArchiveOrErr.get(), HandleObj);<br class="">
+ continue;<br class="">
+ } else<br class=""></blockquote><div class=""><br class="">Similarly here ^<br class=""></div></div></div></div></blockquote><div><br class=""></div>Will do!</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ consumeError(ArchiveOrErr.takeError());<br class=""></blockquote><div class=""> </div><div class="">Do you really want to be silently ignoring all these errors? Oh, I guess so, due to the fallback style handling here ("try to treat this as X, if that doesn't work try Y, etc").<br class=""></div></div></div></div></blockquote><div><br class=""></div><div>That's right, they are not really errors, we are just trying to parse the contents until we find the right format.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br class="">
+ else if (auto *Arch = dyn_cast<Archive>(BinOrErr->get()))<br class="">
+ Result = handleArchive(Filename, *Arch, HandleObj);<br class="">
return Result;<br class="">
}<br class="">
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div></div>
</div></blockquote></div><br class=""></body></html>