OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_DEBUG_DEBUG_H_ | 5 #ifndef V8_DEBUG_DEBUG_H_ |
6 #define V8_DEBUG_DEBUG_H_ | 6 #define V8_DEBUG_DEBUG_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 enum BreakPositionAlignment { | 57 enum BreakPositionAlignment { |
58 STATEMENT_ALIGNED = 0, | 58 STATEMENT_ALIGNED = 0, |
59 BREAK_POSITION_ALIGNED = 1 | 59 BREAK_POSITION_ALIGNED = 1 |
60 }; | 60 }; |
61 | 61 |
62 | 62 |
63 class BreakLocation { | 63 class BreakLocation { |
64 public: | 64 public: |
65 // Find the break point at the supplied address, or the closest one before | 65 // Find the break point at the supplied address, or the closest one before |
66 // the address. | 66 // the address. |
67 static BreakLocation FromAddress(Handle<DebugInfo> debug_info, Address pc); | 67 static BreakLocation FromCodeOffset(Handle<DebugInfo> debug_info, int offset); |
68 | 68 |
69 template <class Frame> | 69 static BreakLocation FromFrame(Handle<DebugInfo> debug_info, |
70 static BreakLocation FromFrame(Handle<DebugInfo> debug_info, Frame* frame) { | 70 JavaScriptFrame* frame); |
71 // PC points to the instruction after the current one, possibly a break | |
72 // location as well. So the "- 1" to exclude it from the search. | |
73 return FromAddress(debug_info, frame->pc() - 1); | |
74 } | |
75 | 71 |
76 static void FromAddressSameStatement(Handle<DebugInfo> debug_info, Address pc, | 72 static void FromCodeOffsetSameStatement(Handle<DebugInfo> debug_info, |
77 List<BreakLocation>* result_out); | 73 int offset, |
| 74 List<BreakLocation>* result_out); |
78 | 75 |
79 static void AllForStatementPosition(Handle<DebugInfo> debug_info, | 76 static void AllForStatementPosition(Handle<DebugInfo> debug_info, |
80 int statement_position, | 77 int statement_position, |
81 List<BreakLocation>* result_out); | 78 List<BreakLocation>* result_out); |
82 | 79 |
83 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, | 80 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, |
84 BreakPositionAlignment alignment); | 81 BreakPositionAlignment alignment); |
85 | 82 |
86 bool IsDebugBreak() const; | 83 bool IsDebugBreak() const; |
87 | 84 |
88 inline bool IsReturn() const { | 85 inline bool IsReturn() const { |
89 return RelocInfo::IsDebugBreakSlotAtReturn(rmode_); | 86 return RelocInfo::IsDebugBreakSlotAtReturn(rmode_); |
90 } | 87 } |
91 inline bool IsCall() const { | 88 inline bool IsCall() const { |
92 return RelocInfo::IsDebugBreakSlotAtCall(rmode_); | 89 return RelocInfo::IsDebugBreakSlotAtCall(rmode_); |
93 } | 90 } |
94 inline bool HasBreakPoint() const { | 91 inline bool HasBreakPoint() const { |
95 return debug_info_->HasBreakPoint(pc_offset_); | 92 return debug_info_->HasBreakPoint(code_offset_); |
96 } | 93 } |
97 | 94 |
98 Handle<Object> BreakPointObjects() const; | 95 Handle<Object> BreakPointObjects() const; |
99 | 96 |
100 void SetBreakPoint(Handle<Object> break_point_object); | 97 void SetBreakPoint(Handle<Object> break_point_object); |
101 void ClearBreakPoint(Handle<Object> break_point_object); | 98 void ClearBreakPoint(Handle<Object> break_point_object); |
102 | 99 |
103 void SetOneShot(); | 100 void SetOneShot(); |
104 void ClearOneShot(); | 101 void ClearOneShot(); |
105 | 102 |
106 | 103 |
107 inline RelocInfo rinfo() const { | 104 inline RelocInfo rinfo() const { |
108 return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code()); | 105 return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code()); |
109 } | 106 } |
110 | 107 |
111 inline int position() const { return position_; } | 108 inline int position() const { return position_; } |
112 inline int statement_position() const { return statement_position_; } | 109 inline int statement_position() const { return statement_position_; } |
113 | 110 |
114 inline Address pc() const { return code()->entry() + pc_offset_; } | 111 inline int code_offset() const { return code_offset_; } |
115 | 112 |
116 inline RelocInfo::Mode rmode() const { return rmode_; } | 113 inline RelocInfo::Mode rmode() const { return rmode_; } |
117 | 114 |
118 inline Code* code() const { return debug_info_->code(); } | 115 inline Code* code() const { return debug_info_->code(); } |
119 | 116 |
120 private: | 117 private: |
121 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, int position, | 118 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, int position, |
122 int statement_position); | 119 int statement_position); |
123 | 120 |
124 class Iterator { | 121 class Iterator { |
(...skipping 28 matching lines...) Expand all Loading... |
153 int position_; | 150 int position_; |
154 int statement_position_; | 151 int statement_position_; |
155 | 152 |
156 DisallowHeapAllocation no_gc_; | 153 DisallowHeapAllocation no_gc_; |
157 | 154 |
158 DISALLOW_COPY_AND_ASSIGN(Iterator); | 155 DISALLOW_COPY_AND_ASSIGN(Iterator); |
159 }; | 156 }; |
160 | 157 |
161 friend class Debug; | 158 friend class Debug; |
162 | 159 |
163 static int BreakIndexFromAddress(Handle<DebugInfo> debug_info, Address pc); | 160 static int BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, int offset); |
164 | 161 |
165 void SetDebugBreak(); | 162 void SetDebugBreak(); |
166 void ClearDebugBreak(); | 163 void ClearDebugBreak(); |
167 | 164 |
168 inline bool IsDebuggerStatement() const { | 165 inline bool IsDebuggerStatement() const { |
169 return RelocInfo::IsDebuggerStatement(rmode_); | 166 return RelocInfo::IsDebuggerStatement(rmode_); |
170 } | 167 } |
171 inline bool IsDebugBreakSlot() const { | 168 inline bool IsDebugBreakSlot() const { |
172 return RelocInfo::IsDebugBreakSlot(rmode_); | 169 return RelocInfo::IsDebugBreakSlot(rmode_); |
173 } | 170 } |
174 | 171 |
| 172 inline Address pc() const { return code()->entry() + code_offset_; } |
| 173 |
175 Handle<DebugInfo> debug_info_; | 174 Handle<DebugInfo> debug_info_; |
176 int pc_offset_; | 175 int code_offset_; |
177 RelocInfo::Mode rmode_; | 176 RelocInfo::Mode rmode_; |
178 intptr_t data_; | 177 intptr_t data_; |
179 int position_; | 178 int position_; |
180 int statement_position_; | 179 int statement_position_; |
181 }; | 180 }; |
182 | 181 |
183 | 182 |
184 // Linked list holding debug info objects. The debug info objects are kept as | 183 // Linked list holding debug info objects. The debug info objects are kept as |
185 // weak handles to avoid a debug info object to keep a function alive. | 184 // weak handles to avoid a debug info object to keep a function alive. |
186 class DebugInfoListNode { | 185 class DebugInfoListNode { |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, | 751 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, |
753 Handle<Code> code); | 752 Handle<Code> code); |
754 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 753 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
755 }; | 754 }; |
756 | 755 |
757 | 756 |
758 } // namespace internal | 757 } // namespace internal |
759 } // namespace v8 | 758 } // namespace v8 |
760 | 759 |
761 #endif // V8_DEBUG_DEBUG_H_ | 760 #endif // V8_DEBUG_DEBUG_H_ |
OLD | NEW |