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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } else if (format[1] == 'v') { // 'svc | 597 } else if (format[1] == 'v') { // 'svc |
598 DCHECK(STRING_STARTS_WITH(format, "svc")); | 598 DCHECK(STRING_STARTS_WITH(format, "svc")); |
599 PrintSoftwareInterrupt(instr->SvcValue()); | 599 PrintSoftwareInterrupt(instr->SvcValue()); |
600 return 3; | 600 return 3; |
601 } else if (format[1] == 'i') { // 'sign: signed extra loads and stores | 601 } else if (format[1] == 'i') { // 'sign: signed extra loads and stores |
602 DCHECK(STRING_STARTS_WITH(format, "sign")); | 602 DCHECK(STRING_STARTS_WITH(format, "sign")); |
603 if (instr->HasSign()) { | 603 if (instr->HasSign()) { |
604 Print("s"); | 604 Print("s"); |
605 } | 605 } |
606 return 4; | 606 return 4; |
| 607 } else if (format[1] == 'p') { |
| 608 if (format[8] == '_') { // 'spec_reg_fields |
| 609 DCHECK(STRING_STARTS_WITH(format, "spec_reg_fields")); |
| 610 Print("_"); |
| 611 int mask = instr->Bits(19, 16); |
| 612 if (mask == 0) Print("(none)"); |
| 613 if ((mask & 0x8) != 0) Print("f"); |
| 614 if ((mask & 0x4) != 0) Print("s"); |
| 615 if ((mask & 0x2) != 0) Print("x"); |
| 616 if ((mask & 0x1) != 0) Print("c"); |
| 617 return 15; |
| 618 } else { // 'spec_reg |
| 619 DCHECK(STRING_STARTS_WITH(format, "spec_reg")); |
| 620 if (instr->Bit(22) == 0) { |
| 621 Print("CPSR"); |
| 622 } else { |
| 623 Print("SPSR"); |
| 624 } |
| 625 return 8; |
| 626 } |
607 } | 627 } |
608 // 's: S field of data processing instructions | 628 // 's: S field of data processing instructions |
609 if (instr->HasS()) { | 629 if (instr->HasS()) { |
610 Print("s"); | 630 Print("s"); |
611 } | 631 } |
612 return 1; | 632 return 1; |
613 } | 633 } |
614 case 't': { // 'target: target of branch instructions | 634 case 't': { // 'target: target of branch instructions |
615 DCHECK(STRING_STARTS_WITH(format, "target")); | 635 DCHECK(STRING_STARTS_WITH(format, "target")); |
616 int off = (instr->SImmed24Value() << 2) + 8; | 636 int off = (instr->SImmed24Value() << 2) + 8; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 } | 835 } |
816 default: { | 836 default: { |
817 // The PU field is a 2-bit field. | 837 // The PU field is a 2-bit field. |
818 UNREACHABLE(); | 838 UNREACHABLE(); |
819 break; | 839 break; |
820 } | 840 } |
821 } | 841 } |
822 return; | 842 return; |
823 } | 843 } |
824 } else if ((type == 0) && instr->IsMiscType0()) { | 844 } else if ((type == 0) && instr->IsMiscType0()) { |
825 if (instr->Bits(22, 21) == 1) { | 845 if ((instr->Bits(27, 23) == 2) && (instr->Bits(21, 20) == 2) && |
| 846 (instr->Bits(15, 4) == 0xf00)) { |
| 847 Format(instr, "msr'cond 'spec_reg'spec_reg_fields, 'rm"); |
| 848 } else if ((instr->Bits(27, 23) == 2) && (instr->Bits(21, 20) == 0) && |
| 849 (instr->Bits(11, 0) == 0)) { |
| 850 Format(instr, "mrs'cond 'rd, 'spec_reg"); |
| 851 } else if (instr->Bits(22, 21) == 1) { |
826 switch (instr->BitField(7, 4)) { | 852 switch (instr->BitField(7, 4)) { |
827 case BX: | 853 case BX: |
828 Format(instr, "bx'cond 'rm"); | 854 Format(instr, "bx'cond 'rm"); |
829 break; | 855 break; |
830 case BLX: | 856 case BLX: |
831 Format(instr, "blx'cond 'rm"); | 857 Format(instr, "blx'cond 'rm"); |
832 break; | 858 break; |
833 case BKPT: | 859 case BKPT: |
834 Format(instr, "bkpt 'off0to3and8to19"); | 860 Format(instr, "bkpt 'off0to3and8to19"); |
835 break; | 861 break; |
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 v8::internal::PrintF( | 2034 v8::internal::PrintF( |
2009 f, "%p %08x %s\n", | 2035 f, "%p %08x %s\n", |
2010 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 2036 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
2011 } | 2037 } |
2012 } | 2038 } |
2013 | 2039 |
2014 | 2040 |
2015 } // namespace disasm | 2041 } // namespace disasm |
2016 | 2042 |
2017 #endif // V8_TARGET_ARCH_ARM | 2043 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |