| 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" |
| 11 #include "src/base/atomicops.h" | 11 #include "src/base/atomicops.h" |
| 12 #include "src/base/platform/platform.h" | 12 #include "src/base/platform/platform.h" |
| 13 #include "src/debug/liveedit.h" | 13 #include "src/debug/liveedit.h" |
| 14 #include "src/execution.h" | 14 #include "src/execution.h" |
| 15 #include "src/factory.h" | 15 #include "src/factory.h" |
| 16 #include "src/flags.h" | 16 #include "src/flags.h" |
| 17 #include "src/frames.h" | 17 #include "src/frames.h" |
| 18 #include "src/hashmap.h" | 18 #include "src/hashmap.h" |
| 19 #include "src/interpreter/source-position-table.h" |
| 19 #include "src/runtime/runtime.h" | 20 #include "src/runtime/runtime.h" |
| 20 #include "src/string-stream.h" | 21 #include "src/string-stream.h" |
| 21 #include "src/v8threads.h" | 22 #include "src/v8threads.h" |
| 22 | 23 |
| 23 #include "include/v8-debug.h" | 24 #include "include/v8-debug.h" |
| 24 | 25 |
| 25 namespace v8 { | 26 namespace v8 { |
| 26 namespace internal { | 27 namespace internal { |
| 27 | 28 |
| 28 | 29 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 int statement_position, | 78 int statement_position, |
| 78 List<BreakLocation>* result_out); | 79 List<BreakLocation>* result_out); |
| 79 | 80 |
| 80 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, | 81 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, |
| 81 BreakPositionAlignment alignment); | 82 BreakPositionAlignment alignment); |
| 82 | 83 |
| 83 bool IsDebugBreak() const; | 84 bool IsDebugBreak() const; |
| 84 | 85 |
| 85 inline bool IsReturn() const { return type_ == DEBUG_BREAK_SLOT_AT_RETURN; } | 86 inline bool IsReturn() const { return type_ == DEBUG_BREAK_SLOT_AT_RETURN; } |
| 86 inline bool IsCall() const { return type_ == DEBUG_BREAK_SLOT_AT_CALL; } | 87 inline bool IsCall() const { return type_ == DEBUG_BREAK_SLOT_AT_CALL; } |
| 88 inline bool IsDebugBreakSlot() const { return type_ >= DEBUG_BREAK_SLOT; } |
| 89 inline bool IsDebuggerStatement() const { |
| 90 return type_ == DEBUGGER_STATEMENT; |
| 91 } |
| 87 inline bool HasBreakPoint() const { | 92 inline bool HasBreakPoint() const { |
| 88 return debug_info_->HasBreakPoint(code_offset_); | 93 return debug_info_->HasBreakPoint(code_offset_); |
| 89 } | 94 } |
| 90 | 95 |
| 91 Handle<Object> BreakPointObjects() const; | 96 Handle<Object> BreakPointObjects() const; |
| 92 | 97 |
| 93 void SetBreakPoint(Handle<Object> break_point_object); | 98 void SetBreakPoint(Handle<Object> break_point_object); |
| 94 void ClearBreakPoint(Handle<Object> break_point_object); | 99 void ClearBreakPoint(Handle<Object> break_point_object); |
| 95 | 100 |
| 96 void SetOneShot(); | 101 void SetOneShot(); |
| 97 void ClearOneShot(); | 102 void ClearOneShot(); |
| 98 | 103 |
| 99 inline int position() const { return position_; } | 104 inline int position() const { return position_; } |
| 100 inline int statement_position() const { return statement_position_; } | 105 inline int statement_position() const { return statement_position_; } |
| 101 | 106 |
| 102 inline int code_offset() const { return code_offset_; } | 107 inline int code_offset() const { return code_offset_; } |
| 103 inline Isolate* isolate() { return debug_info_->GetIsolate(); } | 108 inline Isolate* isolate() { return debug_info_->GetIsolate(); } |
| 104 | 109 |
| 105 inline AbstractCode* abstract_code() const { | 110 inline AbstractCode* abstract_code() const { |
| 106 return debug_info_->abstract_code(); | 111 return debug_info_->abstract_code(); |
| 107 } | 112 } |
| 108 | 113 |
| 109 private: | 114 protected: |
| 110 enum DebugBreakType { | 115 enum DebugBreakType { |
| 111 NOT_DEBUG_BREAK, | 116 NOT_DEBUG_BREAK, |
| 112 DEBUGGER_STATEMENT, | 117 DEBUGGER_STATEMENT, |
| 113 DEBUG_BREAK_SLOT, | 118 DEBUG_BREAK_SLOT, |
| 114 DEBUG_BREAK_SLOT_AT_CALL, | 119 DEBUG_BREAK_SLOT_AT_CALL, |
| 115 DEBUG_BREAK_SLOT_AT_RETURN | 120 DEBUG_BREAK_SLOT_AT_RETURN |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 BreakLocation(Handle<DebugInfo> debug_info, DebugBreakType type, | 123 BreakLocation(Handle<DebugInfo> debug_info, DebugBreakType type, |
| 119 int code_offset, int position, int statement_position); | 124 int code_offset, int position, int statement_position); |
| 120 | 125 |
| 121 class Iterator { | 126 class Iterator { |
| 122 public: | 127 public: |
| 123 virtual ~Iterator() {} | 128 virtual ~Iterator() {} |
| 124 | 129 |
| 125 virtual BreakLocation GetBreakLocation() = 0; | 130 virtual BreakLocation GetBreakLocation() = 0; |
| 126 virtual bool Done() const = 0; | 131 virtual bool Done() const = 0; |
| 127 virtual void Next() = 0; | 132 virtual void Next() = 0; |
| 128 | 133 |
| 129 void SkipTo(int count) { | 134 void SkipTo(int count) { |
| 130 while (count-- > 0) Next(); | 135 while (count-- > 0) Next(); |
| 131 } | 136 } |
| 132 | 137 |
| 133 virtual int code_offset() = 0; | 138 virtual int code_offset() = 0; |
| 134 int break_index() const { return break_index_; } | 139 int break_index() const { return break_index_; } |
| 135 inline int position() const { return position_; } | 140 inline int position() const { return position_; } |
| 136 inline int statement_position() const { return statement_position_; } | 141 inline int statement_position() const { return statement_position_; } |
| 137 | 142 |
| 138 protected: | 143 protected: |
| 139 Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type); | 144 explicit Iterator(Handle<DebugInfo> debug_info); |
| 140 | 145 |
| 141 Handle<DebugInfo> debug_info_; | 146 Handle<DebugInfo> debug_info_; |
| 142 int break_index_; | 147 int break_index_; |
| 143 int position_; | 148 int position_; |
| 144 int statement_position_; | 149 int statement_position_; |
| 145 | 150 |
| 146 private: | 151 private: |
| 147 DisallowHeapAllocation no_gc_; | 152 DisallowHeapAllocation no_gc_; |
| 148 DISALLOW_COPY_AND_ASSIGN(Iterator); | 153 DISALLOW_COPY_AND_ASSIGN(Iterator); |
| 149 }; | 154 }; |
| 150 | 155 |
| 151 class CodeIterator : public Iterator { | 156 class CodeIterator : public Iterator { |
| 152 public: | 157 public: |
| 153 CodeIterator(Handle<DebugInfo> debug_info, BreakLocatorType type); | 158 CodeIterator(Handle<DebugInfo> debug_info, BreakLocatorType type); |
| 154 ~CodeIterator() override{}; | 159 ~CodeIterator() override {} |
| 155 | 160 |
| 156 BreakLocation GetBreakLocation() override; | 161 BreakLocation GetBreakLocation() override; |
| 157 bool Done() const override { return reloc_iterator_.done(); } | 162 bool Done() const override { return reloc_iterator_.done(); } |
| 158 void Next() override; | 163 void Next() override; |
| 159 | 164 |
| 160 int code_offset() override { | 165 int code_offset() override { |
| 161 return static_cast<int>( | 166 return static_cast<int>( |
| 162 rinfo()->pc() - | 167 rinfo()->pc() - |
| 163 debug_info_->abstract_code()->GetCode()->instruction_start()); | 168 debug_info_->abstract_code()->GetCode()->instruction_start()); |
| 164 } | 169 } |
| 165 | 170 |
| 166 private: | 171 private: |
| 167 static int GetModeMask(BreakLocatorType type); | 172 static int GetModeMask(BreakLocatorType type); |
| 168 RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } | 173 RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); } |
| 169 RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } | 174 RelocInfo* rinfo() { return reloc_iterator_.rinfo(); } |
| 170 | 175 |
| 171 RelocIterator reloc_iterator_; | 176 RelocIterator reloc_iterator_; |
| 172 DISALLOW_COPY_AND_ASSIGN(CodeIterator); | 177 DISALLOW_COPY_AND_ASSIGN(CodeIterator); |
| 173 }; | 178 }; |
| 174 | 179 |
| 180 class BytecodeArrayIterator : public Iterator { |
| 181 public: |
| 182 BytecodeArrayIterator(Handle<DebugInfo> debug_info, BreakLocatorType type); |
| 183 ~BytecodeArrayIterator() override {} |
| 184 |
| 185 BreakLocation GetBreakLocation() override; |
| 186 bool Done() const override { return source_position_iterator_.done(); } |
| 187 void Next() override; |
| 188 |
| 189 int code_offset() override { |
| 190 return source_position_iterator_.bytecode_offset(); |
| 191 } |
| 192 |
| 193 private: |
| 194 DebugBreakType GetDebugBreakType(); |
| 195 |
| 196 interpreter::SourcePositionTableIterator source_position_iterator_; |
| 197 BreakLocatorType break_locator_type_; |
| 198 int start_position_; |
| 199 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayIterator); |
| 200 }; |
| 201 |
| 175 static Iterator* GetIterator(Handle<DebugInfo> debug_info, | 202 static Iterator* GetIterator(Handle<DebugInfo> debug_info, |
| 176 BreakLocatorType type = ALL_BREAK_LOCATIONS); | 203 BreakLocatorType type = ALL_BREAK_LOCATIONS); |
| 177 | 204 |
| 205 private: |
| 178 friend class Debug; | 206 friend class Debug; |
| 179 | 207 |
| 180 static int BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, int offset); | 208 static int BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, int offset); |
| 181 | 209 |
| 182 void SetDebugBreak(); | 210 void SetDebugBreak(); |
| 183 void ClearDebugBreak(); | 211 void ClearDebugBreak(); |
| 184 | 212 |
| 185 inline bool IsDebuggerStatement() const { | |
| 186 return type_ == DEBUGGER_STATEMENT; | |
| 187 } | |
| 188 inline bool IsDebugBreakSlot() const { return type_ >= DEBUG_BREAK_SLOT; } | |
| 189 | |
| 190 Handle<DebugInfo> debug_info_; | 213 Handle<DebugInfo> debug_info_; |
| 191 int code_offset_; | 214 int code_offset_; |
| 192 DebugBreakType type_; | 215 DebugBreakType type_; |
| 193 int position_; | 216 int position_; |
| 194 int statement_position_; | 217 int statement_position_; |
| 195 }; | 218 }; |
| 196 | 219 |
| 197 | 220 |
| 198 // Linked list holding debug info objects. The debug info objects are kept as | 221 // Linked list holding debug info objects. The debug info objects are kept as |
| 199 // weak handles to avoid a debug info object to keep a function alive. | 222 // weak handles to avoid a debug info object to keep a function alive. |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 Handle<Code> code); | 790 Handle<Code> code); |
| 768 static bool DebugBreakSlotIsPatched(Address pc); | 791 static bool DebugBreakSlotIsPatched(Address pc); |
| 769 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); | 792 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); |
| 770 }; | 793 }; |
| 771 | 794 |
| 772 | 795 |
| 773 } // namespace internal | 796 } // namespace internal |
| 774 } // namespace v8 | 797 } // namespace v8 |
| 775 | 798 |
| 776 #endif // V8_DEBUG_DEBUG_H_ | 799 #endif // V8_DEBUG_DEBUG_H_ |
| OLD | NEW |