| 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 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class SourceBreakpoint; | 14 class SourceBreakpoint; |
| 15 class CodeBreakpoint; | 15 class CodeBreakpoint; |
| 16 class Isolate; | 16 class Isolate; |
| 17 class ObjectPointerVisitor; | 17 class ObjectPointerVisitor; |
| 18 class ActiveVariables; | 18 class ActiveVariables; |
| 19 class RemoteObjectCache; | 19 class RemoteObjectCache; |
| 20 | 20 |
| 21 // SourceBreakpoint represents a user-specified breakpoint location in | 21 // SourceBreakpoint represents a user-specified breakpoint location in |
| 22 // Dart source. There may be more than one CodeBreakpoint object per | 22 // Dart source. There may be more than one CodeBreakpoint object per |
| 23 // SourceBreakpoint. | 23 // SourceBreakpoint. |
| 24 class SourceBreakpoint { | 24 class SourceBreakpoint { |
| 25 public: | 25 public: |
| 26 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_index); | 26 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_pos); |
| 27 | 27 |
| 28 RawFunction* function() const { return function_; } | 28 RawFunction* function() const { return function_; } |
| 29 intptr_t token_index() const { return token_index_; } | 29 intptr_t token_pos() const { return token_pos_; } |
| 30 intptr_t id() const { return id_; } | 30 intptr_t id() const { return id_; } |
| 31 | 31 |
| 32 RawScript* SourceCode(); | 32 RawScript* SourceCode(); |
| 33 RawString* SourceUrl(); | 33 RawString* SourceUrl(); |
| 34 intptr_t LineNumber(); | 34 intptr_t LineNumber(); |
| 35 | 35 |
| 36 void Enable(); | 36 void Enable(); |
| 37 void Disable(); | 37 void Disable(); |
| 38 bool IsEnabled() const { return is_enabled_; } | 38 bool IsEnabled() const { return is_enabled_; } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 41 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 42 | 42 |
| 43 void set_function(const Function& func); | 43 void set_function(const Function& func); |
| 44 void set_next(SourceBreakpoint* value) { next_ = value; } | 44 void set_next(SourceBreakpoint* value) { next_ = value; } |
| 45 SourceBreakpoint* next() const { return this->next_; } | 45 SourceBreakpoint* next() const { return this->next_; } |
| 46 | 46 |
| 47 const intptr_t id_; | 47 const intptr_t id_; |
| 48 RawFunction* function_; | 48 RawFunction* function_; |
| 49 const intptr_t token_index_; | 49 const intptr_t token_pos_; |
| 50 intptr_t line_number_; | 50 intptr_t line_number_; |
| 51 bool is_enabled_; | 51 bool is_enabled_; |
| 52 | 52 |
| 53 SourceBreakpoint* next_; | 53 SourceBreakpoint* next_; |
| 54 | 54 |
| 55 friend class Debugger; | 55 friend class Debugger; |
| 56 DISALLOW_COPY_AND_ASSIGN(SourceBreakpoint); | 56 DISALLOW_COPY_AND_ASSIGN(SourceBreakpoint); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 | 59 |
| 60 // CodeBreakpoint represents a location in compiled code. There may be | 60 // CodeBreakpoint represents a location in compiled code. There may be |
| 61 // more than one CodeBreakpoint for one SourceBreakpoint, e.g. when a | 61 // more than one CodeBreakpoint for one SourceBreakpoint, e.g. when a |
| 62 // function gets compiled as a regular function and as a closure. | 62 // function gets compiled as a regular function and as a closure. |
| 63 class CodeBreakpoint { | 63 class CodeBreakpoint { |
| 64 public: | 64 public: |
| 65 CodeBreakpoint(const Function& func, intptr_t pc_desc_index); | 65 CodeBreakpoint(const Function& func, intptr_t pc_desc_index); |
| 66 ~CodeBreakpoint(); | 66 ~CodeBreakpoint(); |
| 67 | 67 |
| 68 RawFunction* function() const { return function_; } | 68 RawFunction* function() const { return function_; } |
| 69 uword pc() const { return pc_; } | 69 uword pc() const { return pc_; } |
| 70 intptr_t token_index() const { return token_index_; } | 70 intptr_t token_pos() const { return token_pos_; } |
| 71 bool IsInternal() const { return src_bpt_ == NULL; } | 71 bool IsInternal() const { return src_bpt_ == NULL; } |
| 72 | 72 |
| 73 RawScript* SourceCode(); | 73 RawScript* SourceCode(); |
| 74 RawString* SourceUrl(); | 74 RawString* SourceUrl(); |
| 75 intptr_t LineNumber(); | 75 intptr_t LineNumber(); |
| 76 | 76 |
| 77 void Enable(); | 77 void Enable(); |
| 78 void Disable(); | 78 void Disable(); |
| 79 bool IsEnabled() const { return is_enabled_; } | 79 bool IsEnabled() const { return is_enabled_; } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 82 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 83 | 83 |
| 84 SourceBreakpoint* src_bpt() const { return src_bpt_; } | 84 SourceBreakpoint* src_bpt() const { return src_bpt_; } |
| 85 void set_src_bpt(SourceBreakpoint* value) { src_bpt_ = value; } | 85 void set_src_bpt(SourceBreakpoint* value) { src_bpt_ = value; } |
| 86 | 86 |
| 87 void set_next(CodeBreakpoint* value) { next_ = value; } | 87 void set_next(CodeBreakpoint* value) { next_ = value; } |
| 88 CodeBreakpoint* next() const { return this->next_; } | 88 CodeBreakpoint* next() const { return this->next_; } |
| 89 intptr_t pc_desc_index() const { return pc_desc_index_; } | 89 intptr_t pc_desc_index() const { return pc_desc_index_; } |
| 90 | 90 |
| 91 void PatchCode(); | 91 void PatchCode(); |
| 92 void RestoreCode(); | 92 void RestoreCode(); |
| 93 void PatchFunctionReturn(); | 93 void PatchFunctionReturn(); |
| 94 void RestoreFunctionReturn(); | 94 void RestoreFunctionReturn(); |
| 95 | 95 |
| 96 RawFunction* function_; | 96 RawFunction* function_; |
| 97 intptr_t pc_desc_index_; | 97 intptr_t pc_desc_index_; |
| 98 intptr_t token_index_; | 98 intptr_t token_pos_; |
| 99 uword pc_; | 99 uword pc_; |
| 100 intptr_t line_number_; | 100 intptr_t line_number_; |
| 101 bool is_enabled_; | 101 bool is_enabled_; |
| 102 | 102 |
| 103 SourceBreakpoint* src_bpt_; | 103 SourceBreakpoint* src_bpt_; |
| 104 CodeBreakpoint* next_; | 104 CodeBreakpoint* next_; |
| 105 | 105 |
| 106 PcDescriptors::Kind breakpoint_kind_; | 106 PcDescriptors::Kind breakpoint_kind_; |
| 107 union { | 107 union { |
| 108 uword target_address_; | 108 uword target_address_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args); | 160 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args); |
| 161 | 161 |
| 162 uword pc_; | 162 uword pc_; |
| 163 uword fp_; | 163 uword fp_; |
| 164 uword sp_; | 164 uword sp_; |
| 165 | 165 |
| 166 // The anchor of the context chain for this function. | 166 // The anchor of the context chain for this function. |
| 167 const Context& ctx_; | 167 const Context& ctx_; |
| 168 | 168 |
| 169 Function& function_; | 169 Function& function_; |
| 170 intptr_t token_index_; | 170 intptr_t token_pos_; |
| 171 intptr_t pc_desc_index_; | 171 intptr_t pc_desc_index_; |
| 172 intptr_t line_number_; | 172 intptr_t line_number_; |
| 173 intptr_t context_level_; | 173 intptr_t context_level_; |
| 174 | 174 |
| 175 bool vars_initialized_; | 175 bool vars_initialized_; |
| 176 LocalVarDescriptors& var_descriptors_; | 176 LocalVarDescriptors& var_descriptors_; |
| 177 ZoneGrowableArray<intptr_t> desc_indices_; | 177 ZoneGrowableArray<intptr_t> desc_indices_; |
| 178 PcDescriptors& pc_desc_; | 178 PcDescriptors& pc_desc_; |
| 179 | 179 |
| 180 friend class Debugger; | 180 friend class Debugger; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 enum ResumeAction { | 285 enum ResumeAction { |
| 286 kContinue, | 286 kContinue, |
| 287 kStepOver, | 287 kStepOver, |
| 288 kStepInto, | 288 kStepInto, |
| 289 kStepOut | 289 kStepOut |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 void EnsureFunctionIsDeoptimized(const Function& func); | 292 void EnsureFunctionIsDeoptimized(const Function& func); |
| 293 void InstrumentForStepping(const Function& target_function); | 293 void InstrumentForStepping(const Function& target_function); |
| 294 SourceBreakpoint* SetBreakpoint(const Function& target_function, | 294 SourceBreakpoint* SetBreakpoint(const Function& target_function, |
| 295 intptr_t token_index); | 295 intptr_t token_pos); |
| 296 void RemoveInternalBreakpoints(); | 296 void RemoveInternalBreakpoints(); |
| 297 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); | 297 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); |
| 298 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); | 298 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); |
| 299 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); | 299 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); |
| 300 SourceBreakpoint* GetSourceBreakpoint(const Function& func, | 300 SourceBreakpoint* GetSourceBreakpoint(const Function& func, |
| 301 intptr_t token_index); | 301 intptr_t token_pos); |
| 302 CodeBreakpoint* MakeCodeBreakpoint(const Function& func, | 302 CodeBreakpoint* MakeCodeBreakpoint(const Function& func, |
| 303 intptr_t token_index); | 303 intptr_t token_pos); |
| 304 | 304 |
| 305 // Returns NULL if no breakpoint exists for the given address. | 305 // Returns NULL if no breakpoint exists for the given address. |
| 306 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 306 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
| 307 | 307 |
| 308 void SyncBreakpoint(SourceBreakpoint* bpt); | 308 void SyncBreakpoint(SourceBreakpoint* bpt); |
| 309 | 309 |
| 310 DebuggerStackTrace* CollectStackTrace(); | 310 DebuggerStackTrace* CollectStackTrace(); |
| 311 void SignalBpResolved(SourceBreakpoint *bpt); | 311 void SignalBpResolved(SourceBreakpoint *bpt); |
| 312 | 312 |
| 313 bool IsDebuggable(const Function& func); | 313 bool IsDebuggable(const Function& func); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 intptr_t exc_pause_info_; | 348 intptr_t exc_pause_info_; |
| 349 | 349 |
| 350 friend class SourceBreakpoint; | 350 friend class SourceBreakpoint; |
| 351 DISALLOW_COPY_AND_ASSIGN(Debugger); | 351 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 352 }; | 352 }; |
| 353 | 353 |
| 354 | 354 |
| 355 } // namespace dart | 355 } // namespace dart |
| 356 | 356 |
| 357 #endif // VM_DEBUGGER_H_ | 357 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |