[llvm] r218649 - [llvm-objdump] switch some uses of format() to format_hex() and left_justify()

Sean Silva chisophugis at gmail.com
Mon Sep 29 23:09:45 PDT 2014


This is so much nicer!

-- Sean Silva

On Mon, Sep 29, 2014 at 5:19 PM, Nick Kledzik <kledzik at apple.com> wrote:

> Author: kledzik
> Date: Mon Sep 29 19:19:58 2014
> New Revision: 218649
>
> URL: http://llvm.org/viewvc/llvm-project?rev=218649&view=rev
> Log:
> [llvm-objdump] switch some uses of format() to format_hex() and
> left_justify()
>
> Modified:
>     llvm/trunk/tools/llvm-objdump/MachODump.cpp
>
> Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=218649&r1=218648&r2=218649&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
> +++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Mon Sep 29 19:19:58 2014
> @@ -2829,8 +2829,8 @@ void llvm::printMachOBindTable(const obj
>    // Build table of sections so names can used in final output.
>    SegInfo sectionTable(Obj);
>
> -  outs() << "segment  section            address     type     "
> -            "addend   dylib               symbol\n";
> +  outs() << "segment  section            address    type       "
> +            "addend dylib            symbol\n";
>    for (const llvm::object::MachOBindEntry &Entry : Obj->bindTable()) {
>      uint32_t SegIndex = Entry.segmentIndex();
>      uint64_t OffsetInSeg = Entry.segmentOffset();
> @@ -2840,18 +2840,17 @@ void llvm::printMachOBindTable(const obj
>
>      // Table lines look like:
>      //  __DATA  __got  0x00012010    pointer   0 libSystem
> ___stack_chk_guard
> -    outs() << format("%-8s %-18s 0x%08" PRIX64 "  %-8s %-8" PRId64 "
> %-20s",
> -                     SegmentName.str().c_str(),
> -                     SectionName.str().c_str(),
> -                     Address,
> -                     Entry.typeName().str().c_str(),
> -                     Entry.addend(),
> -                     ordinalName(Obj, Entry.ordinal()).str().c_str())
> -           << Entry.symbolName();
> +    StringRef Attr;
>      if (Entry.flags() & MachO::BIND_SYMBOL_FLAGS_WEAK_IMPORT)
> -      outs() << " (weak_import)\n";
> -    else
> -      outs() << "\n";
> +      Attr = " (weak_import)";
> +    outs() << left_justify(SegmentName, 8)  << " "
> +           << left_justify(SectionName, 18) << " "
> +           << format_hex(Address, 10, true) << " "
> +           << left_justify(Entry.typeName(), 8) << " "
> +           << format_decimal(Entry.addend(), 8)  << " "
> +           << left_justify(ordinalName(Obj, Entry.ordinal()), 16) << " "
> +           << Entry.symbolName()
> +           << Attr << "\n";
>    }
>  }
>
> @@ -2863,8 +2862,8 @@ void llvm::printMachOLazyBindTable(const
>    // Build table of sections so names can used in final output.
>    SegInfo sectionTable(Obj);
>
> -  outs() << "segment  section            address      "
> -            "dylib               symbol\n";
> +  outs() << "segment  section            address     "
> +            "dylib            symbol\n";
>    for (const llvm::object::MachOBindEntry &Entry : Obj->lazyBindTable()) {
>      uint32_t SegIndex = Entry.segmentIndex();
>      uint64_t OffsetInSeg = Entry.segmentOffset();
> @@ -2874,11 +2873,10 @@ void llvm::printMachOLazyBindTable(const
>
>      // Table lines look like:
>      //  __DATA  __got  0x00012010 libSystem ___stack_chk_guard
> -    outs() << format("%-8s %-18s 0x%08" PRIX64 "   %-20s",
> -                     SegmentName.str().c_str(),
> -                     SectionName.str().c_str(),
> -                     Address,
> -                     ordinalName(Obj, Entry.ordinal()).str().c_str())
> +    outs() << left_justify(SegmentName, 8)  << " "
> +           << left_justify(SectionName, 18) << " "
> +           << format_hex(Address, 10, true) << " "
> +           << left_justify(ordinalName(Obj, Entry.ordinal()), 16) << " "
>             << Entry.symbolName() << "\n";
>    }
>  }
> @@ -2892,12 +2890,12 @@ void llvm::printMachOWeakBindTable(const
>    // Build table of sections so names can used in final output.
>    SegInfo sectionTable(Obj);
>
> -  outs() << "segment  section            address      "
> -            "type     addend   symbol\n";
> +  outs() << "segment  section            address     "
> +            "type       addend   symbol\n";
>    for (const llvm::object::MachOBindEntry &Entry : Obj->weakBindTable()) {
>      // Strong symbols don't have a location to update.
>      if (Entry.flags() & MachO::BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION) {
> -      outs() << "                                          strong
>     "
> +      outs() << "                                        strong
>     "
>               << Entry.symbolName() << "\n";
>        continue;
>      }
> @@ -2909,12 +2907,11 @@ void llvm::printMachOWeakBindTable(const
>
>      // Table lines look like:
>      // __DATA  __data  0x00001000  pointer    0   _foo
> -    outs() << format("%-8s %-18s 0x%08" PRIX64 "   %-8s %-8" PRId64 " ",
> -                     SegmentName.str().c_str(),
> -                     SectionName.str().c_str(),
> -                     Address,
> -                     Entry.typeName().str().c_str(),
> -                     Entry.addend())
> +    outs() << left_justify(SegmentName, 8)  << " "
> +           << left_justify(SectionName, 18) << " "
> +           << format_hex(Address, 10, true) << " "
> +           << left_justify(Entry.typeName(), 8) << " "
> +           << format_decimal(Entry.addend(), 8)  << "   "
>             << Entry.symbolName() << "\n";
>    }
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140929/640f4453/attachment.html>


More information about the llvm-commits mailing list