OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 if (instr->Bit(22) == 0) { | 660 if (instr->Bit(22) == 0) { |
661 Print("u"); | 661 Print("u"); |
662 } else { | 662 } else { |
663 Print("s"); | 663 Print("s"); |
664 } | 664 } |
665 return 1; | 665 return 1; |
666 } | 666 } |
667 case 'v': { | 667 case 'v': { |
668 return FormatVFPinstruction(instr, format); | 668 return FormatVFPinstruction(instr, format); |
669 } | 669 } |
| 670 case 'A': { |
| 671 // Print pc-relative address. |
| 672 int offset = instr->Offset12Value(); |
| 673 byte* pc = reinterpret_cast<byte*>(instr) + Instruction::kPCReadOffset; |
| 674 byte* addr; |
| 675 switch (instr->PUField()) { |
| 676 case db_x: { |
| 677 addr = pc - offset; |
| 678 break; |
| 679 } |
| 680 case ib_x: { |
| 681 addr = pc + offset; |
| 682 break; |
| 683 } |
| 684 default: { |
| 685 UNREACHABLE(); |
| 686 return -1; |
| 687 } |
| 688 } |
| 689 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%p", addr); |
| 690 return 1; |
| 691 } |
670 case 'S': | 692 case 'S': |
671 case 'D': { | 693 case 'D': { |
672 return FormatVFPRegister(instr, format); | 694 return FormatVFPRegister(instr, format); |
673 } | 695 } |
674 case 'w': { // 'w: W field of load and store instructions | 696 case 'w': { // 'w: W field of load and store instructions |
675 if (instr->HasW()) { | 697 if (instr->HasW()) { |
676 Print("!"); | 698 Print("!"); |
677 } | 699 } |
678 return 1; | 700 return 1; |
679 } | 701 } |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 } | 1048 } |
1027 case ia_x: { | 1049 case ia_x: { |
1028 if (instr->HasW()) { | 1050 if (instr->HasW()) { |
1029 Unknown(instr); // not used in V8 | 1051 Unknown(instr); // not used in V8 |
1030 return; | 1052 return; |
1031 } | 1053 } |
1032 Format(instr, "'memop'cond'b 'rd, ['rn], #+'off12"); | 1054 Format(instr, "'memop'cond'b 'rd, ['rn], #+'off12"); |
1033 break; | 1055 break; |
1034 } | 1056 } |
1035 case db_x: { | 1057 case db_x: { |
1036 Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w"); | 1058 if (instr->HasL() && (instr->RnValue() == kPCRegister)) { |
| 1059 Format(instr, "'memop'cond'b 'rd, [pc, #-'off12]'w (addr 'A)"); |
| 1060 } else { |
| 1061 Format(instr, "'memop'cond'b 'rd, ['rn, #-'off12]'w"); |
| 1062 } |
1037 break; | 1063 break; |
1038 } | 1064 } |
1039 case ib_x: { | 1065 case ib_x: { |
1040 Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w"); | 1066 if (instr->HasL() && (instr->RnValue() == kPCRegister)) { |
| 1067 Format(instr, "'memop'cond'b 'rd, [pc, #+'off12]'w (addr 'A)"); |
| 1068 } else { |
| 1069 Format(instr, "'memop'cond'b 'rd, ['rn, #+'off12]'w"); |
| 1070 } |
1041 break; | 1071 break; |
1042 } | 1072 } |
1043 default: { | 1073 default: { |
1044 // The PU field is a 2-bit field. | 1074 // The PU field is a 2-bit field. |
1045 UNREACHABLE(); | 1075 UNREACHABLE(); |
1046 break; | 1076 break; |
1047 } | 1077 } |
1048 } | 1078 } |
1049 } | 1079 } |
1050 | 1080 |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 pc += d.InstructionDecode(buffer, pc); | 2684 pc += d.InstructionDecode(buffer, pc); |
2655 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), | 2685 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
2656 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 2686 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
2657 } | 2687 } |
2658 } | 2688 } |
2659 | 2689 |
2660 | 2690 |
2661 } // namespace disasm | 2691 } // namespace disasm |
2662 | 2692 |
2663 #endif // V8_TARGET_ARCH_ARM | 2693 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |