From 4c0423bc8fd8e1c98a56de9c644300d1e30c9a70 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 8 Aug 2011 18:41:34 +0000 Subject: [PATCH] llvm-objdump: disassembly enhancements - Indent simple loops - Print unreachable blocks as .byte directives llvm-svn: 137058 --- llvm/tools/llvm-objdump/llvm-objdump.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 7a5c9110fe41..2458af478fd9 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -284,8 +284,23 @@ static void DisassembleInput(const StringRef &Filename) { break; } - if (!hasPreds && fi != f.begin()) + // Data block. + if (!hasPreds && fi != f.begin()) { + uint64_t End = llvm::next(fi) == fe ? SectSize : + llvm::next(fi)->first; + uint64_t addr; + if (error(i->getAddress(addr))) break; + outs() << "# " << End-fi->first << " bytes of data:\n"; + for (unsigned pos = fi->first; pos != End; ++pos) { + outs() << format("%8x:\t", addr + pos); + DumpBytes(StringRef(Bytes.data() + pos, 1)); + outs() << format("\t.byte 0x%02x\n", (uint8_t)Bytes[pos]); + } continue; + } + + if (fi->second.contains(&fi->second)) + outs() << "# Loop begin:\n"; for (unsigned ii = 0, ie = fi->second.getInsts().size(); ii != ie; ++ii) { @@ -294,6 +309,9 @@ static void DisassembleInput(const StringRef &Filename) { const MCDecodedInst &Inst = fi->second.getInsts()[ii]; outs() << format("%8x:\t", addr + Inst.Address); DumpBytes(StringRef(Bytes.data() + Inst.Address, Inst.Size)); + // Simple loops. + if (fi->second.contains(&fi->second)) + outs() << '\t'; IP->printInst(&Inst.Inst, outs()); outs() << '\n'; }