| OLD | NEW |
| 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 #ifndef VM_DISASSEMBLER_H_ | 5 #ifndef VM_DISASSEMBLER_H_ |
| 6 #define VM_DISASSEMBLER_H_ | 6 #define VM_DISASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 | 57 |
| 58 // Disassemble instructions. | 58 // Disassemble instructions. |
| 59 class Disassembler : public AllStatic { | 59 class Disassembler : public AllStatic { |
| 60 public: | 60 public: |
| 61 // Disassemble instructions between start and end. | 61 // Disassemble instructions between start and end. |
| 62 // (The assumption is that start is at a valid instruction). | 62 // (The assumption is that start is at a valid instruction). |
| 63 static void Disassemble(uword start, | 63 static void Disassemble(uword start, |
| 64 uword end, | 64 uword end, |
| 65 DisassemblyFormatter* formatter); | 65 DisassemblyFormatter* formatter, |
| 66 const Code::Comments& comments); |
| 67 |
| 68 static void Disassemble(uword start, |
| 69 uword end, |
| 70 DisassemblyFormatter* formatter) { |
| 71 Disassemble(start, end, formatter, Code::Comments::New(0)); |
| 72 } |
| 73 |
| 74 static void Disassemble(uword start, |
| 75 uword end, |
| 76 const Code::Comments& comments) { |
| 77 DisassembleToStdout stdout_formatter; |
| 78 Disassemble(start, end, &stdout_formatter, comments); |
| 79 } |
| 80 |
| 66 static void Disassemble(uword start, uword end) { | 81 static void Disassemble(uword start, uword end) { |
| 67 DisassembleToStdout stdout_formatter; | 82 DisassembleToStdout stdout_formatter; |
| 68 Disassemble(start, end, &stdout_formatter); | 83 Disassemble(start, end, &stdout_formatter); |
| 69 } | 84 } |
| 70 | 85 |
| 71 // Disassemble instructions in a memory region. | 86 // Disassemble instructions in a memory region. |
| 72 static void DisassembleMemoryRegion(const MemoryRegion& instructions, | 87 static void DisassembleMemoryRegion(const MemoryRegion& instructions, |
| 73 DisassemblyFormatter* formatter) { | 88 DisassemblyFormatter* formatter) { |
| 74 uword start = instructions.start(); | 89 uword start = instructions.start(); |
| 75 uword end = instructions.end(); | 90 uword end = instructions.end(); |
| 76 Disassemble(start, end, formatter); | 91 Disassemble(start, end, formatter); |
| 77 } | 92 } |
| 93 |
| 78 static void DisassembleMemoryRegion(const MemoryRegion& instructions) { | 94 static void DisassembleMemoryRegion(const MemoryRegion& instructions) { |
| 79 uword start = instructions.start(); | 95 uword start = instructions.start(); |
| 80 uword end = instructions.end(); | 96 uword end = instructions.end(); |
| 81 Disassemble(start, end); | 97 Disassemble(start, end); |
| 82 } | 98 } |
| 83 | 99 |
| 84 // Decodes one instruction. | 100 // Decodes one instruction. |
| 85 // Writes a hexadecimal representation into the hex_buffer and a | 101 // Writes a hexadecimal representation into the hex_buffer and a |
| 86 // human-readable representation into the human_buffer. | 102 // human-readable representation into the human_buffer. |
| 87 // Returns the length of the decoded instruction in bytes. | 103 // Returns the length of the decoded instruction in bytes. |
| 88 static int DecodeInstruction(char* hex_buffer, intptr_t hex_size, | 104 static int DecodeInstruction(char* hex_buffer, intptr_t hex_size, |
| 89 char* human_buffer, intptr_t human_size, | 105 char* human_buffer, intptr_t human_size, |
| 90 uword pc); | 106 uword pc); |
| 91 | 107 |
| 92 private: | 108 private: |
| 93 static const int kHexadecimalBufferSize = 32; | 109 static const int kHexadecimalBufferSize = 32; |
| 94 static const int kUserReadableBufferSize = 256; | 110 static const int kUserReadableBufferSize = 256; |
| 95 }; | 111 }; |
| 96 | 112 |
| 97 } // namespace dart | 113 } // namespace dart |
| 98 | 114 |
| 99 #endif // VM_DISASSEMBLER_H_ | 115 #endif // VM_DISASSEMBLER_H_ |
| OLD | NEW |