| 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 CodeBreakpoint; | 15 class CodeBreakpoint; |
| 16 class Isolate; | 16 class Isolate; |
| 17 class JSONArray; | 17 class JSONArray; |
| 18 class JSONStream; | 18 class JSONStream; |
| 19 class ObjectPointerVisitor; | 19 class ObjectPointerVisitor; |
| 20 class RemoteObjectCache; | 20 class RemoteObjectCache; |
| 21 class SourceBreakpoint; | 21 class BreakpointLocation; |
| 22 class StackFrame; | 22 class StackFrame; |
| 23 | 23 |
| 24 // SourceBreakpoint represents a user-specified breakpoint location in | 24 // A user-defined breakpoint, which either fires once, for a particular closure, |
| 25 // Dart source. There may be more than one CodeBreakpoint object per | 25 // or always. The API's notion of a breakpoint corresponds to this object. |
| 26 // SourceBreakpoint. | 26 class Breakpoint { |
| 27 public: |
| 28 Breakpoint(intptr_t id, BreakpointLocation* bpt_location) |
| 29 : id_(id), |
| 30 kind_(Breakpoint::kNone), |
| 31 next_(NULL), |
| 32 closure_(Instance::null()), |
| 33 bpt_location_(bpt_location) {} |
| 34 |
| 35 intptr_t id() const { return id_; } |
| 36 Breakpoint* next() const { return next_; } |
| 37 void set_next(Breakpoint* n) { next_ = n; } |
| 38 |
| 39 BreakpointLocation* bpt_location() const { return bpt_location_; } |
| 40 void set_bpt_location(BreakpointLocation* new_bpt_location); |
| 41 |
| 42 bool IsRepeated() const { return kind_ == kRepeated; } |
| 43 bool IsSingleShot() const { return kind_ == kSingleShot; } |
| 44 bool IsPerClosure() const { return kind_ == kPerClosure; } |
| 45 RawInstance* closure() const { return closure_; } |
| 46 |
| 47 void SetIsRepeated() { |
| 48 ASSERT(kind_ == kNone); |
| 49 kind_ = kRepeated; |
| 50 } |
| 51 |
| 52 void SetIsSingleShot() { |
| 53 ASSERT(kind_ == kNone); |
| 54 kind_ = kSingleShot; |
| 55 } |
| 56 |
| 57 void SetIsPerClosure(const Instance& closure) { |
| 58 ASSERT(kind_ == kNone); |
| 59 kind_ = kPerClosure; |
| 60 closure_ = closure.raw(); |
| 61 } |
| 62 |
| 63 void PrintJSON(JSONStream* stream); |
| 64 |
| 65 private: |
| 66 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 67 |
| 68 enum ConditionKind { |
| 69 kNone, |
| 70 kRepeated, |
| 71 kSingleShot, |
| 72 kPerClosure, |
| 73 }; |
| 74 |
| 75 intptr_t id_; |
| 76 ConditionKind kind_; |
| 77 Breakpoint* next_; |
| 78 RawInstance* closure_; |
| 79 BreakpointLocation* bpt_location_; |
| 80 |
| 81 friend class BreakpointLocation; |
| 82 DISALLOW_COPY_AND_ASSIGN(Breakpoint); |
| 83 }; |
| 84 |
| 85 |
| 86 // BreakpointLocation represents a collection of breakpoint conditions at the |
| 87 // same token position in Dart source. There may be more than one CodeBreakpoint |
| 88 // object per BreakpointLocation. |
| 27 // An unresolved breakpoint is one where the underlying code has not | 89 // An unresolved breakpoint is one where the underlying code has not |
| 28 // been compiled yet. Since the code has not been compiled, we don't know | 90 // been compiled yet. Since the code has not been compiled, we don't know |
| 29 // the definitive source location yet. The requested source location may | 91 // the definitive source location yet. The requested source location may |
| 30 // change when the underlying code gets compiled. | 92 // change when the underlying code gets compiled. |
| 31 // A latent breakpoint represents a breakpoint location in Dart source | 93 // A latent breakpoint represents a breakpoint location in Dart source |
| 32 // that is not loaded in the VM when the breakpoint is requested. | 94 // that is not loaded in the VM when the breakpoint is requested. |
| 33 // When a script with matching url is loaded, a latent breakpoint | 95 // When a script with matching url is loaded, a latent breakpoint |
| 34 // becomes an unresolved breakpoint. | 96 // becomes an unresolved breakpoint. |
| 35 class SourceBreakpoint { | 97 class BreakpointLocation { |
| 36 public: | 98 public: |
| 37 // Create a new unresolved breakpoint. | 99 // Create a new unresolved breakpoint. |
| 38 SourceBreakpoint(intptr_t id, | 100 BreakpointLocation(const Script& script, |
| 39 const Script& script, | 101 intptr_t token_pos, |
| 40 intptr_t token_pos, | 102 intptr_t end_token_pos); |
| 41 intptr_t end_token_pos); | |
| 42 // Create a new latent breakpoint. | 103 // Create a new latent breakpoint. |
| 43 SourceBreakpoint(intptr_t id, | 104 BreakpointLocation(const String& url, |
| 44 const String& url, | 105 intptr_t line_number); |
| 45 intptr_t line_number); | 106 |
| 107 ~BreakpointLocation(); |
| 46 | 108 |
| 47 RawFunction* function() const { return function_; } | 109 RawFunction* function() const { return function_; } |
| 48 intptr_t token_pos() const { return token_pos_; } | 110 intptr_t token_pos() const { return token_pos_; } |
| 49 intptr_t end_token_pos() const { return end_token_pos_; } | 111 intptr_t end_token_pos() const { return end_token_pos_; } |
| 50 intptr_t id() const { return id_; } | |
| 51 | 112 |
| 52 RawScript* script() const { return script_; } | 113 RawScript* script() const { return script_; } |
| 53 RawString* url() const { return url_; } | 114 RawString* url() const { return url_; } |
| 54 intptr_t LineNumber(); | 115 intptr_t LineNumber(); |
| 55 | 116 |
| 56 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); | 117 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); |
| 57 | 118 |
| 58 void Enable(); | 119 Breakpoint* AddRepeated(Debugger* dbg); |
| 59 void Disable(); | 120 Breakpoint* AddSingleShot(Debugger* dbg); |
| 60 bool IsEnabled() const { return is_enabled_; } | 121 Breakpoint* AddPerClosure(Debugger* dbg, const Instance& closure); |
| 122 |
| 123 bool AnyEnabled() const; |
| 61 bool IsResolved() const { return is_resolved_; } | 124 bool IsResolved() const { return is_resolved_; } |
| 62 bool IsLatent() const { return token_pos_ < 0; } | 125 bool IsLatent() const { return token_pos_ < 0; } |
| 63 | 126 |
| 64 bool IsOneShot() const { return is_one_shot_; } | |
| 65 void SetIsOneShot() { is_one_shot_ = true; } | |
| 66 | |
| 67 void PrintJSON(JSONStream* stream); | |
| 68 | |
| 69 private: | 127 private: |
| 70 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 128 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 71 | 129 |
| 72 void SetResolved(const Function& func, intptr_t token_pos); | 130 void SetResolved(const Function& func, intptr_t token_pos); |
| 73 void set_next(SourceBreakpoint* value) { next_ = value; } | |
| 74 SourceBreakpoint* next() const { return this->next_; } | |
| 75 | 131 |
| 76 const intptr_t id_; | 132 BreakpointLocation* next() const { return this->next_; } |
| 133 void set_next(BreakpointLocation* value) { next_ = value; } |
| 134 |
| 135 void AddBreakpoint(Breakpoint* bpt, Debugger* dbg); |
| 136 |
| 137 Breakpoint* breakpoints() const { return this->conditions_; } |
| 138 void set_breakpoints(Breakpoint* head) { this->conditions_ = head; } |
| 139 |
| 77 RawScript* script_; | 140 RawScript* script_; |
| 78 RawString* url_; | 141 RawString* url_; |
| 79 intptr_t token_pos_; | 142 intptr_t token_pos_; |
| 80 intptr_t end_token_pos_; | 143 intptr_t end_token_pos_; |
| 81 bool is_resolved_; | 144 bool is_resolved_; |
| 82 bool is_enabled_; | 145 BreakpointLocation* next_; |
| 83 bool is_one_shot_; | 146 Breakpoint* conditions_; |
| 84 SourceBreakpoint* next_; | |
| 85 | 147 |
| 86 // Valid for resolved breakpoints: | 148 // Valid for resolved breakpoints: |
| 87 RawFunction* function_; | 149 RawFunction* function_; |
| 88 intptr_t line_number_; | 150 intptr_t line_number_; |
| 89 | 151 |
| 90 friend class Debugger; | 152 friend class Debugger; |
| 91 DISALLOW_COPY_AND_ASSIGN(SourceBreakpoint); | 153 DISALLOW_COPY_AND_ASSIGN(BreakpointLocation); |
| 92 }; | 154 }; |
| 93 | 155 |
| 94 | 156 |
| 95 // CodeBreakpoint represents a location in compiled code. There may be | 157 // CodeBreakpoint represents a location in compiled code. There may be |
| 96 // more than one CodeBreakpoint for one SourceBreakpoint, e.g. when a | 158 // more than one CodeBreakpoint for one BreakpointLocation, e.g. when a |
| 97 // function gets compiled as a regular function and as a closure. | 159 // function gets compiled as a regular function and as a closure. |
| 98 class CodeBreakpoint { | 160 class CodeBreakpoint { |
| 99 public: | 161 public: |
| 100 CodeBreakpoint(const Code& code, | 162 CodeBreakpoint(const Code& code, |
| 101 intptr_t token_pos, | 163 intptr_t token_pos, |
| 102 uword pc, | 164 uword pc, |
| 103 RawPcDescriptors::Kind kind); | 165 RawPcDescriptors::Kind kind); |
| 104 ~CodeBreakpoint(); | 166 ~CodeBreakpoint(); |
| 105 | 167 |
| 106 RawFunction* function() const; | 168 RawFunction* function() const; |
| 107 uword pc() const { return pc_; } | 169 uword pc() const { return pc_; } |
| 108 intptr_t token_pos() const { return token_pos_; } | 170 intptr_t token_pos() const { return token_pos_; } |
| 109 bool IsInternal() const { return src_bpt_ == NULL; } | 171 bool IsInternal() const { return bpt_location_ == NULL; } |
| 110 | 172 |
| 111 RawScript* SourceCode(); | 173 RawScript* SourceCode(); |
| 112 RawString* SourceUrl(); | 174 RawString* SourceUrl(); |
| 113 intptr_t LineNumber(); | 175 intptr_t LineNumber(); |
| 114 | 176 |
| 115 void Enable(); | 177 void Enable(); |
| 116 void Disable(); | 178 void Disable(); |
| 117 bool IsEnabled() const { return is_enabled_; } | 179 bool IsEnabled() const { return is_enabled_; } |
| 118 | 180 |
| 119 uword OrigStubAddress() const; | 181 uword OrigStubAddress() const; |
| 120 | 182 |
| 121 private: | 183 private: |
| 122 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 184 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 123 | 185 |
| 124 SourceBreakpoint* src_bpt() const { return src_bpt_; } | 186 BreakpointLocation* bpt_location() const { return bpt_location_; } |
| 125 void set_src_bpt(SourceBreakpoint* value) { src_bpt_ = value; } | 187 void set_bpt_location(BreakpointLocation* value) { bpt_location_ = value; } |
| 126 | 188 |
| 127 void set_next(CodeBreakpoint* value) { next_ = value; } | 189 void set_next(CodeBreakpoint* value) { next_ = value; } |
| 128 CodeBreakpoint* next() const { return this->next_; } | 190 CodeBreakpoint* next() const { return this->next_; } |
| 129 | 191 |
| 130 void PatchCode(); | 192 void PatchCode(); |
| 131 void RestoreCode(); | 193 void RestoreCode(); |
| 132 | 194 |
| 133 RawCode* code_; | 195 RawCode* code_; |
| 134 intptr_t token_pos_; | 196 intptr_t token_pos_; |
| 135 uword pc_; | 197 uword pc_; |
| 136 intptr_t line_number_; | 198 intptr_t line_number_; |
| 137 bool is_enabled_; | 199 bool is_enabled_; |
| 138 | 200 |
| 139 SourceBreakpoint* src_bpt_; | 201 BreakpointLocation* bpt_location_; |
| 140 CodeBreakpoint* next_; | 202 CodeBreakpoint* next_; |
| 141 | 203 |
| 142 RawPcDescriptors::Kind breakpoint_kind_; | 204 RawPcDescriptors::Kind breakpoint_kind_; |
| 143 uword saved_value_; | 205 uword saved_value_; |
| 144 | 206 |
| 145 friend class Debugger; | 207 friend class Debugger; |
| 146 DISALLOW_COPY_AND_ASSIGN(CodeBreakpoint); | 208 DISALLOW_COPY_AND_ASSIGN(CodeBreakpoint); |
| 147 }; | 209 }; |
| 148 | 210 |
| 149 | 211 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 249 |
| 188 intptr_t NumLocalVariables(); | 250 intptr_t NumLocalVariables(); |
| 189 | 251 |
| 190 void VariableAt(intptr_t i, | 252 void VariableAt(intptr_t i, |
| 191 String* name, | 253 String* name, |
| 192 intptr_t* token_pos, | 254 intptr_t* token_pos, |
| 193 intptr_t* end_pos, | 255 intptr_t* end_pos, |
| 194 Object* value); | 256 Object* value); |
| 195 | 257 |
| 196 RawArray* GetLocalVariables(); | 258 RawArray* GetLocalVariables(); |
| 259 RawObject* GetParameter(intptr_t index); |
| 260 RawObject* GetClosure(); |
| 197 RawObject* GetReceiver(); | 261 RawObject* GetReceiver(); |
| 198 | 262 |
| 199 const Context& GetSavedCurrentContext(); | 263 const Context& GetSavedCurrentContext(); |
| 200 | 264 |
| 201 RawObject* Evaluate(const String& expr); | 265 RawObject* Evaluate(const String& expr); |
| 202 | 266 |
| 203 // Print the activation frame into |jsobj|. if |full| is false, script | 267 // Print the activation frame into |jsobj|. if |full| is false, script |
| 204 // and local variable objects are only references. if |full| is true, | 268 // and local variable objects are only references. if |full| is true, |
| 205 // the complete script, function, and, local variable objects are included. | 269 // the complete script, function, and, local variable objects are included. |
| 206 void PrintToJSONObject(JSONObject* jsobj, bool full = false); | 270 void PrintToJSONObject(JSONObject* jsobj, bool full = false); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 330 |
| 267 private: | 331 private: |
| 268 void AddActivation(ActivationFrame* frame); | 332 void AddActivation(ActivationFrame* frame); |
| 269 ZoneGrowableArray<ActivationFrame*> trace_; | 333 ZoneGrowableArray<ActivationFrame*> trace_; |
| 270 | 334 |
| 271 friend class Debugger; | 335 friend class Debugger; |
| 272 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); | 336 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); |
| 273 }; | 337 }; |
| 274 | 338 |
| 275 | 339 |
| 276 typedef void BreakpointHandler(Dart_Port isolate_id, | |
| 277 SourceBreakpoint* bpt, | |
| 278 DebuggerStackTrace* stack); | |
| 279 | |
| 280 | |
| 281 class DebuggerEvent { | 340 class DebuggerEvent { |
| 282 public: | 341 public: |
| 283 enum EventType { | 342 enum EventType { |
| 284 kBreakpointReached = 1, | 343 kBreakpointReached = 1, |
| 285 kBreakpointResolved = 2, | 344 kBreakpointResolved = 2, |
| 286 kExceptionThrown = 3, | 345 kExceptionThrown = 3, |
| 287 kIsolateCreated = 4, | 346 kIsolateCreated = 4, |
| 288 kIsolateShutdown = 5, | 347 kIsolateShutdown = 5, |
| 289 kIsolateInterrupted = 6, | 348 kIsolateInterrupted = 6, |
| 290 }; | 349 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 308 | 367 |
| 309 ActivationFrame* top_frame() const { | 368 ActivationFrame* top_frame() const { |
| 310 ASSERT(IsPauseEvent()); | 369 ASSERT(IsPauseEvent()); |
| 311 return top_frame_; | 370 return top_frame_; |
| 312 } | 371 } |
| 313 void set_top_frame(ActivationFrame* frame) { | 372 void set_top_frame(ActivationFrame* frame) { |
| 314 ASSERT(IsPauseEvent()); | 373 ASSERT(IsPauseEvent()); |
| 315 top_frame_ = frame; | 374 top_frame_ = frame; |
| 316 } | 375 } |
| 317 | 376 |
| 318 SourceBreakpoint* breakpoint() const { | 377 Breakpoint* breakpoint() const { |
| 319 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); | 378 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); |
| 320 return breakpoint_; | 379 return breakpoint_; |
| 321 } | 380 } |
| 322 void set_breakpoint(SourceBreakpoint* bpt) { | 381 void set_breakpoint(Breakpoint* bpt) { |
| 323 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); | 382 ASSERT(type_ == kBreakpointReached || type_ == kBreakpointResolved); |
| 324 breakpoint_ = bpt; | 383 breakpoint_ = bpt; |
| 325 } | 384 } |
| 326 | 385 |
| 327 const Object* exception() const { | 386 const Object* exception() const { |
| 328 ASSERT(type_ == kExceptionThrown); | 387 ASSERT(type_ == kExceptionThrown); |
| 329 return exception_; | 388 return exception_; |
| 330 } | 389 } |
| 331 void set_exception(const Object* exception) { | 390 void set_exception(const Object* exception) { |
| 332 ASSERT(type_ == kExceptionThrown); | 391 ASSERT(type_ == kExceptionThrown); |
| 333 exception_ = exception; | 392 exception_ = exception; |
| 334 } | 393 } |
| 335 | 394 |
| 336 Dart_Port isolate_id() const { | 395 Dart_Port isolate_id() const { |
| 337 return isolate_->main_port(); | 396 return isolate_->main_port(); |
| 338 } | 397 } |
| 339 | 398 |
| 340 private: | 399 private: |
| 341 Isolate* isolate_; | 400 Isolate* isolate_; |
| 342 EventType type_; | 401 EventType type_; |
| 343 ActivationFrame* top_frame_; | 402 ActivationFrame* top_frame_; |
| 344 SourceBreakpoint* breakpoint_; | 403 Breakpoint* breakpoint_; |
| 345 const Object* exception_; | 404 const Object* exception_; |
| 346 }; | 405 }; |
| 347 | 406 |
| 348 | 407 |
| 349 class Debugger { | 408 class Debugger { |
| 350 public: | 409 public: |
| 351 typedef void EventHandler(DebuggerEvent* event); | 410 typedef void EventHandler(DebuggerEvent* event); |
| 352 | 411 |
| 353 Debugger(); | 412 Debugger(); |
| 354 ~Debugger(); | 413 ~Debugger(); |
| 355 | 414 |
| 356 void Initialize(Isolate* isolate); | 415 void Initialize(Isolate* isolate); |
| 357 void NotifyIsolateCreated(); | 416 void NotifyIsolateCreated(); |
| 358 void Shutdown(); | 417 void Shutdown(); |
| 359 | 418 |
| 360 void NotifyCompilation(const Function& func); | 419 void NotifyCompilation(const Function& func); |
| 361 void NotifyDoneLoading(); | 420 void NotifyDoneLoading(); |
| 362 | 421 |
| 363 RawFunction* ResolveFunction(const Library& library, | 422 RawFunction* ResolveFunction(const Library& library, |
| 364 const String& class_name, | 423 const String& class_name, |
| 365 const String& function_name); | 424 const String& function_name); |
| 366 | 425 |
| 367 // Set breakpoint at closest location to function entry. | 426 // Set breakpoint at closest location to function entry. |
| 368 SourceBreakpoint* SetBreakpointAtEntry(const Function& target_function); | 427 Breakpoint* SetBreakpointAtEntry(const Function& target_function, |
| 428 bool single_shot); |
| 429 Breakpoint* SetBreakpointAtActivation(const Instance& closure); |
| 369 | 430 |
| 370 // TODO(turnidge): script_url may no longer be specific enough. | 431 // TODO(turnidge): script_url may no longer be specific enough. |
| 371 SourceBreakpoint* SetBreakpointAtLine(const String& script_url, | 432 Breakpoint* SetBreakpointAtLine(const String& script_url, |
| 372 intptr_t line_number); | 433 intptr_t line_number); |
| 373 RawError* OneTimeBreakAtEntry(const Function& target_function); | 434 RawError* OneTimeBreakAtEntry(const Function& target_function); |
| 374 | 435 |
| 436 BreakpointLocation* BreakpointLocationAtLine(const String& script_url, |
| 437 intptr_t line_number); |
| 438 |
| 439 |
| 375 void RemoveBreakpoint(intptr_t bp_id); | 440 void RemoveBreakpoint(intptr_t bp_id); |
| 376 SourceBreakpoint* GetBreakpointById(intptr_t id); | 441 Breakpoint* GetBreakpointById(intptr_t id); |
| 377 | 442 |
| 378 void SetStepOver(); | 443 void SetStepOver(); |
| 379 void SetSingleStep(); | 444 void SetSingleStep(); |
| 380 void SetStepOut(); | 445 void SetStepOut(); |
| 381 bool IsStepping() const { return resume_action_ != kContinue; } | 446 bool IsStepping() const { return resume_action_ != kContinue; } |
| 382 | 447 |
| 383 bool IsPaused() const { return pause_event_ != NULL; } | 448 bool IsPaused() const { return pause_event_ != NULL; } |
| 384 | 449 |
| 385 // Indicates why the debugger is currently paused. If the debugger | 450 // Indicates why the debugger is currently paused. If the debugger |
| 386 // is not paused, this returns NULL. Note that the debugger can be | 451 // is not paused, this returns NULL. Note that the debugger can be |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 intptr_t start_pos, | 534 intptr_t start_pos, |
| 470 intptr_t end_pos, | 535 intptr_t end_pos, |
| 471 GrowableObjectArray* function_list); | 536 GrowableObjectArray* function_list); |
| 472 RawFunction* FindBestFit(const Script& script, intptr_t token_pos); | 537 RawFunction* FindBestFit(const Script& script, intptr_t token_pos); |
| 473 RawFunction* FindInnermostClosure(const Function& function, | 538 RawFunction* FindInnermostClosure(const Function& function, |
| 474 intptr_t token_pos); | 539 intptr_t token_pos); |
| 475 intptr_t ResolveBreakpointPos(const Function& func, | 540 intptr_t ResolveBreakpointPos(const Function& func, |
| 476 intptr_t requested_token_pos, | 541 intptr_t requested_token_pos, |
| 477 intptr_t last_token_pos); | 542 intptr_t last_token_pos); |
| 478 void DeoptimizeWorld(); | 543 void DeoptimizeWorld(); |
| 479 SourceBreakpoint* SetBreakpoint(const Script& script, | 544 BreakpointLocation* SetBreakpoint(const Script& script, |
| 480 intptr_t token_pos, | 545 intptr_t token_pos, |
| 481 intptr_t last_token_pos); | 546 intptr_t last_token_pos); |
| 482 void RemoveInternalBreakpoints(); | 547 void RemoveInternalBreakpoints(); |
| 483 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); | 548 void UnlinkCodeBreakpoints(BreakpointLocation* bpt_location); |
| 484 SourceBreakpoint* GetLatentBreakpoint(const String& url, intptr_t line); | 549 BreakpointLocation* GetLatentBreakpoint(const String& url, intptr_t line); |
| 485 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); | 550 void RegisterBreakpointLocation(BreakpointLocation* bpt); |
| 486 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); | 551 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); |
| 487 SourceBreakpoint* GetSourceBreakpoint(const Script& script, | 552 BreakpointLocation* GetBreakpointLocation(const Script& script, |
| 488 intptr_t token_pos); | 553 intptr_t token_pos); |
| 489 void MakeCodeBreakpointAt(const Function& func, | 554 void MakeCodeBreakpointAt(const Function& func, |
| 490 SourceBreakpoint* bpt); | 555 BreakpointLocation* bpt); |
| 491 // Returns NULL if no breakpoint exists for the given address. | 556 // Returns NULL if no breakpoint exists for the given address. |
| 492 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 557 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
| 493 | 558 |
| 494 void SyncBreakpoint(SourceBreakpoint* bpt); | 559 void SyncBreakpointLocation(BreakpointLocation* loc); |
| 495 | 560 |
| 496 ActivationFrame* TopDartFrame() const; | 561 ActivationFrame* TopDartFrame() const; |
| 497 static ActivationFrame* CollectDartFrame(Isolate* isolate, | 562 static ActivationFrame* CollectDartFrame(Isolate* isolate, |
| 498 uword pc, | 563 uword pc, |
| 499 StackFrame* frame, | 564 StackFrame* frame, |
| 500 const Code& code, | 565 const Code& code, |
| 501 const Array& deopt_frame, | 566 const Array& deopt_frame, |
| 502 intptr_t deopt_frame_offset); | 567 intptr_t deopt_frame_offset); |
| 503 static RawArray* DeoptimizeToArray(Isolate* isolate, | 568 static RawArray* DeoptimizeToArray(Isolate* isolate, |
| 504 StackFrame* frame, | 569 StackFrame* frame, |
| 505 const Code& code); | 570 const Code& code); |
| 506 static DebuggerStackTrace* CollectStackTrace(); | 571 static DebuggerStackTrace* CollectStackTrace(); |
| 507 void SignalBpResolved(SourceBreakpoint *bpt); | 572 void SignalBpResolved(Breakpoint *bpt); |
| 508 void SignalPausedEvent(ActivationFrame* top_frame, | 573 void SignalPausedEvent(ActivationFrame* top_frame, |
| 509 SourceBreakpoint* bpt); | 574 Breakpoint* bpt); |
| 510 | 575 |
| 511 intptr_t nextId() { return next_id_++; } | 576 intptr_t nextId() { return next_id_++; } |
| 512 | 577 |
| 513 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, | 578 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, |
| 514 const Instance& exc); | 579 const Instance& exc); |
| 515 | 580 |
| 516 void CollectLibraryFields(const GrowableObjectArray& field_list, | 581 void CollectLibraryFields(const GrowableObjectArray& field_list, |
| 517 const Library& lib, | 582 const Library& lib, |
| 518 const String& prefix, | 583 const String& prefix, |
| 519 bool include_private_fields); | 584 bool include_private_fields); |
| 520 | 585 |
| 521 // Handles any events which pause vm execution. Breakpoints, | 586 // Handles any events which pause vm execution. Breakpoints, |
| 522 // interrupts, etc. | 587 // interrupts, etc. |
| 523 void Pause(DebuggerEvent* event); | 588 void Pause(DebuggerEvent* event); |
| 524 | 589 |
| 525 void HandleSteppingRequest(DebuggerStackTrace* stack_trace); | 590 void HandleSteppingRequest(DebuggerStackTrace* stack_trace); |
| 526 | 591 |
| 527 Isolate* isolate_; | 592 Isolate* isolate_; |
| 528 Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. | 593 Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. |
| 529 bool initialized_; | 594 bool initialized_; |
| 530 | 595 |
| 531 // ID number generator. | 596 // ID number generator. |
| 532 intptr_t next_id_; | 597 intptr_t next_id_; |
| 533 | 598 |
| 534 SourceBreakpoint* latent_breakpoints_; | 599 BreakpointLocation* latent_locations_; |
| 535 SourceBreakpoint* src_breakpoints_; | 600 BreakpointLocation* breakpoint_locations_; |
| 536 CodeBreakpoint* code_breakpoints_; | 601 CodeBreakpoint* code_breakpoints_; |
| 537 | 602 |
| 538 // Tells debugger what to do when resuming execution after a breakpoint. | 603 // Tells debugger what to do when resuming execution after a breakpoint. |
| 539 ResumeAction resume_action_; | 604 ResumeAction resume_action_; |
| 540 | 605 |
| 541 // Do not call back to breakpoint handler if this flag is set. | 606 // Do not call back to breakpoint handler if this flag is set. |
| 542 // Effectively this means ignoring breakpoints. Set when Dart code may | 607 // Effectively this means ignoring breakpoints. Set when Dart code may |
| 543 // be run as a side effect of getting values of fields. | 608 // be run as a side effect of getting values of fields. |
| 544 bool ignore_breakpoints_; | 609 bool ignore_breakpoints_; |
| 545 | 610 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 558 // When stepping through code, only pause the program if the top | 623 // When stepping through code, only pause the program if the top |
| 559 // frame corresponds to this fp value, or if the top frame is | 624 // frame corresponds to this fp value, or if the top frame is |
| 560 // lower on the stack. | 625 // lower on the stack. |
| 561 uword stepping_fp_; | 626 uword stepping_fp_; |
| 562 | 627 |
| 563 Dart_ExceptionPauseInfo exc_pause_info_; | 628 Dart_ExceptionPauseInfo exc_pause_info_; |
| 564 | 629 |
| 565 static EventHandler* event_handler_; | 630 static EventHandler* event_handler_; |
| 566 | 631 |
| 567 friend class Isolate; | 632 friend class Isolate; |
| 568 friend class SourceBreakpoint; | 633 friend class BreakpointLocation; |
| 569 DISALLOW_COPY_AND_ASSIGN(Debugger); | 634 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 570 }; | 635 }; |
| 571 | 636 |
| 572 | 637 |
| 573 } // namespace dart | 638 } // namespace dart |
| 574 | 639 |
| 575 #endif // VM_DEBUGGER_H_ | 640 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |