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_DEBUGINFO_H_ | 5 #ifndef VM_DEBUGINFO_H_ |
6 #define VM_DEBUGINFO_H_ | 6 #define VM_DEBUGINFO_H_ |
7 | 7 |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/utils.h" | 10 #include "vm/utils.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 // A basic ByteArray which is growable and uses malloc/free. | 14 // A basic ByteVector which is growable and uses malloc/free. |
15 class ByteArray { | 15 class ByteVector { |
Ivan Posva
2012/01/13 00:32:44
DebugInfo::ByteBuffer => no more conflicts...
| |
16 public: | 16 public: |
17 ByteArray() : size_(0), capacity_(0), data_(NULL) { } | 17 ByteVector() : size_(0), capacity_(0), data_(NULL) { } |
18 ~ByteArray() { | 18 ~ByteVector() { |
19 free(data_); | 19 free(data_); |
20 size_ = 0; | 20 size_ = 0; |
21 capacity_ = 0; | 21 capacity_ = 0; |
22 data_ = NULL; | 22 data_ = NULL; |
23 } | 23 } |
24 | 24 |
25 uint8_t at(int index) const { | 25 uint8_t at(int index) const { |
26 ASSERT(0 <= index); | 26 ASSERT(0 <= index); |
27 ASSERT(index < size_); | 27 ASSERT(index < size_); |
28 ASSERT(size_ <= capacity_); | 28 ASSERT(size_ <= capacity_); |
(...skipping 21 matching lines...) Expand all Loading... | |
50 capacity_ = new_capacity; | 50 capacity_ = new_capacity; |
51 } | 51 } |
52 size_ = new_size; | 52 size_ = new_size; |
53 } | 53 } |
54 | 54 |
55 int size_; | 55 int size_; |
56 int capacity_; | 56 int capacity_; |
57 uint8_t* data_; | 57 uint8_t* data_; |
58 | 58 |
59 // Disallow assignment | 59 // Disallow assignment |
60 DISALLOW_COPY_AND_ASSIGN(ByteArray); | 60 DISALLOW_COPY_AND_ASSIGN(ByteVector); |
61 }; | 61 }; |
62 | 62 |
63 | 63 |
64 // DebugInfo is used to generate minimal debug information containing code, | 64 // DebugInfo is used to generate minimal debug information containing code, |
65 // symbols, and line numbers for generated code in the dart VM. This information | 65 // symbols, and line numbers for generated code in the dart VM. This information |
66 // can be used in two ways: | 66 // can be used in two ways: |
67 // - for debugging using a debugger | 67 // - for debugging using a debugger |
68 // - for generating information to be read by pprof to analyze Dart programs. | 68 // - for generating information to be read by pprof to analyze Dart programs. |
69 class DebugInfo { | 69 class DebugInfo { |
70 public: | 70 public: |
71 ~DebugInfo(); | 71 ~DebugInfo(); |
72 | 72 |
73 // Add the code starting at pc. | 73 // Add the code starting at pc. |
74 void AddCode(uword pc, intptr_t size); | 74 void AddCode(uword pc, intptr_t size); |
75 | 75 |
76 // Add symbol information for a region (includes the start and end symbol), | 76 // Add symbol information for a region (includes the start and end symbol), |
77 // does not add the actual code. | 77 // does not add the actual code. |
78 void AddCodeRegion(const char* name, uword pc, intptr_t size); | 78 void AddCodeRegion(const char* name, uword pc, intptr_t size); |
79 | 79 |
80 // Write out all the debug information info the memory region. | 80 // Write out all the debug information info the memory region. |
81 bool WriteToMemory(ByteArray* region); | 81 bool WriteToMemory(ByteVector* region); |
82 | 82 |
83 // Create a new debug information generator. | 83 // Create a new debug information generator. |
84 static DebugInfo* NewGenerator(); | 84 static DebugInfo* NewGenerator(); |
85 | 85 |
86 // Register this generated section with debuggger using the JIT interface. | 86 // Register this generated section with debuggger using the JIT interface. |
87 static void RegisterSection(const char* name, | 87 static void RegisterSection(const char* name, |
88 uword entry_point, | 88 uword entry_point, |
89 intptr_t size); | 89 intptr_t size); |
90 | 90 |
91 // Unregister all generated section from debuggger. | 91 // Unregister all generated section from debuggger. |
92 static void UnregisterAllSections(); | 92 static void UnregisterAllSections(); |
93 | 93 |
94 private: | 94 private: |
95 void* handle_; | 95 void* handle_; |
96 DebugInfo(); | 96 DebugInfo(); |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(DebugInfo); | 98 DISALLOW_COPY_AND_ASSIGN(DebugInfo); |
99 }; | 99 }; |
100 | 100 |
101 } // namespace dart | 101 } // namespace dart |
102 | 102 |
103 #endif // VM_DEBUGINFO_H_ | 103 #endif // VM_DEBUGINFO_H_ |
OLD | NEW |