| 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_X64) | 8 #if defined(TARGET_ARCH_X64) |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 OS::SNPrint(&hex_buffer[hex_index], remaining_size, "%02x", pc_ptr[i]); | 1940 OS::SNPrint(&hex_buffer[hex_index], remaining_size, "%02x", pc_ptr[i]); |
| 1941 hex_index += 2; | 1941 hex_index += 2; |
| 1942 remaining_size -= 2; | 1942 remaining_size -= 2; |
| 1943 } | 1943 } |
| 1944 hex_buffer[hex_index] = '\0'; | 1944 hex_buffer[hex_index] = '\0'; |
| 1945 if (out_instr_len) { | 1945 if (out_instr_len) { |
| 1946 *out_instr_len = instruction_length; | 1946 *out_instr_len = instruction_length; |
| 1947 } | 1947 } |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 | |
| 1951 void Disassembler::Disassemble(uword start, | |
| 1952 uword end, | |
| 1953 DisassemblyFormatter* formatter, | |
| 1954 const Code::Comments& comments) { | |
| 1955 ASSERT(formatter != NULL); | |
| 1956 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form. | |
| 1957 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction. | |
| 1958 uword pc = start; | |
| 1959 intptr_t comment_finger = 0; | |
| 1960 while (pc < end) { | |
| 1961 const intptr_t offset = pc - start; | |
| 1962 while (comment_finger < comments.Length() && | |
| 1963 comments.PCOffsetAt(comment_finger) <= offset) { | |
| 1964 formatter->Print( | |
| 1965 " ;; %s\n", | |
| 1966 String::Handle(comments.CommentAt(comment_finger)).ToCString()); | |
| 1967 comment_finger++; | |
| 1968 } | |
| 1969 int instruction_length; | |
| 1970 DecodeInstruction(hex_buffer, | |
| 1971 sizeof(hex_buffer), | |
| 1972 human_buffer, | |
| 1973 sizeof(human_buffer), | |
| 1974 &instruction_length, pc); | |
| 1975 formatter->ConsumeInstruction(hex_buffer, | |
| 1976 sizeof(hex_buffer), | |
| 1977 human_buffer, | |
| 1978 sizeof(human_buffer), | |
| 1979 pc); | |
| 1980 pc += instruction_length; | |
| 1981 } | |
| 1982 | |
| 1983 return; | |
| 1984 } | |
| 1985 | |
| 1986 } // namespace dart | 1950 } // namespace dart |
| 1987 | 1951 |
| 1988 #endif // defined TARGET_ARCH_X64 | 1952 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |