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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 static void AllForStatementPosition(Handle<DebugInfo> debug_info, | 76 static void AllForStatementPosition(Handle<DebugInfo> debug_info, |
77 int statement_position, | 77 int statement_position, |
78 List<BreakLocation>* result_out); | 78 List<BreakLocation>* result_out); |
79 | 79 |
80 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, | 80 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, |
81 BreakPositionAlignment alignment); | 81 BreakPositionAlignment alignment); |
82 | 82 |
83 bool IsDebugBreak() const; | 83 bool IsDebugBreak() const; |
84 | 84 |
85 inline bool IsReturn() const { | 85 inline bool IsReturn() const { return type_ == DEBUG_BREAK_SLOT_AT_RETURN; } |
86 return RelocInfo::IsDebugBreakSlotAtReturn(rmode_); | 86 inline bool IsCall() const { return type_ == DEBUG_BREAK_SLOT_AT_CALL; } |
87 } | |
88 inline bool IsCall() const { | |
89 return RelocInfo::IsDebugBreakSlotAtCall(rmode_); | |
90 } | |
91 inline bool HasBreakPoint() const { | 87 inline bool HasBreakPoint() const { |
92 return debug_info_->HasBreakPoint(code_offset_); | 88 return debug_info_->HasBreakPoint(code_offset_); |
93 } | 89 } |
94 | 90 |
95 Handle<Object> BreakPointObjects() const; | 91 Handle<Object> BreakPointObjects() const; |
96 | 92 |
97 void SetBreakPoint(Handle<Object> break_point_object); | 93 void SetBreakPoint(Handle<Object> break_point_object); |
98 void ClearBreakPoint(Handle<Object> break_point_object); | 94 void ClearBreakPoint(Handle<Object> break_point_object); |
99 | 95 |
100 void SetOneShot(); | 96 void SetOneShot(); |
101 void ClearOneShot(); | 97 void ClearOneShot(); |
102 | 98 |
103 | |
104 inline RelocInfo rinfo() const { | |
105 return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code()); | |
106 } | |
107 | |
108 inline int position() const { return position_; } | 99 inline int position() const { return position_; } |
109 inline int statement_position() const { return statement_position_; } | 100 inline int statement_position() const { return statement_position_; } |
110 | 101 |
111 inline int code_offset() const { return code_offset_; } | 102 inline int code_offset() const { return code_offset_; } |
| 103 inline Isolate* isolate() { return debug_info_->GetIsolate(); } |
112 | 104 |
113 inline RelocInfo::Mode rmode() const { return rmode_; } | 105 inline AbstractCode* abstract_code() const { |
114 | 106 return debug_info_->abstract_code(); |
115 inline Code* code() const { return debug_info_->code(); } | 107 } |
116 | 108 |
117 private: | 109 private: |
118 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, int position, | 110 enum DebugBreakType { |
119 int statement_position); | 111 NOT_DEBUG_BREAK, |
| 112 DEBUGGER_STATEMENT, |
| 113 DEBUG_BREAK_SLOT, |
| 114 DEBUG_BREAK_SLOT_AT_CALL, |
| 115 DEBUG_BREAK_SLOT_AT_RETURN |
| 116 }; |
| 117 |
| 118 BreakLocation(Handle<DebugInfo> debug_info, DebugBreakType type, |
| 119 int code_offset, int position, int statement_position); |
120 | 120 |
121 class Iterator { | 121 class Iterator { |
122 public: | 122 public: |
123 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); | 123 virtual ~Iterator() {} |
124 | 124 |
125 BreakLocation GetBreakLocation() { | 125 virtual BreakLocation GetBreakLocation() = 0; |
126 return BreakLocation(debug_info_, rinfo(), position(), | 126 virtual bool Done() const = 0; |
127 statement_position()); | 127 virtual void Next() = 0; |
128 } | |
129 | |
130 inline bool Done() const { return reloc_iterator_.done(); } | |
131 void Next(); | |
132 | 128 |
133 void SkipTo(int count) { | 129 void SkipTo(int count) { |
134 while (count-- > 0) Next(); | 130 while (count-- > 0) Next(); |
135 } | 131 } |
136 | 132 |
137 inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } | 133 virtual int code_offset() = 0; |
138 inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } | |
139 inline Address pc() { return rinfo()->pc(); } | |
140 int break_index() const { return break_index_; } | 134 int break_index() const { return break_index_; } |
141 inline int position() const { return position_; } | 135 inline int position() const { return position_; } |
142 inline int statement_position() const { return statement_position_; } | 136 inline int statement_position() const { return statement_position_; } |
143 | 137 |
144 private: | 138 protected: |
145 static int GetModeMask(BreakLocatorType type); | 139 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); |
146 | 140 |
147 Handle<DebugInfo> debug_info_; | 141 Handle<DebugInfo> debug_info_; |
148 RelocIterator reloc_iterator_; | |
149 int break_index_; | 142 int break_index_; |
150 int position_; | 143 int position_; |
151 int statement_position_; | 144 int statement_position_; |
152 | 145 |
| 146 private: |
153 DisallowHeapAllocation no_gc_; | 147 DisallowHeapAllocation no_gc_; |
154 | |
155 DISALLOW_COPY_AND_ASSIGN(Iterator); | 148 DISALLOW_COPY_AND_ASSIGN(Iterator); |
156 }; | 149 }; |
157 | 150 |
| 151 class CodeIterator : public Iterator { |
| 152 public: |
| 153 CodeIterator(Handle<DebugInfo> debug_info, BreakLocatorType type); |
| 154 ~CodeIterator() override{}; |
| 155 |
| 156 BreakLocation GetBreakLocation() override; |
| 157 bool Done() const override { return reloc_iterator_.done(); } |
| 158 void Next() override; |
| 159 |
| 160 int code_offset() override { |
| 161 return static_cast<int>( |
| 162 rinfo()->pc() - |
| 163 debug_info_->abstract_code()->GetCode()->instruction_start()); |
| 164 } |
| 165 |
| 166 private: |
| 167 static int GetModeMask(BreakLocatorType type); |
| 168 RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } |
| 169 RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } |
| 170 |
| 171 RelocIterator reloc_iterator_; |
| 172 DISALLOW_COPY_AND_ASSIGN(CodeIterator); |
| 173 }; |
| 174 |
| 175 static Iterator* GetIterator(Handle<DebugInfo> debug_info, |
| 176 BreakLocatorType type = ALL_BREAK_LOCATIONS); |
| 177 |
158 friend class Debug; | 178 friend class Debug; |
159 | 179 |
160 static int BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, int offset); | 180 static int BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, int offset); |
161 | 181 |
162 void SetDebugBreak(); | 182 void SetDebugBreak(); |
163 void ClearDebugBreak(); | 183 void ClearDebugBreak(); |
164 | 184 |
165 inline bool IsDebuggerStatement() const { | 185 inline bool IsDebuggerStatement() const { |
166 return RelocInfo::IsDebuggerStatement(rmode_); | 186 return type_ == DEBUGGER_STATEMENT; |
167 } | 187 } |
168 inline bool IsDebugBreakSlot() const { | 188 inline bool IsDebugBreakSlot() const { return type_ >= DEBUG_BREAK_SLOT; } |
169 return RelocInfo::IsDebugBreakSlot(rmode_); | |
170 } | |
171 | |
172 inline Address pc() const { return code()->entry() + code_offset_; } | |
173 | 189 |
174 Handle<DebugInfo> debug_info_; | 190 Handle<DebugInfo> debug_info_; |
175 int code_offset_; | 191 int code_offset_; |
176 RelocInfo::Mode rmode_; | 192 DebugBreakType type_; |
177 intptr_t data_; | |
178 int position_; | 193 int position_; |
179 int statement_position_; | 194 int statement_position_; |
180 }; | 195 }; |
181 | 196 |
182 | 197 |
183 // Linked list holding debug info objects. The debug info objects are kept as | 198 // Linked list holding debug info objects. The debug info objects are kept as |
184 // weak handles to avoid a debug info object to keep a function alive. | 199 // weak handles to avoid a debug info object to keep a function alive. |
185 class DebugInfoListNode { | 200 class DebugInfoListNode { |
186 public: | 201 public: |
187 explicit DebugInfoListNode(DebugInfo* debug_info); | 202 explicit DebugInfoListNode(DebugInfo* debug_info); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // several frames above. | 758 // several frames above. |
744 // There is no calling conventions here, because it never actually gets | 759 // There is no calling conventions here, because it never actually gets |
745 // called, it only gets returned to. | 760 // called, it only gets returned to. |
746 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | 761 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); |
747 | 762 |
748 | 763 |
749 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode); | 764 static void GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode); |
750 | 765 |
751 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, | 766 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, |
752 Handle<Code> code); | 767 Handle<Code> code); |
| 768 static bool DebugBreakSlotIsPatched(Address pc); |
753 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 769 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
754 }; | 770 }; |
755 | 771 |
756 | 772 |
757 } // namespace internal | 773 } // namespace internal |
758 } // namespace v8 | 774 } // namespace v8 |
759 | 775 |
760 #endif // V8_DEBUG_DEBUG_H_ | 776 #endif // V8_DEBUG_DEBUG_H_ |
OLD | NEW |