Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/debug/debug.h

Issue 1618343002: [interpreter, debugger] abstraction for source position calculation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/debug/debug.cc » ('j') | src/debug/debug.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position, 76 static BreakLocation FromPosition(Handle<DebugInfo> debug_info, int position,
80 BreakPositionAlignment alignment); 77 BreakPositionAlignment alignment);
81 78
82 bool IsDebugBreak() const; 79 bool IsDebugBreak() const;
83 80
84 inline bool IsReturn() const { 81 inline bool IsReturn() const {
85 return RelocInfo::IsDebugBreakSlotAtReturn(rmode_); 82 return RelocInfo::IsDebugBreakSlotAtReturn(rmode_);
86 } 83 }
87 inline bool IsCall() const { 84 inline bool IsCall() const {
88 return RelocInfo::IsDebugBreakSlotAtCall(rmode_); 85 return RelocInfo::IsDebugBreakSlotAtCall(rmode_);
89 } 86 }
90 inline bool HasBreakPoint() const { 87 inline bool HasBreakPoint() const {
91 return debug_info_->HasBreakPoint(pc_offset_); 88 return debug_info_->HasBreakPoint(code_offset_);
92 } 89 }
93 90
94 Handle<Object> BreakPointObjects() const; 91 Handle<Object> BreakPointObjects() const;
95 92
96 void SetBreakPoint(Handle<Object> break_point_object); 93 void SetBreakPoint(Handle<Object> break_point_object);
97 void ClearBreakPoint(Handle<Object> break_point_object); 94 void ClearBreakPoint(Handle<Object> break_point_object);
98 95
99 void SetOneShot(); 96 void SetOneShot();
100 void ClearOneShot(); 97 void ClearOneShot();
101 98
102 99
103 inline RelocInfo rinfo() const { 100 inline RelocInfo rinfo() const {
104 return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code()); 101 return RelocInfo(debug_info_->GetIsolate(), pc(), rmode(), data_, code());
105 } 102 }
106 103
107 inline int position() const { return position_; } 104 inline int position() const { return position_; }
108 inline int statement_position() const { return statement_position_; } 105 inline int statement_position() const { return statement_position_; }
109 106
110 inline Address pc() const { return code()->entry() + pc_offset_; } 107 inline int code_offset() const { return code_offset_; }
111 108
112 inline RelocInfo::Mode rmode() const { return rmode_; } 109 inline RelocInfo::Mode rmode() const { return rmode_; }
113 110
114 inline Code* code() const { return debug_info_->code(); } 111 inline Code* code() const { return debug_info_->code(); }
115 112
116 private: 113 private:
117 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, int position, 114 BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, int position,
118 int statement_position); 115 int statement_position);
119 116
120 class Iterator { 117 class Iterator {
(...skipping 28 matching lines...) Expand all
149 int position_; 146 int position_;
150 int statement_position_; 147 int statement_position_;
151 148
152 DisallowHeapAllocation no_gc_; 149 DisallowHeapAllocation no_gc_;
153 150
154 DISALLOW_COPY_AND_ASSIGN(Iterator); 151 DISALLOW_COPY_AND_ASSIGN(Iterator);
155 }; 152 };
156 153
157 friend class Debug; 154 friend class Debug;
158 155
159 static int BreakIndexFromAddress(Handle<DebugInfo> debug_info, Address pc); 156 static int BreakIndexFromCodeOffset(Handle<DebugInfo> debug_info, int offset);
160 157
161 void SetDebugBreak(); 158 void SetDebugBreak();
162 void ClearDebugBreak(); 159 void ClearDebugBreak();
163 160
164 inline bool IsDebuggerStatement() const { 161 inline bool IsDebuggerStatement() const {
165 return RelocInfo::IsDebuggerStatement(rmode_); 162 return RelocInfo::IsDebuggerStatement(rmode_);
166 } 163 }
167 inline bool IsDebugBreakSlot() const { 164 inline bool IsDebugBreakSlot() const {
168 return RelocInfo::IsDebugBreakSlot(rmode_); 165 return RelocInfo::IsDebugBreakSlot(rmode_);
169 } 166 }
170 167
168 inline Address pc() const { return code()->entry() + code_offset_; }
169
171 Handle<DebugInfo> debug_info_; 170 Handle<DebugInfo> debug_info_;
172 int pc_offset_; 171 int code_offset_;
173 RelocInfo::Mode rmode_; 172 RelocInfo::Mode rmode_;
174 intptr_t data_; 173 intptr_t data_;
175 int position_; 174 int position_;
176 int statement_position_; 175 int statement_position_;
177 }; 176 };
178 177
179 178
180 // Linked list holding debug info objects. The debug info objects are kept as 179 // Linked list holding debug info objects. The debug info objects are kept as
181 // weak handles to avoid a debug info object to keep a function alive. 180 // weak handles to avoid a debug info object to keep a function alive.
182 class DebugInfoListNode { 181 class DebugInfoListNode {
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 static void PatchDebugBreakSlot(Isolate* isolate, Address pc, 747 static void PatchDebugBreakSlot(Isolate* isolate, Address pc,
749 Handle<Code> code); 748 Handle<Code> code);
750 static void ClearDebugBreakSlot(Isolate* isolate, Address pc); 749 static void ClearDebugBreakSlot(Isolate* isolate, Address pc);
751 }; 750 };
752 751
753 752
754 } // namespace internal 753 } // namespace internal
755 } // namespace v8 754 } // namespace v8
756 755
757 #endif // V8_DEBUG_DEBUG_H_ 756 #endif // V8_DEBUG_DEBUG_H_
OLDNEW
« no previous file with comments | « no previous file | src/debug/debug.cc » ('j') | src/debug/debug.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698