Exemplo n.º 1
0
void CorDisasm::dumpInstruction(const BlockIterator &BIter) const {
  assert(BIter.isDecoded() && "Cannot print before Decode");

  uint64_t InstSize = BIter.InstrSize;
  string buffer;
  raw_string_ostream OS(buffer);

  OS << format("%8llx: ", BIter.Addr);
  dumpBytes(ArrayRef<uint8_t>(BIter.Ptr, InstSize), OS);

  if ((TheTargetArch == Target_X86) || (TheTargetArch == Target_X64)) {
    // For architectures with a variable size instruction, we pad the
    // byte dump with space up to 7 bytes. Some instructions might be longer,
    // but ...

    const char *Padding[] = {"",
                             "   ",
                             "      ",
                             "         ",
                             "            ",
                             "               ",
                             "                  "};
    OS << (Padding[(InstSize < 7) ? (7 - InstSize) : 0]);
  }

  IP->printInst(&BIter.Inst, OS, "", *STI);
  Print->Dump(OS.str().c_str());
}