| 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 ActiveVariables; | 15 class ActiveVariables; |
| 16 class CodeBreakpoint; | 16 class CodeBreakpoint; |
| 17 class Isolate; | 17 class Isolate; |
| 18 class JSONArray; | 18 class JSONArray; |
| 19 class JSONStream; | 19 class JSONStream; |
| 20 class ObjectPointerVisitor; | 20 class ObjectPointerVisitor; |
| 21 class RemoteObjectCache; | 21 class RemoteObjectCache; |
| 22 class SourceBreakpoint; | 22 class SourceBreakpoint; |
| 23 class StackFrame; | 23 class StackFrame; |
| 24 | 24 |
| 25 // SourceBreakpoint represents a user-specified breakpoint location in | 25 // SourceBreakpoint represents a user-specified breakpoint location in |
| 26 // Dart source. There may be more than one CodeBreakpoint object per | 26 // Dart source. There may be more than one CodeBreakpoint object per |
| 27 // SourceBreakpoint. | 27 // SourceBreakpoint. |
| 28 // An unresolved breakpoint is one where the underlying code has not |
| 29 // been compiled yet. Since the code has not been compiled, we don't know |
| 30 // the definitive source location yet. The requested source location may |
| 31 // change when the underlying code gets compiled. |
| 32 // A latent breakpoint represents a breakpoint location in Dart source |
| 33 // that is not loaded in the VM when the breakpoint is requested. |
| 34 // When a script with matching url is loaded, a latent breakpoint |
| 35 // becomes an unresolved breakpoint. |
| 28 class SourceBreakpoint { | 36 class SourceBreakpoint { |
| 29 public: | 37 public: |
| 38 // Create a new unresolved breakpoint. |
| 30 SourceBreakpoint(intptr_t id, | 39 SourceBreakpoint(intptr_t id, |
| 31 const Script& script, | 40 const Script& script, |
| 32 intptr_t token_pos, | 41 intptr_t token_pos, |
| 33 intptr_t end_token_pos); | 42 intptr_t end_token_pos); |
| 43 // Create a new latent breakpoint. |
| 44 SourceBreakpoint(intptr_t id, |
| 45 const String& url, |
| 46 intptr_t line_number); |
| 34 | 47 |
| 35 RawFunction* function() const { return function_; } | 48 RawFunction* function() const { return function_; } |
| 36 intptr_t token_pos() const { return token_pos_; } | 49 intptr_t token_pos() const { return token_pos_; } |
| 37 intptr_t end_token_pos() const { return end_token_pos_; } | 50 intptr_t end_token_pos() const { return end_token_pos_; } |
| 38 intptr_t id() const { return id_; } | 51 intptr_t id() const { return id_; } |
| 39 | 52 |
| 40 RawScript* script() const { return script_; } | 53 RawScript* script() const { return script_; } |
| 41 RawString* SourceUrl(); | 54 RawString* url() const { return url_; } |
| 42 intptr_t LineNumber(); | 55 intptr_t LineNumber(); |
| 43 | 56 |
| 44 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); | 57 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); |
| 45 | 58 |
| 46 void Enable(); | 59 void Enable(); |
| 47 void Disable(); | 60 void Disable(); |
| 48 bool IsEnabled() const { return is_enabled_; } | 61 bool IsEnabled() const { return is_enabled_; } |
| 49 bool IsResolved() const { return is_resolved_; } | 62 bool IsResolved() const { return is_resolved_; } |
| 63 bool IsLatent() const { return token_pos_ < 0; } |
| 50 | 64 |
| 51 bool IsOneShot() const { return is_one_shot_; } | 65 bool IsOneShot() const { return is_one_shot_; } |
| 52 void SetIsOneShot() { is_one_shot_ = true; } | 66 void SetIsOneShot() { is_one_shot_ = true; } |
| 53 | 67 |
| 54 void PrintJSON(JSONStream* stream); | 68 void PrintJSON(JSONStream* stream); |
| 55 | 69 |
| 56 private: | 70 private: |
| 57 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 71 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 58 | 72 |
| 59 void SetResolved(const Function& func, intptr_t token_pos); | 73 void SetResolved(const Function& func, intptr_t token_pos); |
| 60 void set_next(SourceBreakpoint* value) { next_ = value; } | 74 void set_next(SourceBreakpoint* value) { next_ = value; } |
| 61 SourceBreakpoint* next() const { return this->next_; } | 75 SourceBreakpoint* next() const { return this->next_; } |
| 62 | 76 |
| 63 const intptr_t id_; | 77 const intptr_t id_; |
| 64 RawScript* script_; | 78 RawScript* script_; |
| 79 RawString* url_; |
| 65 intptr_t token_pos_; | 80 intptr_t token_pos_; |
| 66 intptr_t end_token_pos_; | 81 intptr_t end_token_pos_; |
| 67 bool is_resolved_; | 82 bool is_resolved_; |
| 68 bool is_enabled_; | 83 bool is_enabled_; |
| 69 bool is_one_shot_; | 84 bool is_one_shot_; |
| 70 SourceBreakpoint* next_; | 85 SourceBreakpoint* next_; |
| 71 | 86 |
| 72 // Valid for resolved breakpoints: | 87 // Valid for resolved breakpoints: |
| 73 RawFunction* function_; | 88 RawFunction* function_; |
| 74 intptr_t line_number_; | 89 intptr_t line_number_; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 typedef void EventHandler(DebuggerEvent* event); | 350 typedef void EventHandler(DebuggerEvent* event); |
| 336 | 351 |
| 337 Debugger(); | 352 Debugger(); |
| 338 ~Debugger(); | 353 ~Debugger(); |
| 339 | 354 |
| 340 void Initialize(Isolate* isolate); | 355 void Initialize(Isolate* isolate); |
| 341 void NotifyIsolateCreated(); | 356 void NotifyIsolateCreated(); |
| 342 void Shutdown(); | 357 void Shutdown(); |
| 343 | 358 |
| 344 void NotifyCompilation(const Function& func); | 359 void NotifyCompilation(const Function& func); |
| 360 void NotifyDoneLoading(); |
| 345 | 361 |
| 346 RawFunction* ResolveFunction(const Library& library, | 362 RawFunction* ResolveFunction(const Library& library, |
| 347 const String& class_name, | 363 const String& class_name, |
| 348 const String& function_name); | 364 const String& function_name); |
| 349 | 365 |
| 350 // Set breakpoint at closest location to function entry. | 366 // Set breakpoint at closest location to function entry. |
| 351 SourceBreakpoint* SetBreakpointAtEntry(const Function& target_function); | 367 SourceBreakpoint* SetBreakpointAtEntry(const Function& target_function); |
| 352 | 368 |
| 353 // TODO(turnidge): script_url may no longer be specific enough. | 369 // TODO(turnidge): script_url may no longer be specific enough. |
| 354 SourceBreakpoint* SetBreakpointAtLine(const String& script_url, | 370 SourceBreakpoint* SetBreakpointAtLine(const String& script_url, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 intptr_t token_pos); | 471 intptr_t token_pos); |
| 456 intptr_t ResolveBreakpointPos(const Function& func, | 472 intptr_t ResolveBreakpointPos(const Function& func, |
| 457 intptr_t requested_token_pos, | 473 intptr_t requested_token_pos, |
| 458 intptr_t last_token_pos); | 474 intptr_t last_token_pos); |
| 459 void DeoptimizeWorld(); | 475 void DeoptimizeWorld(); |
| 460 SourceBreakpoint* SetBreakpoint(const Script& script, | 476 SourceBreakpoint* SetBreakpoint(const Script& script, |
| 461 intptr_t token_pos, | 477 intptr_t token_pos, |
| 462 intptr_t last_token_pos); | 478 intptr_t last_token_pos); |
| 463 void RemoveInternalBreakpoints(); | 479 void RemoveInternalBreakpoints(); |
| 464 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); | 480 void UnlinkCodeBreakpoints(SourceBreakpoint* src_bpt); |
| 481 SourceBreakpoint* GetLatentBreakpoint(const String& url, intptr_t line); |
| 465 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); | 482 void RegisterSourceBreakpoint(SourceBreakpoint* bpt); |
| 466 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); | 483 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); |
| 467 SourceBreakpoint* GetSourceBreakpoint(const Script& script, | 484 SourceBreakpoint* GetSourceBreakpoint(const Script& script, |
| 468 intptr_t token_pos); | 485 intptr_t token_pos); |
| 469 void MakeCodeBreakpointAt(const Function& func, | 486 void MakeCodeBreakpointAt(const Function& func, |
| 470 SourceBreakpoint* bpt); | 487 SourceBreakpoint* bpt); |
| 471 // Returns NULL if no breakpoint exists for the given address. | 488 // Returns NULL if no breakpoint exists for the given address. |
| 472 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 489 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
| 473 | 490 |
| 474 void SyncBreakpoint(SourceBreakpoint* bpt); | 491 void SyncBreakpoint(SourceBreakpoint* bpt); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 504 | 521 |
| 505 void HandleSteppingRequest(DebuggerStackTrace* stack_trace); | 522 void HandleSteppingRequest(DebuggerStackTrace* stack_trace); |
| 506 | 523 |
| 507 Isolate* isolate_; | 524 Isolate* isolate_; |
| 508 Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. | 525 Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. |
| 509 bool initialized_; | 526 bool initialized_; |
| 510 | 527 |
| 511 // ID number generator. | 528 // ID number generator. |
| 512 intptr_t next_id_; | 529 intptr_t next_id_; |
| 513 | 530 |
| 514 | 531 SourceBreakpoint* latent_breakpoints_; |
| 515 SourceBreakpoint* src_breakpoints_; | 532 SourceBreakpoint* src_breakpoints_; |
| 516 CodeBreakpoint* code_breakpoints_; | 533 CodeBreakpoint* code_breakpoints_; |
| 517 | 534 |
| 518 // Tells debugger what to do when resuming execution after a breakpoint. | 535 // Tells debugger what to do when resuming execution after a breakpoint. |
| 519 ResumeAction resume_action_; | 536 ResumeAction resume_action_; |
| 520 | 537 |
| 521 // Do not call back to breakpoint handler if this flag is set. | 538 // Do not call back to breakpoint handler if this flag is set. |
| 522 // Effectively this means ignoring breakpoints. Set when Dart code may | 539 // Effectively this means ignoring breakpoints. Set when Dart code may |
| 523 // be run as a side effect of getting values of fields. | 540 // be run as a side effect of getting values of fields. |
| 524 bool ignore_breakpoints_; | 541 bool ignore_breakpoints_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 546 | 563 |
| 547 friend class Isolate; | 564 friend class Isolate; |
| 548 friend class SourceBreakpoint; | 565 friend class SourceBreakpoint; |
| 549 DISALLOW_COPY_AND_ASSIGN(Debugger); | 566 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 550 }; | 567 }; |
| 551 | 568 |
| 552 | 569 |
| 553 } // namespace dart | 570 } // namespace dart |
| 554 | 571 |
| 555 #endif // VM_DEBUGGER_H_ | 572 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |