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

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

Issue 12431016: Copies Simulator Debugger from ARM to MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months 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) 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 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 for (int i = 0; (i < instruction_length) && (remaining_size > 2); ++i) { 1757 for (int i = 0; (i < instruction_length) && (remaining_size > 2); ++i) {
1758 OS::SNPrint(&hex_buffer[hex_index], remaining_size, "%02x", pc_ptr[i]); 1758 OS::SNPrint(&hex_buffer[hex_index], remaining_size, "%02x", pc_ptr[i]);
1759 hex_index += 2; 1759 hex_index += 2;
1760 remaining_size -= 2; 1760 remaining_size -= 2;
1761 } 1761 }
1762 hex_buffer[hex_index] = '\0'; 1762 hex_buffer[hex_index] = '\0';
1763 return instruction_length; 1763 return instruction_length;
1764 } 1764 }
1765 1765
1766 1766
1767 void Disassembler::Disassemble(uword start, 1767 bool Disassembler::Disassemble(uword start,
1768 uword end, 1768 uword end,
1769 DisassemblyFormatter* formatter, 1769 DisassemblyFormatter* formatter,
1770 const Code::Comments& comments) { 1770 const Code::Comments& comments) {
1771 ASSERT(formatter != NULL); 1771 ASSERT(formatter != NULL);
1772 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. 1772 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form.
1773 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. 1773 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction.
1774 uword pc = start; 1774 uword pc = start;
1775 intptr_t comment_finger = 0; 1775 intptr_t comment_finger = 0;
1776 while (pc < end) { 1776 while (pc < end) {
1777 const intptr_t offset = pc - start; 1777 const intptr_t offset = pc - start;
1778 while (comment_finger < comments.Length() && 1778 while (comment_finger < comments.Length() &&
1779 comments.PCOffsetAt(comment_finger) <= offset) { 1779 comments.PCOffsetAt(comment_finger) <= offset) {
1780 formatter->Print( 1780 formatter->Print(
1781 " ;; %s\n", 1781 " ;; %s\n",
1782 String::Handle(comments.CommentAt(comment_finger)).ToCString()); 1782 String::Handle(comments.CommentAt(comment_finger)).ToCString());
1783 comment_finger++; 1783 comment_finger++;
1784 } 1784 }
1785 int instruction_length = DecodeInstruction(hex_buffer, 1785 int instruction_length = DecodeInstruction(hex_buffer,
1786 sizeof(hex_buffer), 1786 sizeof(hex_buffer),
1787 human_buffer, 1787 human_buffer,
1788 sizeof(human_buffer), 1788 sizeof(human_buffer),
1789 pc); 1789 pc);
1790 formatter->ConsumeInstruction(hex_buffer, 1790 formatter->ConsumeInstruction(hex_buffer,
1791 sizeof(hex_buffer), 1791 sizeof(hex_buffer),
1792 human_buffer, 1792 human_buffer,
1793 sizeof(human_buffer), 1793 sizeof(human_buffer),
1794 pc); 1794 pc);
1795 pc += instruction_length; 1795 pc += instruction_length;
1796 } 1796 }
1797 // X86Decoder aborts on unknown instruction.
1798 return true;
1797 } 1799 }
1798 1800
1799 } // namespace dart 1801 } // namespace dart
1800 1802
1801 #endif // defined TARGET_ARCH_IA32 1803 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698