| 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 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 OS::SNPrint(&hex_buffer[hex_index], remaining_size, "%02x", pc_ptr[i]); | 1838 OS::SNPrint(&hex_buffer[hex_index], remaining_size, "%02x", pc_ptr[i]); |
| 1839 hex_index += 2; | 1839 hex_index += 2; |
| 1840 remaining_size -= 2; | 1840 remaining_size -= 2; |
| 1841 } | 1841 } |
| 1842 hex_buffer[hex_index] = '\0'; | 1842 hex_buffer[hex_index] = '\0'; |
| 1843 if (out_instr_len) { | 1843 if (out_instr_len) { |
| 1844 *out_instr_len = instruction_length; | 1844 *out_instr_len = instruction_length; |
| 1845 } | 1845 } |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 | |
| 1849 void Disassembler::Disassemble(uword start, | |
| 1850 uword end, | |
| 1851 DisassemblyFormatter* formatter, | |
| 1852 const Code::Comments& comments) { | |
| 1853 ASSERT(formatter != NULL); | |
| 1854 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | |
| 1855 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | |
| 1856 uword pc = start; | |
| 1857 intptr_t comment_finger = 0; | |
| 1858 while (pc < end) { | |
| 1859 const intptr_t offset = pc - start; | |
| 1860 while (comment_finger < comments.Length() && | |
| 1861 comments.PCOffsetAt(comment_finger) <= offset) { | |
| 1862 formatter->Print( | |
| 1863 " ;; %s\n", | |
| 1864 String::Handle(comments.CommentAt(comment_finger)).ToCString()); | |
| 1865 comment_finger++; | |
| 1866 } | |
| 1867 int instruction_length; | |
| 1868 DecodeInstruction(hex_buffer, | |
| 1869 sizeof(hex_buffer), | |
| 1870 human_buffer, | |
| 1871 sizeof(human_buffer), | |
| 1872 &instruction_length, pc); | |
| 1873 formatter->ConsumeInstruction(hex_buffer, | |
| 1874 sizeof(hex_buffer), | |
| 1875 human_buffer, | |
| 1876 sizeof(human_buffer), | |
| 1877 pc); | |
| 1878 pc += instruction_length; | |
| 1879 } | |
| 1880 | |
| 1881 return; | |
| 1882 } | |
| 1883 | |
| 1884 } // namespace dart | 1848 } // namespace dart |
| 1885 | 1849 |
| 1886 #endif // defined TARGET_ARCH_IA32 | 1850 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |