OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A Disassembler object is used to disassemble a block of code instruction by | 5 // A Disassembler object is used to disassemble a block of code instruction by |
6 // instruction. The default implementation of the NameConverter object can be | 6 // instruction. The default implementation of the NameConverter object can be |
7 // overriden to modify register names or to do symbol lookup on addresses. | 7 // overriden to modify register names or to do symbol lookup on addresses. |
8 // | 8 // |
9 // The example below will disassemble a block of code and print it to stdout. | 9 // The example below will disassemble a block of code and print it to stdout. |
10 // | 10 // |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + | 368 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + |
369 delta_pc + (imm21 << n_bits))); | 369 delta_pc + (imm21 << n_bits))); |
370 } | 370 } |
371 | 371 |
372 | 372 |
373 // Print 26-bit hex immediate value. | 373 // Print 26-bit hex immediate value. |
374 void Decoder::PrintXImm26(Instruction* instr) { | 374 void Decoder::PrintXImm26(Instruction* instr) { |
375 uint64_t target = static_cast<uint64_t>(instr->Imm26Value()) | 375 uint64_t target = static_cast<uint64_t>(instr->Imm26Value()) |
376 << kImmFieldShift; | 376 << kImmFieldShift; |
377 target = (reinterpret_cast<uint64_t>(instr) & ~0xfffffff) | target; | 377 target = (reinterpret_cast<uint64_t>(instr) & ~0xfffffff) | target; |
378 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%lx", target); | 378 out_buffer_pos_ += |
| 379 SNPrintF(out_buffer_ + out_buffer_pos_, "0x%" PRIx64, target); |
379 } | 380 } |
380 | 381 |
381 | 382 |
382 // Print 26-bit signed immediate value. | 383 // Print 26-bit signed immediate value. |
383 void Decoder::PrintSImm26(Instruction* instr) { | 384 void Decoder::PrintSImm26(Instruction* instr) { |
384 int32_t imm26 = instr->Imm26Value(); | 385 int32_t imm26 = instr->Imm26Value(); |
385 // set sign | 386 // set sign |
386 imm26 <<= (32 - kImm26Bits); | 387 imm26 <<= (32 - kImm26Bits); |
387 imm26 >>= (32 - kImm26Bits); | 388 imm26 >>= (32 - kImm26Bits); |
388 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm26); | 389 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm26); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 void Decoder::Unknown(Instruction* instr) { | 795 void Decoder::Unknown(Instruction* instr) { |
795 Format(instr, "unknown"); | 796 Format(instr, "unknown"); |
796 } | 797 } |
797 | 798 |
798 | 799 |
799 int Decoder::DecodeBreakInstr(Instruction* instr) { | 800 int Decoder::DecodeBreakInstr(Instruction* instr) { |
800 // This is already known to be BREAK instr, just extract the code. | 801 // This is already known to be BREAK instr, just extract the code. |
801 if (instr->Bits(25, 6) == static_cast<int>(kMaxStopCode)) { | 802 if (instr->Bits(25, 6) == static_cast<int>(kMaxStopCode)) { |
802 // This is stop(msg). | 803 // This is stop(msg). |
803 Format(instr, "break, code: 'code"); | 804 Format(instr, "break, code: 'code"); |
804 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, | 805 out_buffer_pos_ += SNPrintF( |
805 "\n%p %08lx stop msg: %s", | 806 out_buffer_ + out_buffer_pos_, |
806 static_cast<void*> | 807 "\n%p %08" PRIx64 " stop msg: %s", |
807 (reinterpret_cast<int32_t*>(instr | 808 static_cast<void*>( |
808 + Instruction::kInstrSize)), | 809 reinterpret_cast<int32_t*>(instr + Instruction::kInstrSize)), |
809 reinterpret_cast<uint64_t> | 810 reinterpret_cast<uint64_t>( |
810 (*reinterpret_cast<char**>(instr | 811 *reinterpret_cast<char**>(instr + Instruction::kInstrSize)), |
811 + Instruction::kInstrSize)), | 812 *reinterpret_cast<char**>(instr + Instruction::kInstrSize)); |
812 *reinterpret_cast<char**>(instr | |
813 + Instruction::kInstrSize)); | |
814 // Size 3: the break_ instr, plus embedded 64-bit char pointer. | 813 // Size 3: the break_ instr, plus embedded 64-bit char pointer. |
815 return 3 * Instruction::kInstrSize; | 814 return 3 * Instruction::kInstrSize; |
816 } else { | 815 } else { |
817 Format(instr, "break, code: 'code"); | 816 Format(instr, "break, code: 'code"); |
818 return Instruction::kInstrSize; | 817 return Instruction::kInstrSize; |
819 } | 818 } |
820 } | 819 } |
821 | 820 |
822 | 821 |
823 bool Decoder::DecodeTypeRegisterRsType(Instruction* instr) { | 822 bool Decoder::DecodeTypeRegisterRsType(Instruction* instr) { |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 2002 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
2004 } | 2003 } |
2005 } | 2004 } |
2006 | 2005 |
2007 | 2006 |
2008 #undef UNSUPPORTED | 2007 #undef UNSUPPORTED |
2009 | 2008 |
2010 } // namespace disasm | 2009 } // namespace disasm |
2011 | 2010 |
2012 #endif // V8_TARGET_ARCH_MIPS64 | 2011 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |