| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
| 8 #if defined(TARGET_ARCH_ARM64) | 8 #if defined(TARGET_ARCH_ARM64) |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 int* out_instr_size, uword pc) { | 1428 int* out_instr_size, uword pc) { |
| 1429 ARM64Decoder decoder(human_buffer, human_size); | 1429 ARM64Decoder decoder(human_buffer, human_size); |
| 1430 decoder.InstructionDecode(pc); | 1430 decoder.InstructionDecode(pc); |
| 1431 int32_t instruction_bits = Instr::At(pc)->InstructionBits(); | 1431 int32_t instruction_bits = Instr::At(pc)->InstructionBits(); |
| 1432 OS::SNPrint(hex_buffer, hex_size, "%08x", instruction_bits); | 1432 OS::SNPrint(hex_buffer, hex_size, "%08x", instruction_bits); |
| 1433 if (out_instr_size) { | 1433 if (out_instr_size) { |
| 1434 *out_instr_size = Instr::kInstrSize; | 1434 *out_instr_size = Instr::kInstrSize; |
| 1435 } | 1435 } |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 | |
| 1439 void Disassembler::Disassemble(uword start, | |
| 1440 uword end, | |
| 1441 DisassemblyFormatter* formatter, | |
| 1442 const Code::Comments& comments) { | |
| 1443 ASSERT(formatter != NULL); | |
| 1444 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | |
| 1445 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | |
| 1446 uword pc = start; | |
| 1447 intptr_t comment_finger = 0; | |
| 1448 while (pc < end) { | |
| 1449 const intptr_t offset = pc - start; | |
| 1450 while (comment_finger < comments.Length() && | |
| 1451 comments.PCOffsetAt(comment_finger) <= offset) { | |
| 1452 formatter->Print( | |
| 1453 " ;; %s\n", | |
| 1454 String::Handle(comments.CommentAt(comment_finger)).ToCString()); | |
| 1455 comment_finger++; | |
| 1456 } | |
| 1457 int instruction_length; | |
| 1458 DecodeInstruction(hex_buffer, sizeof(hex_buffer), | |
| 1459 human_buffer, sizeof(human_buffer), | |
| 1460 &instruction_length, pc); | |
| 1461 | |
| 1462 formatter->ConsumeInstruction(hex_buffer, | |
| 1463 sizeof(hex_buffer), | |
| 1464 human_buffer, | |
| 1465 sizeof(human_buffer), | |
| 1466 pc); | |
| 1467 pc += instruction_length; | |
| 1468 } | |
| 1469 } | |
| 1470 | |
| 1471 } // namespace dart | 1438 } // namespace dart |
| 1472 | 1439 |
| 1473 #endif // defined TARGET_ARCH_ARM | 1440 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |