OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_DEBUGGER_H_ | 5 #ifndef VM_DEBUGGER_H_ |
6 #define VM_DEBUGGER_H_ | 6 #define VM_DEBUGGER_H_ |
7 | 7 |
8 #include "include/dart_debugger_api.h" | 8 #include "include/dart_debugger_api.h" |
9 | 9 |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
11 #include "vm/port.h" | 11 #include "vm/port.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 class SourceBreakpoint; | 15 class ActiveVariables; |
16 class CodeBreakpoint; | 16 class CodeBreakpoint; |
17 class Isolate; | 17 class Isolate; |
18 class ObjectPointerVisitor; | 18 class ObjectPointerVisitor; |
19 class ActiveVariables; | |
20 class RemoteObjectCache; | 19 class RemoteObjectCache; |
| 20 class SourceBreakpoint; |
| 21 class StackFrame; |
21 | 22 |
22 // SourceBreakpoint represents a user-specified breakpoint location in | 23 // SourceBreakpoint represents a user-specified breakpoint location in |
23 // Dart source. There may be more than one CodeBreakpoint object per | 24 // Dart source. There may be more than one CodeBreakpoint object per |
24 // SourceBreakpoint. | 25 // SourceBreakpoint. |
25 class SourceBreakpoint { | 26 class SourceBreakpoint { |
26 public: | 27 public: |
27 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_pos); | 28 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_pos); |
28 | 29 |
29 RawFunction* function() const { return function_; } | 30 RawFunction* function() const { return function_; } |
30 intptr_t token_pos() const { return token_pos_; } | 31 intptr_t token_pos() const { return token_pos_; } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return code_; | 137 return code_; |
137 } | 138 } |
138 | 139 |
139 RawString* QualifiedFunctionName(); | 140 RawString* QualifiedFunctionName(); |
140 RawString* SourceUrl(); | 141 RawString* SourceUrl(); |
141 RawScript* SourceScript(); | 142 RawScript* SourceScript(); |
142 RawLibrary* Library(); | 143 RawLibrary* Library(); |
143 intptr_t TokenPos(); | 144 intptr_t TokenPos(); |
144 intptr_t LineNumber(); | 145 intptr_t LineNumber(); |
145 void SetContext(const Context& ctx) { ctx_ = ctx.raw(); } | 146 void SetContext(const Context& ctx) { ctx_ = ctx.raw(); } |
| 147 void SetDeoptFrame(const Array& deopt_frame, intptr_t deopt_frame_offset) { |
| 148 deopt_frame_ = deopt_frame.raw(); |
| 149 deopt_frame_offset_ = deopt_frame_offset; |
| 150 } |
146 | 151 |
147 // Returns true if this frame is for a function that is visible | 152 // Returns true if this frame is for a function that is visible |
148 // to the user and can be debugged. | 153 // to the user and can be debugged. |
149 bool IsDebuggable() const; | 154 bool IsDebuggable() const; |
150 | 155 |
151 // The context level of a frame is the context level at the | 156 // The context level of a frame is the context level at the |
152 // PC/token index of the frame. It determines the depth of the context | 157 // PC/token index of the frame. It determines the depth of the context |
153 // chain that belongs to the function of this activation frame. | 158 // chain that belongs to the function of this activation frame. |
154 intptr_t ContextLevel(); | 159 intptr_t ContextLevel(); |
155 | 160 |
156 const char* ToCString(); | 161 const char* ToCString(); |
157 | 162 |
158 intptr_t NumLocalVariables(); | 163 intptr_t NumLocalVariables(); |
159 | 164 |
160 void VariableAt(intptr_t i, | 165 void VariableAt(intptr_t i, |
161 String* name, | 166 String* name, |
162 intptr_t* token_pos, | 167 intptr_t* token_pos, |
163 intptr_t* end_pos, | 168 intptr_t* end_pos, |
164 Instance* value); | 169 Instance* value); |
165 | 170 |
166 RawArray* GetLocalVariables(); | 171 RawArray* GetLocalVariables(); |
167 RawContext* GetSavedEntryContext(const Context& ctx); | 172 RawContext* GetSavedEntryContext(const Context& ctx); |
| 173 RawContext* GetSavedEntryContextNew(); |
168 RawContext* GetSavedCurrentContext(); | 174 RawContext* GetSavedCurrentContext(); |
169 | 175 |
170 private: | 176 private: |
171 intptr_t PcDescIndex(); | 177 intptr_t PcDescIndex(); |
172 intptr_t TryIndex(); | 178 intptr_t TryIndex(); |
173 void GetPcDescriptors(); | 179 void GetPcDescriptors(); |
174 void GetVarDescriptors(); | 180 void GetVarDescriptors(); |
175 void GetDescIndices(); | 181 void GetDescIndices(); |
| 182 |
| 183 RawObject* GetLocalVar(intptr_t slot_index); |
| 184 RawInstance* GetLocalInstanceVar(intptr_t slot_index); |
| 185 RawContext* GetLocalContextVar(intptr_t slot_index); |
| 186 |
176 RawInstance* GetLocalVarValue(intptr_t slot_index); | 187 RawInstance* GetLocalVarValue(intptr_t slot_index); |
177 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args); | 188 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args); |
178 RawObject* GetClosureObject(intptr_t num_acatual_args); | 189 RawObject* GetClosureObject(intptr_t num_acatual_args); |
179 | 190 |
180 uword pc_; | 191 uword pc_; |
181 uword fp_; | 192 uword fp_; |
182 uword sp_; | 193 uword sp_; |
183 | 194 |
184 // The anchor of the context chain for this function. | 195 // The anchor of the context chain for this function. |
185 Context& ctx_; | 196 Context& ctx_; |
186 const Code& code_; | 197 const Code& code_; |
187 const Function& function_; | 198 const Function& function_; |
188 intptr_t token_pos_; | 199 intptr_t token_pos_; |
189 intptr_t pc_desc_index_; | 200 intptr_t pc_desc_index_; |
190 intptr_t line_number_; | 201 intptr_t line_number_; |
191 intptr_t context_level_; | 202 intptr_t context_level_; |
192 | 203 |
| 204 // Some frames are deoptimized into a side array in order to inspect them. |
| 205 Array& deopt_frame_; |
| 206 intptr_t deopt_frame_offset_; |
| 207 |
193 bool vars_initialized_; | 208 bool vars_initialized_; |
194 LocalVarDescriptors& var_descriptors_; | 209 LocalVarDescriptors& var_descriptors_; |
195 ZoneGrowableArray<intptr_t> desc_indices_; | 210 ZoneGrowableArray<intptr_t> desc_indices_; |
196 PcDescriptors& pc_desc_; | 211 PcDescriptors& pc_desc_; |
197 | 212 |
198 friend class Debugger; | 213 friend class Debugger; |
199 friend class DebuggerStackTrace; | 214 friend class DebuggerStackTrace; |
200 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); | 215 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); |
201 }; | 216 }; |
202 | 217 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 void MakeCodeBreakpointsAt(const Function& func, | 370 void MakeCodeBreakpointsAt(const Function& func, |
356 intptr_t token_pos, | 371 intptr_t token_pos, |
357 SourceBreakpoint* bpt); | 372 SourceBreakpoint* bpt); |
358 // Returns NULL if no breakpoint exists for the given address. | 373 // Returns NULL if no breakpoint exists for the given address. |
359 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 374 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
360 | 375 |
361 void SyncBreakpoint(SourceBreakpoint* bpt); | 376 void SyncBreakpoint(SourceBreakpoint* bpt); |
362 | 377 |
363 ActivationFrame* TopDartFrame() const; | 378 ActivationFrame* TopDartFrame() const; |
364 static DebuggerStackTrace* CollectStackTrace(); | 379 static DebuggerStackTrace* CollectStackTrace(); |
| 380 static ActivationFrame* CollectDartFrame(Isolate* isolate, |
| 381 uword pc, |
| 382 StackFrame* frame, |
| 383 const Code& code, |
| 384 bool optimized, |
| 385 ActivationFrame* callee_activation, |
| 386 const Context& entry_ctx); |
| 387 static RawArray* DeoptimizeToArray(Isolate* isolate, |
| 388 StackFrame* frame, |
| 389 const Code& code); |
| 390 static DebuggerStackTrace* CollectStackTraceNew(); |
365 void SignalBpResolved(SourceBreakpoint *bpt); | 391 void SignalBpResolved(SourceBreakpoint *bpt); |
366 void SignalPausedEvent(ActivationFrame* top_frame); | 392 void SignalPausedEvent(ActivationFrame* top_frame); |
367 | 393 |
368 intptr_t nextId() { return next_id_++; } | 394 intptr_t nextId() { return next_id_++; } |
369 | 395 |
370 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, | 396 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, |
371 const Instance& exc); | 397 const Instance& exc); |
372 | 398 |
373 void CollectLibraryFields(const GrowableObjectArray& field_list, | 399 void CollectLibraryFields(const GrowableObjectArray& field_list, |
374 const Library& lib, | 400 const Library& lib, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 434 |
409 friend class Isolate; | 435 friend class Isolate; |
410 friend class SourceBreakpoint; | 436 friend class SourceBreakpoint; |
411 DISALLOW_COPY_AND_ASSIGN(Debugger); | 437 DISALLOW_COPY_AND_ASSIGN(Debugger); |
412 }; | 438 }; |
413 | 439 |
414 | 440 |
415 } // namespace dart | 441 } // namespace dart |
416 | 442 |
417 #endif // VM_DEBUGGER_H_ | 443 #endif // VM_DEBUGGER_H_ |
OLD | NEW |