Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: runtime/vm/disassembler_ia32.cc

Issue 8758005: Disassembler for x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/disassembler.h" 8 #include "vm/disassembler.h"
9 9
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 return instruction_length; 1518 return instruction_length;
1519 } 1519 }
1520 1520
1521 1521
1522 const char* Disassembler::RegisterName(Register reg) { 1522 const char* Disassembler::RegisterName(Register reg) {
1523 ASSERT(0 <= reg); 1523 ASSERT(0 <= reg);
1524 ASSERT(reg < kMaxCPURegisters); 1524 ASSERT(reg < kMaxCPURegisters);
1525 return (cpu_regs[reg]); 1525 return (cpu_regs[reg]);
1526 } 1526 }
1527 1527
1528
1529 void Disassembler::Disassemble(uword start,
1530 uword end,
1531 DisassemblyFormatter* formatter) {
1532 ASSERT(formatter != NULL);
1533 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form.
1534 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction.
1535 uword pc = start;
1536 while (pc < end) {
1537 int instruction_length = DecodeInstruction(hex_buffer,
1538 sizeof(hex_buffer),
1539 human_buffer,
1540 sizeof(human_buffer),
1541 pc);
1542 formatter->ConsumeInstruction(hex_buffer,
1543 sizeof(hex_buffer),
1544 human_buffer,
1545 sizeof(human_buffer),
1546 pc);
1547 pc += instruction_length;
1548 }
1549 }
1550
1551
1552 void Disassembler::DisassembleMemoryRegionRange(
1553 const MemoryRegion& instructions,
1554 uword from,
1555 uword to,
1556 DisassemblyFormatter *formatter) {
1557 ASSERT(formatter != NULL);
1558 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form.
1559 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction.
1560 uword start = instructions.start();
1561 uword end = instructions.end();
1562 ASSERT((from >= start) && (to <= end) && (from <= to));
1563 uword pc = start;
1564 uword stop = Utils::Minimum(end, to);
1565 while (pc < stop) {
1566 int instruction_length = DecodeInstruction(hex_buffer,
1567 sizeof(hex_buffer),
1568 human_buffer,
1569 sizeof(human_buffer),
1570 pc);
1571 if (pc >= from) {
1572 formatter->ConsumeInstruction(hex_buffer,
1573 sizeof(hex_buffer),
1574 human_buffer,
1575 sizeof(human_buffer),
1576 pc);
1577 }
1578 pc += instruction_length;
1579 }
1580 }
1581
1528 } // namespace dart 1582 } // namespace dart
1529 1583
1530 #endif // defined TARGET_ARCH_IA32 1584 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698