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" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 // Froward declaration. | 14 // Froward declaration. |
15 class MemoryRegion; | 15 class MemoryRegion; |
16 class JSONStream; | 16 class JSONArray; |
17 | 17 |
18 // Disassembly formatter interface, which consumes the | 18 // Disassembly formatter interface, which consumes the |
19 // disassembled instructions in any desired form. | 19 // disassembled instructions in any desired form. |
20 class DisassemblyFormatter { | 20 class DisassemblyFormatter { |
21 public: | 21 public: |
22 DisassemblyFormatter() { } | 22 DisassemblyFormatter() { } |
23 virtual ~DisassemblyFormatter() { } | 23 virtual ~DisassemblyFormatter() { } |
24 | 24 |
25 // Consume the decoded instruction at the given pc. | 25 // Consume the decoded instruction at the given pc. |
26 virtual void ConsumeInstruction(char* hex_buffer, | 26 virtual void ConsumeInstruction(char* hex_buffer, |
(...skipping 24 matching lines...) Expand all Loading... |
51 | 51 |
52 private: | 52 private: |
53 DISALLOW_ALLOCATION() | 53 DISALLOW_ALLOCATION() |
54 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); | 54 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); |
55 }; | 55 }; |
56 | 56 |
57 | 57 |
58 // Disassemble into a JSONStream. | 58 // Disassemble into a JSONStream. |
59 class DisassembleToJSONStream : public DisassemblyFormatter { | 59 class DisassembleToJSONStream : public DisassemblyFormatter { |
60 public: | 60 public: |
61 explicit DisassembleToJSONStream(JSONStream* stream) : DisassemblyFormatter(), | 61 explicit DisassembleToJSONStream(const JSONArray& jsarr) |
62 stream_(stream) { } | 62 : DisassemblyFormatter(), jsarr_(jsarr) { } |
63 ~DisassembleToJSONStream() { } | 63 ~DisassembleToJSONStream() { } |
64 | 64 |
65 virtual void ConsumeInstruction(char* hex_buffer, | 65 virtual void ConsumeInstruction(char* hex_buffer, |
66 intptr_t hex_size, | 66 intptr_t hex_size, |
67 char* human_buffer, | 67 char* human_buffer, |
68 intptr_t human_size, | 68 intptr_t human_size, |
69 uword pc); | 69 uword pc); |
70 | 70 |
71 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 71 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
72 | 72 |
73 private: | 73 private: |
74 JSONStream* stream_; | 74 const JSONArray& jsarr_; |
75 DISALLOW_ALLOCATION(); | 75 DISALLOW_ALLOCATION(); |
76 DISALLOW_COPY_AND_ASSIGN(DisassembleToJSONStream); | 76 DISALLOW_COPY_AND_ASSIGN(DisassembleToJSONStream); |
77 }; | 77 }; |
78 | 78 |
79 | 79 |
80 // Disassemble instructions. | 80 // Disassemble instructions. |
81 class Disassembler : public AllStatic { | 81 class Disassembler : public AllStatic { |
82 public: | 82 public: |
83 // Disassemble instructions between start and end. | 83 // Disassemble instructions between start and end. |
84 // (The assumption is that start is at a valid instruction). | 84 // (The assumption is that start is at a valid instruction). |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 int* out_instr_len, uword pc); | 129 int* out_instr_len, uword pc); |
130 | 130 |
131 private: | 131 private: |
132 static const int kHexadecimalBufferSize = 32; | 132 static const int kHexadecimalBufferSize = 32; |
133 static const int kUserReadableBufferSize = 256; | 133 static const int kUserReadableBufferSize = 256; |
134 }; | 134 }; |
135 | 135 |
136 } // namespace dart | 136 } // namespace dart |
137 | 137 |
138 #endif // VM_DISASSEMBLER_H_ | 138 #endif // VM_DISASSEMBLER_H_ |
OLD | NEW |