<div dir="ltr">This is so much nicer!<div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 29, 2014 at 5:19 PM, Nick Kledzik <span dir="ltr"><<a href="mailto:kledzik@apple.com" target="_blank">kledzik@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: kledzik<br>
Date: Mon Sep 29 19:19:58 2014<br>
New Revision: 218649<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218649&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218649&view=rev</a><br>
Log:<br>
[llvm-objdump] switch some uses of format() to format_hex() and left_justify()<br>
<br>
Modified:<br>
  Â  llvm/trunk/tools/llvm-objdump/MachODump.cpp<br>
<br>
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=218649&r1=218648&r2=218649&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=218649&r1=218648&r2=218649&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Mon Sep 29 19:19:58 2014<br>
@@ -2829,8 +2829,8 @@ void llvm::printMachOBindTable(const obj<br>
  Â // Build table of sections so names can used in final output.<br>
  Â SegInfo sectionTable(Obj);<br>
<br>
-  outs() << "segment  section  Â  Â  Â  Â  Â  address  Â  Â type  Â  Â "<br>
-  Â  Â  Â  Â  Â  "addend  Â dylib  Â  Â  Â  Â  Â  Â  Â symbol\n";<br>
+  outs() << "segment  section  Â  Â  Â  Â  Â  address  Â  type  Â  Â  Â "<br>
+  Â  Â  Â  Â  Â  "addend dylib  Â  Â  Â  Â  Â  symbol\n";<br>
  Â for (const llvm::object::MachOBindEntry &Entry : Obj->bindTable()) {<br>
  Â  Â uint32_t SegIndex = Entry.segmentIndex();<br>
  Â  Â uint64_t OffsetInSeg = Entry.segmentOffset();<br>
@@ -2840,18 +2840,17 @@ void llvm::printMachOBindTable(const obj<br>
<br>
  Â  Â // Table lines look like:<br>
  Â  Â //  __DATA  __got  0x00012010  Â  pointer  Â 0 libSystem ___stack_chk_guard<br>
-  Â  outs() << format("%-8s %-18s 0x%08" PRIX64 "  %-8s %-8" PRId64 " %-20s",<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â SegmentName.str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â SectionName.str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Address,<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Entry.typeName().str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Entry.addend(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â ordinalName(Obj, Entry.ordinal()).str().c_str())<br>
-  Â  Â  Â  Â  Â << Entry.symbolName();<br>
+  Â  StringRef Attr;<br>
  Â  Â if (Entry.flags() & MachO::BIND_SYMBOL_FLAGS_WEAK_IMPORT)<br>
-  Â  Â  outs() << " (weak_import)\n";<br>
-  Â  else<br>
-  Â  Â  outs() << "\n";<br>
+  Â  Â  Attr = " (weak_import)";<br>
+  Â  outs() << left_justify(SegmentName, 8)  << " "<br>
+  Â  Â  Â  Â  Â << left_justify(SectionName, 18) << " "<br>
+  Â  Â  Â  Â  Â << format_hex(Address, 10, true) << " "<br>
+  Â  Â  Â  Â  Â << left_justify(Entry.typeName(), 8) << " "<br>
+  Â  Â  Â  Â  Â << format_decimal(Entry.addend(), 8)  << " "<br>
+  Â  Â  Â  Â  Â << left_justify(ordinalName(Obj, Entry.ordinal()), 16) << " "<br>
+  Â  Â  Â  Â  Â << Entry.symbolName()<br>
+  Â  Â  Â  Â  Â << Attr << "\n";<br>
  Â }<br>
 }<br>
<br>
@@ -2863,8 +2862,8 @@ void llvm::printMachOLazyBindTable(const<br>
  Â // Build table of sections so names can used in final output.<br>
  Â SegInfo sectionTable(Obj);<br>
<br>
-  outs() << "segment  section  Â  Â  Â  Â  Â  address  Â  Â  "<br>
-  Â  Â  Â  Â  Â  "dylib  Â  Â  Â  Â  Â  Â  Â symbol\n";<br>
+  outs() << "segment  section  Â  Â  Â  Â  Â  address  Â  Â "<br>
+  Â  Â  Â  Â  Â  "dylib  Â  Â  Â  Â  Â  symbol\n";<br>
  Â for (const llvm::object::MachOBindEntry &Entry : Obj->lazyBindTable()) {<br>
  Â  Â uint32_t SegIndex = Entry.segmentIndex();<br>
  Â  Â uint64_t OffsetInSeg = Entry.segmentOffset();<br>
@@ -2874,11 +2873,10 @@ void llvm::printMachOLazyBindTable(const<br>
<br>
  Â  Â // Table lines look like:<br>
  Â  Â //  __DATA  __got  0x00012010 libSystem ___stack_chk_guard<br>
-  Â  outs() << format("%-8s %-18s 0x%08" PRIX64 "  Â %-20s",<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â SegmentName.str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â SectionName.str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Address,<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â ordinalName(Obj, Entry.ordinal()).str().c_str())<br>
+  Â  outs() << left_justify(SegmentName, 8)  << " "<br>
+  Â  Â  Â  Â  Â << left_justify(SectionName, 18) << " "<br>
+  Â  Â  Â  Â  Â << format_hex(Address, 10, true) << " "<br>
+  Â  Â  Â  Â  Â << left_justify(ordinalName(Obj, Entry.ordinal()), 16) << " "<br>
  Â  Â  Â  Â  Â  << Entry.symbolName() << "\n";<br>
  Â }<br>
 }<br>
@@ -2892,12 +2890,12 @@ void llvm::printMachOWeakBindTable(const<br>
  Â // Build table of sections so names can used in final output.<br>
  Â SegInfo sectionTable(Obj);<br>
<br>
-  outs() << "segment  section  Â  Â  Â  Â  Â  address  Â  Â  "<br>
-  Â  Â  Â  Â  Â  "type  Â  Â addend  Â symbol\n";<br>
+  outs() << "segment  section  Â  Â  Â  Â  Â  address  Â  Â "<br>
+  Â  Â  Â  Â  Â  "type  Â  Â  Â addend  Â symbol\n";<br>
  Â for (const llvm::object::MachOBindEntry &Entry : Obj->weakBindTable()) {<br>
  Â  Â // Strong symbols don't have a location to update.<br>
  Â  Â if (Entry.flags() & MachO::BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION) {<br>
-  Â  Â  outs() << "  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  strong  Â  Â  Â  Â  Â  "<br>
+  Â  Â  outs() << "  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  strong  Â  Â  Â  Â  Â  Â  "<br>
  Â  Â  Â  Â  Â  Â  << Entry.symbolName() << "\n";<br>
  Â  Â  Â continue;<br>
  Â  Â }<br>
@@ -2909,12 +2907,11 @@ void llvm::printMachOWeakBindTable(const<br>
<br>
  Â  Â // Table lines look like:<br>
  Â  Â // __DATA  __data  0x00001000  pointer  Â  0  Â _foo<br>
-  Â  outs() << format("%-8s %-18s 0x%08" PRIX64 "  Â %-8s %-8" PRId64 " ",<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â SegmentName.str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â SectionName.str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Address,<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Entry.typeName().str().c_str(),<br>
-  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Entry.addend())<br>
+  Â  outs() << left_justify(SegmentName, 8)  << " "<br>
+  Â  Â  Â  Â  Â << left_justify(SectionName, 18) << " "<br>
+  Â  Â  Â  Â  Â << format_hex(Address, 10, true) << " "<br>
+  Â  Â  Â  Â  Â << left_justify(Entry.typeName(), 8) << " "<br>
+  Â  Â  Â  Â  Â << format_decimal(Entry.addend(), 8)  << "  Â "<br>
  Â  Â  Â  Â  Â  << Entry.symbolName() << "\n";<br>
  Â }<br>
 }<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>