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