| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IA32. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 8 #if defined(TARGET_ARCH_IA32) | 8 #if defined(TARGET_ARCH_IA32) |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 } | 1575 } |
| 1576 hex_buffer[hex_index] = '\0'; | 1576 hex_buffer[hex_index] = '\0'; |
| 1577 return instruction_length; | 1577 return instruction_length; |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 | 1580 |
| 1581 void Disassembler::Disassemble(uword start, | 1581 void Disassembler::Disassemble(uword start, |
| 1582 uword end, | 1582 uword end, |
| 1583 DisassemblyFormatter* formatter, | 1583 DisassemblyFormatter* formatter, |
| 1584 const Code::Comments& comments) { | 1584 const Code::Comments& comments) { |
| 1585 // TODO(vegorov): Decode and display comments. | |
| 1586 ASSERT(formatter != NULL); | 1585 ASSERT(formatter != NULL); |
| 1587 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | 1586 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. |
| 1588 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | 1587 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. |
| 1589 uword pc = start; | 1588 uword pc = start; |
| 1589 intptr_t comment_finger = 0; |
| 1590 while (pc < end) { | 1590 while (pc < end) { |
| 1591 const intptr_t offset = pc - start; |
| 1592 while (comment_finger < comments.Length() && |
| 1593 comments.PCOffsetAt(comment_finger) <= offset) { |
| 1594 formatter->Print(" ;; %s\n", |
| 1595 comments.CommentAt(comment_finger).ToCString()); |
| 1596 comment_finger++; |
| 1597 } |
| 1591 int instruction_length = DecodeInstruction(hex_buffer, | 1598 int instruction_length = DecodeInstruction(hex_buffer, |
| 1592 sizeof(hex_buffer), | 1599 sizeof(hex_buffer), |
| 1593 human_buffer, | 1600 human_buffer, |
| 1594 sizeof(human_buffer), | 1601 sizeof(human_buffer), |
| 1595 pc); | 1602 pc); |
| 1596 formatter->ConsumeInstruction(hex_buffer, | 1603 formatter->ConsumeInstruction(hex_buffer, |
| 1597 sizeof(hex_buffer), | 1604 sizeof(hex_buffer), |
| 1598 human_buffer, | 1605 human_buffer, |
| 1599 sizeof(human_buffer), | 1606 sizeof(human_buffer), |
| 1600 pc); | 1607 pc); |
| 1601 pc += instruction_length; | 1608 pc += instruction_length; |
| 1602 } | 1609 } |
| 1603 } | 1610 } |
| 1604 | 1611 |
| 1605 } // namespace dart | 1612 } // namespace dart |
| 1606 | 1613 |
| 1607 #endif // defined TARGET_ARCH_IA32 | 1614 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |