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 #include "vm/log.h" | 11 #include "vm/log.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 // Froward declaration. | 15 // Froward declaration. |
16 class MemoryRegion; | 16 class MemoryRegion; |
17 class JSONArray; | 17 class JSONArray; |
18 | 18 |
19 // Disassembly formatter interface, which consumes the | 19 // Disassembly formatter interface, which consumes the |
20 // disassembled instructions in any desired form. | 20 // disassembled instructions in any desired form. |
21 class DisassemblyFormatter { | 21 class DisassemblyFormatter { |
22 public: | 22 public: |
23 DisassemblyFormatter() { } | 23 DisassemblyFormatter() { } |
24 virtual ~DisassemblyFormatter() { } | 24 virtual ~DisassemblyFormatter() { } |
25 | 25 |
26 // Consume the decoded instruction at the given pc. | 26 // Consume the decoded instruction at the given pc. |
27 virtual void ConsumeInstruction(char* hex_buffer, | 27 virtual void ConsumeInstruction(const Code& code, |
| 28 char* hex_buffer, |
28 intptr_t hex_size, | 29 intptr_t hex_size, |
29 char* human_buffer, | 30 char* human_buffer, |
30 intptr_t human_size, | 31 intptr_t human_size, |
31 uword pc) = 0; | 32 uword pc) = 0; |
32 | 33 |
33 // Print a formatted message. | 34 // Print a formatted message. |
34 virtual void Print(const char* format, ...) = 0; | 35 virtual void Print(const char* format, ...) = 0; |
35 }; | 36 }; |
36 | 37 |
37 | 38 |
38 // Basic disassembly formatter that outputs the disassembled instruction | 39 // Basic disassembly formatter that outputs the disassembled instruction |
39 // to stdout. | 40 // to stdout. |
40 class DisassembleToStdout : public DisassemblyFormatter { | 41 class DisassembleToStdout : public DisassemblyFormatter { |
41 public: | 42 public: |
42 DisassembleToStdout() : DisassemblyFormatter() { } | 43 DisassembleToStdout() : DisassemblyFormatter() { } |
43 ~DisassembleToStdout() { } | 44 ~DisassembleToStdout() { } |
44 | 45 |
45 virtual void ConsumeInstruction(char* hex_buffer, | 46 virtual void ConsumeInstruction(const Code& code, |
| 47 char* hex_buffer, |
46 intptr_t hex_size, | 48 intptr_t hex_size, |
47 char* human_buffer, | 49 char* human_buffer, |
48 intptr_t human_size, | 50 intptr_t human_size, |
49 uword pc); | 51 uword pc); |
50 | 52 |
51 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 53 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
52 | 54 |
53 private: | 55 private: |
54 DISALLOW_ALLOCATION() | 56 DISALLOW_ALLOCATION() |
55 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); | 57 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); |
56 }; | 58 }; |
57 | 59 |
58 | 60 |
59 // Disassemble into a JSONStream. | 61 // Disassemble into a JSONStream. |
60 class DisassembleToJSONStream : public DisassemblyFormatter { | 62 class DisassembleToJSONStream : public DisassemblyFormatter { |
61 public: | 63 public: |
62 explicit DisassembleToJSONStream(const JSONArray& jsarr) | 64 explicit DisassembleToJSONStream(const JSONArray& jsarr) |
63 : DisassemblyFormatter(), jsarr_(jsarr) { } | 65 : DisassemblyFormatter(), jsarr_(jsarr) { } |
64 ~DisassembleToJSONStream() { } | 66 ~DisassembleToJSONStream() { } |
65 | 67 |
66 virtual void ConsumeInstruction(char* hex_buffer, | 68 virtual void ConsumeInstruction(const Code& code, |
| 69 char* hex_buffer, |
67 intptr_t hex_size, | 70 intptr_t hex_size, |
68 char* human_buffer, | 71 char* human_buffer, |
69 intptr_t human_size, | 72 intptr_t human_size, |
70 uword pc); | 73 uword pc); |
71 | 74 |
72 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); | 75 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); |
73 | 76 |
74 private: | 77 private: |
75 const JSONArray& jsarr_; | 78 const JSONArray& jsarr_; |
76 DISALLOW_ALLOCATION(); | 79 DISALLOW_ALLOCATION(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 static bool CanFindOldObject(uword addr); | 137 static bool CanFindOldObject(uword addr); |
135 | 138 |
136 private: | 139 private: |
137 static const int kHexadecimalBufferSize = 32; | 140 static const int kHexadecimalBufferSize = 32; |
138 static const int kUserReadableBufferSize = 256; | 141 static const int kUserReadableBufferSize = 256; |
139 }; | 142 }; |
140 | 143 |
141 } // namespace dart | 144 } // namespace dart |
142 | 145 |
143 #endif // VM_DISASSEMBLER_H_ | 146 #endif // VM_DISASSEMBLER_H_ |
OLD | NEW |