<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 3, 2015 at 2:10 AM, Frederic Riss <span dir="ltr"><<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: friss<br>
Date: Sun Aug 2 19:10:31 2015<br>
New Revision: 243862<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243862-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=1ahNcQkENEwWqTwkKiBabwKoPj-80keeGHW3vyN6zGQ&s=eJ6G35FkOy4IPYXHuW5xsf1La6FBerb9k-RD9GMT5LU&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243862&view=rev</a><br>
Log:<br>
[dwarfdump] Add support for dumping mach-o universal objectfiles<br>
<br>
Added:<br>
llvm/trunk/test/DebugInfo/dwarfdump-macho-universal.test<br>
Modified:<br>
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp<br>
<br>
Added: llvm/trunk/test/DebugInfo/dwarfdump-macho-universal.test<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_DebugInfo_dwarfdump-2Dmacho-2Duniversal.test-3Frev-3D243862-26view-3Dauto&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=1ahNcQkENEwWqTwkKiBabwKoPj-80keeGHW3vyN6zGQ&s=T3O_DYUhEMuKoQo8i30DyCZQV_p64uS2ocbqPWyl-ik&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-macho-universal.test?rev=243862&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/dwarfdump-macho-universal.test (added)<br>
+++ llvm/trunk/test/DebugInfo/dwarfdump-macho-universal.test Sun Aug 2 19:10:31 2015<br>
@@ -0,0 +1,17 @@<br>
+Reuse a test input from llvm-dsymutil, it's perfect for what we want to exercise<br>
+RUN: llvm-dwarfdump %S/../tools/dsymutil/Inputs/fat-test.o -debug-dump=info | FileCheck %s<br></blockquote><div><br></div><div>FYI, using a file from other top-level test/ subdirectory breaks our test setup. I've fixed this in r243872 by copying the file to test/DebugInfo/Inputs/.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+CHECK: fat-test.o (x86_64): file format Mach-O 64-bit x86-64<br>
+CHECK: DW_TAG_variable<br>
+CHECK-NOT: {{NULL|DW_TAG}}<br>
+CHECK: DW_AT_name {{.*}} "x86_64_var"<br>
+<br>
+CHECK: fat-test.o (i386): file format Mach-O 32-bit i386<br>
+CHECK: DW_TAG_variable<br>
+CHECK-NOT: {{NULL|DW_TAG}}<br>
+CHECK: DW_AT_name {{.*}} "i386_var"<br>
+<br>
+CHECK: fat-test.o (x86_64h): file format Mach-O 64-bit x86-64<br>
+CHECK: DW_TAG_variable<br>
+CHECK-NOT: {{NULL|DW_TAG}}<br>
+CHECK: DW_AT_name {{.*}} "x86_64h_var"<br>
<br>
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_llvm-2Ddwarfdump_llvm-2Ddwarfdump.cpp-3Frev-3D243862-26r1-3D243861-26r2-3D243862-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=1ahNcQkENEwWqTwkKiBabwKoPj-80keeGHW3vyN6zGQ&s=PNnu7TwXF13ZiJ_wcNEwJoSXpSaJmryFFmox63L6img&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=243862&r1=243861&r2=243862&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Sun Aug 2 19:10:31 2015<br>
@@ -15,6 +15,7 @@<br>
#include "llvm/ADT/Triple.h"<br>
#include "llvm/DebugInfo/DIContext.h"<br>
#include "llvm/DebugInfo/DWARF/DWARFContext.h"<br>
+#include "llvm/Object/MachOUniversal.h"<br>
#include "llvm/Object/ObjectFile.h"<br>
#include "llvm/Object/RelocVisitor.h"<br>
#include "llvm/Support/CommandLine.h"<br>
@@ -76,11 +77,11 @@ static void error(StringRef Filename, st<br>
exit(1);<br>
}<br>
<br>
-static void DumpObjectFile(ObjectFile &Obj, StringRef Filename) {<br>
+static void DumpObjectFile(ObjectFile &Obj, Twine Filename) {<br>
std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(Obj));<br>
<br>
- outs() << Filename<br>
- << ":\tfile format " << Obj.getFileFormatName() << "\n\n";<br>
+ outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName()<br>
+ << "\n\n";<br>
// Dump the complete DWARF structure.<br>
DICtx->dump(outs(), DumpType);<br>
}<br>
@@ -91,12 +92,19 @@ static void DumpInput(StringRef Filename<br>
error(Filename, BuffOrErr.getError());<br>
std::unique_ptr<MemoryBuffer> Buff = std::move(BuffOrErr.get());<br>
<br>
- ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr =<br>
- ObjectFile::createObjectFile(Buff->getMemBufferRef());<br>
- error(Filename, ObjOrErr.getError());<br>
- ObjectFile &Obj = *ObjOrErr.get();<br>
-<br>
- DumpObjectFile(Obj, Filename);<br>
+ ErrorOr<std::unique_ptr<Binary>> BinOrErr =<br>
+ object::createBinary(Buff->getMemBufferRef());<br>
+ error(Filename, BinOrErr.getError());<br>
+<br>
+ if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get()))<br>
+ DumpObjectFile(*Obj, Filename);<br>
+ else if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get()))<br>
+ for (auto &ObjForArch : Fat->objects()) {<br>
+ auto MachOOrErr = ObjForArch.getAsObjectFile();<br>
+ error(Filename, MachOOrErr.getError());<br>
+ DumpObjectFile(**MachOOrErr,<br>
+ Filename + " (" + ObjForArch.getArchTypeName() + ")");<br>
+ }<br>
}<br>
<br>
int main(int argc, char **argv) {<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" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><div><br></div>
</div></div>