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 RUNTIME_VM_DISASSEMBLER_H_ | 5 #ifndef RUNTIME_VM_DISASSEMBLER_H_ |
6 #define RUNTIME_VM_DISASSEMBLER_H_ | 6 #define RUNTIME_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 18 matching lines...) Expand all Loading... |
29 intptr_t hex_size, | 29 intptr_t hex_size, |
30 char* human_buffer, | 30 char* human_buffer, |
31 intptr_t human_size, | 31 intptr_t human_size, |
32 Object* object, | 32 Object* object, |
33 uword pc) = 0; | 33 uword pc) = 0; |
34 | 34 |
35 // Print a formatted message. | 35 // Print a formatted message. |
36 virtual void Print(const char* format, ...) = 0; | 36 virtual void Print(const char* format, ...) = 0; |
37 }; | 37 }; |
38 | 38 |
39 | |
40 // Basic disassembly formatter that outputs the disassembled instruction | 39 // Basic disassembly formatter that outputs the disassembled instruction |
41 // to stdout. | 40 // to stdout. |
42 class DisassembleToStdout : public DisassemblyFormatter { | 41 class DisassembleToStdout : public DisassemblyFormatter { |
43 public: | 42 public: |
44 DisassembleToStdout() : DisassemblyFormatter() {} | 43 DisassembleToStdout() : DisassemblyFormatter() {} |
45 ~DisassembleToStdout() {} | 44 ~DisassembleToStdout() {} |
46 | 45 |
47 virtual void ConsumeInstruction(const Code& code, | 46 virtual void ConsumeInstruction(const Code& code, |
48 char* hex_buffer, | 47 char* hex_buffer, |
49 intptr_t hex_size, | 48 intptr_t hex_size, |
50 char* human_buffer, | 49 char* human_buffer, |
51 intptr_t human_size, | 50 intptr_t human_size, |
52 Object* object, | 51 Object* object, |
53 uword pc); | 52 uword pc); |
54 | 53 |
55 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 54 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
56 | 55 |
57 private: | 56 private: |
58 DISALLOW_ALLOCATION() | 57 DISALLOW_ALLOCATION() |
59 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); | 58 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); |
60 }; | 59 }; |
61 | 60 |
62 | |
63 // Disassemble into a JSONStream. | 61 // Disassemble into a JSONStream. |
64 class DisassembleToJSONStream : public DisassemblyFormatter { | 62 class DisassembleToJSONStream : public DisassemblyFormatter { |
65 public: | 63 public: |
66 explicit DisassembleToJSONStream(const JSONArray& jsarr) | 64 explicit DisassembleToJSONStream(const JSONArray& jsarr) |
67 : DisassemblyFormatter(), jsarr_(jsarr) {} | 65 : DisassemblyFormatter(), jsarr_(jsarr) {} |
68 ~DisassembleToJSONStream() {} | 66 ~DisassembleToJSONStream() {} |
69 | 67 |
70 virtual void ConsumeInstruction(const Code& code, | 68 virtual void ConsumeInstruction(const Code& code, |
71 char* hex_buffer, | 69 char* hex_buffer, |
72 intptr_t hex_size, | 70 intptr_t hex_size, |
73 char* human_buffer, | 71 char* human_buffer, |
74 intptr_t human_size, | 72 intptr_t human_size, |
75 Object* object, | 73 Object* object, |
76 uword pc); | 74 uword pc); |
77 | 75 |
78 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 76 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
79 | 77 |
80 private: | 78 private: |
81 const JSONArray& jsarr_; | 79 const JSONArray& jsarr_; |
82 DISALLOW_ALLOCATION(); | 80 DISALLOW_ALLOCATION(); |
83 DISALLOW_COPY_AND_ASSIGN(DisassembleToJSONStream); | 81 DISALLOW_COPY_AND_ASSIGN(DisassembleToJSONStream); |
84 }; | 82 }; |
85 | 83 |
86 | |
87 // Disassemble instructions. | 84 // Disassemble instructions. |
88 class Disassembler : public AllStatic { | 85 class Disassembler : public AllStatic { |
89 public: | 86 public: |
90 // Disassemble instructions between start and end. | 87 // Disassemble instructions between start and end. |
91 // (The assumption is that start is at a valid instruction). | 88 // (The assumption is that start is at a valid instruction). |
92 // Return true if all instructions were successfully decoded, false otherwise. | 89 // Return true if all instructions were successfully decoded, false otherwise. |
93 static void Disassemble(uword start, | 90 static void Disassemble(uword start, |
94 uword end, | 91 uword end, |
95 DisassemblyFormatter* formatter, | 92 DisassemblyFormatter* formatter, |
96 const Code& code); | 93 const Code& code); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 const Code& code, | 140 const Code& code, |
144 bool optimized); | 141 bool optimized); |
145 | 142 |
146 static const int kHexadecimalBufferSize = 32; | 143 static const int kHexadecimalBufferSize = 32; |
147 static const int kUserReadableBufferSize = 256; | 144 static const int kUserReadableBufferSize = 256; |
148 }; | 145 }; |
149 | 146 |
150 } // namespace dart | 147 } // namespace dart |
151 | 148 |
152 #endif // RUNTIME_VM_DISASSEMBLER_H_ | 149 #endif // RUNTIME_VM_DISASSEMBLER_H_ |
OLD | NEW |