| 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 "vm/object.h" | 8 #include "vm/object.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 class SourceBreakpoint; | 12 class SourceBreakpoint; |
| 13 class CodeBreakpoint; | 13 class CodeBreakpoint; |
| 14 class Isolate; | 14 class Isolate; |
| 15 class ObjectPointerVisitor; | 15 class ObjectPointerVisitor; |
| 16 class ActiveVariables; | 16 class ActiveVariables; |
| 17 | 17 class RemoteObjectCache; |
| 18 | 18 |
| 19 // SourceBreakpoint represents a user-specified breakpoint location in | 19 // SourceBreakpoint represents a user-specified breakpoint location in |
| 20 // Dart source. There may be more than one CodeBreakpoint object per | 20 // Dart source. There may be more than one CodeBreakpoint object per |
| 21 // SourceBreakpoint. | 21 // SourceBreakpoint. |
| 22 class SourceBreakpoint { | 22 class SourceBreakpoint { |
| 23 public: | 23 public: |
| 24 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_index); | 24 SourceBreakpoint(intptr_t id, const Function& func, intptr_t token_index); |
| 25 | 25 |
| 26 RawFunction* function() const { return function_; } | 26 RawFunction* function() const { return function_; } |
| 27 intptr_t token_index() const { return token_index_; } | 27 intptr_t token_index() const { return token_index_; } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 RawInstance* GetLocalVarValue(intptr_t slot_index); | 147 RawInstance* GetLocalVarValue(intptr_t slot_index); |
| 148 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args); | 148 RawInstance* GetInstanceCallReceiver(intptr_t num_actual_args); |
| 149 | 149 |
| 150 uword pc_; | 150 uword pc_; |
| 151 uword fp_; | 151 uword fp_; |
| 152 uword sp_; | 152 uword sp_; |
| 153 Function& function_; | 153 Function& function_; |
| 154 intptr_t token_index_; | 154 intptr_t token_index_; |
| 155 intptr_t line_number_; | 155 intptr_t line_number_; |
| 156 | 156 |
| 157 LocalVarDescriptors* var_descriptors_; | 157 LocalVarDescriptors& var_descriptors_; |
| 158 ZoneGrowableArray<intptr_t> desc_indices_; | 158 ZoneGrowableArray<intptr_t> desc_indices_; |
| 159 | 159 |
| 160 friend class Debugger; | 160 friend class Debugger; |
| 161 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); | 161 DISALLOW_COPY_AND_ASSIGN(ActivationFrame); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 | 164 |
| 165 // Array of function activations on the call stack. | 165 // Array of function activations on the call stack. |
| 166 class DebuggerStackTrace : public ZoneAllocated { | 166 class DebuggerStackTrace : public ZoneAllocated { |
| 167 public: | 167 public: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 179 | 179 |
| 180 friend class Debugger; | 180 friend class Debugger; |
| 181 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); | 181 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 | 184 |
| 185 typedef void BreakpointHandler(SourceBreakpoint* bpt, | 185 typedef void BreakpointHandler(SourceBreakpoint* bpt, |
| 186 DebuggerStackTrace* stack); | 186 DebuggerStackTrace* stack); |
| 187 | 187 |
| 188 | 188 |
| 189 | |
| 190 class Debugger { | 189 class Debugger { |
| 191 public: | 190 public: |
| 192 enum EventType { | 191 enum EventType { |
| 193 kPaused = 1, | 192 kPaused = 1, |
| 194 kBreakpointResolved = 2, | 193 kBreakpointResolved = 2, |
| 195 }; | 194 }; |
| 196 struct DebuggerEvent { | 195 struct DebuggerEvent { |
| 197 EventType type; | 196 EventType type; |
| 198 union { | 197 union { |
| 199 DebuggerStackTrace* stack_trace; | 198 DebuggerStackTrace* stack_trace; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 232 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 234 | 233 |
| 235 // Called from Runtime when a breakpoint in Dart code is reached. | 234 // Called from Runtime when a breakpoint in Dart code is reached. |
| 236 void BreakpointCallback(); | 235 void BreakpointCallback(); |
| 237 | 236 |
| 238 DebuggerStackTrace* StackTrace() const { return stack_trace_; } | 237 DebuggerStackTrace* StackTrace() const { return stack_trace_; } |
| 239 | 238 |
| 240 RawArray* GetInstanceFields(const Instance& obj); | 239 RawArray* GetInstanceFields(const Instance& obj); |
| 241 RawArray* GetStaticFields(const Class& cls); | 240 RawArray* GetStaticFields(const Class& cls); |
| 242 | 241 |
| 242 intptr_t CacheObject(const Object& obj); |
| 243 RawObject* GetCachedObject(intptr_t obj_id); |
| 244 bool IsValidObjectId(intptr_t obj_id); |
| 245 |
| 243 // Utility functions. | 246 // Utility functions. |
| 244 static const char* QualifiedFunctionName(const Function& func); | 247 static const char* QualifiedFunctionName(const Function& func); |
| 245 | 248 |
| 246 RawObject* GetInstanceField(const Class& cls, | 249 RawObject* GetInstanceField(const Class& cls, |
| 247 const String& field_name, | 250 const String& field_name, |
| 248 const Instance& object); | 251 const Instance& object); |
| 249 RawObject* GetStaticField(const Class& cls, | 252 RawObject* GetStaticField(const Class& cls, |
| 250 const String& field_name); | 253 const String& field_name); |
| 251 | 254 |
| 252 private: | 255 private: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 283 bool initialized_; | 286 bool initialized_; |
| 284 BreakpointHandler* bp_handler_; | 287 BreakpointHandler* bp_handler_; |
| 285 EventHandler* event_handler_; | 288 EventHandler* event_handler_; |
| 286 | 289 |
| 287 // ID number generator. | 290 // ID number generator. |
| 288 intptr_t next_id_; | 291 intptr_t next_id_; |
| 289 | 292 |
| 290 // Current stack trace. Valid while executing breakpoint callback code. | 293 // Current stack trace. Valid while executing breakpoint callback code. |
| 291 DebuggerStackTrace* stack_trace_; | 294 DebuggerStackTrace* stack_trace_; |
| 292 | 295 |
| 296 RemoteObjectCache* obj_cache_; |
| 297 |
| 293 SourceBreakpoint* src_breakpoints_; | 298 SourceBreakpoint* src_breakpoints_; |
| 294 CodeBreakpoint* code_breakpoints_; | 299 CodeBreakpoint* code_breakpoints_; |
| 295 | 300 |
| 296 // Tells debugger what to do when resuming execution after a breakpoint. | 301 // Tells debugger what to do when resuming execution after a breakpoint. |
| 297 ResumeAction resume_action_; | 302 ResumeAction resume_action_; |
| 298 | 303 |
| 299 // Do not call back to breakpoint handler if this flag is set. | 304 // Do not call back to breakpoint handler if this flag is set. |
| 300 // Effectively this means ignoring breakpoints. Set when Dart code may | 305 // Effectively this means ignoring breakpoints. Set when Dart code may |
| 301 // be run as a side effect of getting values of fields. | 306 // be run as a side effect of getting values of fields. |
| 302 bool ignore_breakpoints_; | 307 bool ignore_breakpoints_; |
| 303 | 308 |
| 304 friend class SourceBreakpoint; | 309 friend class SourceBreakpoint; |
| 305 DISALLOW_COPY_AND_ASSIGN(Debugger); | 310 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 306 }; | 311 }; |
| 307 | 312 |
| 308 | 313 |
| 309 } // namespace dart | 314 } // namespace dart |
| 310 | 315 |
| 311 #endif // VM_DEBUGGER_H_ | 316 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |