| 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_ARM. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 8 #if defined(TARGET_ARCH_ARM) | 8 #if defined(TARGET_ARCH_ARM) |
| 9 | 9 |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 int* out_instr_size, uword pc) { | 1525 int* out_instr_size, uword pc) { |
| 1526 ARMDecoder decoder(human_buffer, human_size); | 1526 ARMDecoder decoder(human_buffer, human_size); |
| 1527 decoder.InstructionDecode(pc); | 1527 decoder.InstructionDecode(pc); |
| 1528 int32_t instruction_bits = Instr::At(pc)->InstructionBits(); | 1528 int32_t instruction_bits = Instr::At(pc)->InstructionBits(); |
| 1529 OS::SNPrint(hex_buffer, hex_size, "%08x", instruction_bits); | 1529 OS::SNPrint(hex_buffer, hex_size, "%08x", instruction_bits); |
| 1530 if (out_instr_size) { | 1530 if (out_instr_size) { |
| 1531 *out_instr_size = Instr::kInstrSize; | 1531 *out_instr_size = Instr::kInstrSize; |
| 1532 } | 1532 } |
| 1533 } | 1533 } |
| 1534 | 1534 |
| 1535 | |
| 1536 void Disassembler::Disassemble(uword start, | |
| 1537 uword end, | |
| 1538 DisassemblyFormatter* formatter, | |
| 1539 const Code::Comments& comments) { | |
| 1540 ASSERT(formatter != NULL); | |
| 1541 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | |
| 1542 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | |
| 1543 uword pc = start; | |
| 1544 intptr_t comment_finger = 0; | |
| 1545 while (pc < end) { | |
| 1546 const intptr_t offset = pc - start; | |
| 1547 while (comment_finger < comments.Length() && | |
| 1548 comments.PCOffsetAt(comment_finger) <= offset) { | |
| 1549 formatter->Print( | |
| 1550 " ;; %s\n", | |
| 1551 String::Handle(comments.CommentAt(comment_finger)).ToCString()); | |
| 1552 comment_finger++; | |
| 1553 } | |
| 1554 int instruction_length; | |
| 1555 DecodeInstruction(hex_buffer, sizeof(hex_buffer), | |
| 1556 human_buffer, sizeof(human_buffer), | |
| 1557 &instruction_length, pc); | |
| 1558 | |
| 1559 formatter->ConsumeInstruction(hex_buffer, | |
| 1560 sizeof(hex_buffer), | |
| 1561 human_buffer, | |
| 1562 sizeof(human_buffer), | |
| 1563 pc); | |
| 1564 pc += instruction_length; | |
| 1565 } | |
| 1566 } | |
| 1567 | |
| 1568 } // namespace dart | 1535 } // namespace dart |
| 1569 | 1536 |
| 1570 #endif // defined TARGET_ARCH_ARM | 1537 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |