| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
| 6 | 6 |
| 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 8 #if defined(TARGET_ARCH_MIPS) | 8 #if defined(TARGET_ARCH_MIPS) |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 int* out_instr_len, uword pc) { | 754 int* out_instr_len, uword pc) { |
| 755 MIPSDecoder decoder(human_buffer, human_size); | 755 MIPSDecoder decoder(human_buffer, human_size); |
| 756 Instr* instr = Instr::At(pc); | 756 Instr* instr = Instr::At(pc); |
| 757 decoder.InstructionDecode(instr); | 757 decoder.InstructionDecode(instr); |
| 758 OS::SNPrint(hex_buffer, hex_size, "%08x", instr->InstructionBits()); | 758 OS::SNPrint(hex_buffer, hex_size, "%08x", instr->InstructionBits()); |
| 759 if (out_instr_len) { | 759 if (out_instr_len) { |
| 760 *out_instr_len = Instr::kInstrSize; | 760 *out_instr_len = Instr::kInstrSize; |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 | 763 |
| 764 | |
| 765 void Disassembler::Disassemble(uword start, | |
| 766 uword end, | |
| 767 DisassemblyFormatter* formatter, | |
| 768 const Code::Comments& comments) { | |
| 769 ASSERT(formatter != NULL); | |
| 770 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | |
| 771 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | |
| 772 uword pc = start; | |
| 773 intptr_t comment_finger = 0; | |
| 774 while (pc < end) { | |
| 775 const intptr_t offset = pc - start; | |
| 776 while (comment_finger < comments.Length() && | |
| 777 comments.PCOffsetAt(comment_finger) <= offset) { | |
| 778 formatter->Print( | |
| 779 " ;; %s\n", | |
| 780 String::Handle(comments.CommentAt(comment_finger)).ToCString()); | |
| 781 comment_finger++; | |
| 782 } | |
| 783 int instruction_length; | |
| 784 DecodeInstruction(hex_buffer, sizeof(hex_buffer), | |
| 785 human_buffer, sizeof(human_buffer), | |
| 786 &instruction_length, pc); | |
| 787 | |
| 788 formatter->ConsumeInstruction(hex_buffer, | |
| 789 sizeof(hex_buffer), | |
| 790 human_buffer, | |
| 791 sizeof(human_buffer), | |
| 792 pc); | |
| 793 pc += instruction_length; | |
| 794 } | |
| 795 | |
| 796 return; | |
| 797 } | |
| 798 | |
| 799 } // namespace dart | 764 } // namespace dart |
| 800 | 765 |
| 801 #endif // defined TARGET_ARCH_MIPS | 766 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |