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_tools_api.h" | 8 #include "include/dart_tools_api.h" |
9 | 9 |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // change when the underlying code gets compiled. | 92 // change when the underlying code gets compiled. |
93 // A latent breakpoint represents a breakpoint location in Dart source | 93 // A latent breakpoint represents a breakpoint location in Dart source |
94 // 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. |
95 // When a script with matching url is loaded, a latent breakpoint | 95 // When a script with matching url is loaded, a latent breakpoint |
96 // becomes an unresolved breakpoint. | 96 // becomes an unresolved breakpoint. |
97 class BreakpointLocation { | 97 class BreakpointLocation { |
98 public: | 98 public: |
99 // Create a new unresolved breakpoint. | 99 // Create a new unresolved breakpoint. |
100 BreakpointLocation(const Script& script, | 100 BreakpointLocation(const Script& script, |
101 intptr_t token_pos, | 101 intptr_t token_pos, |
102 intptr_t end_token_pos); | 102 intptr_t end_token_pos, |
| 103 intptr_t requested_line_number, |
| 104 intptr_t requested_column_number); |
103 // Create a new latent breakpoint. | 105 // Create a new latent breakpoint. |
104 BreakpointLocation(const String& url, | 106 BreakpointLocation(const String& url, |
105 intptr_t line_number); | 107 intptr_t requested_line_number, |
| 108 intptr_t requested_column_number); |
106 | 109 |
107 ~BreakpointLocation(); | 110 ~BreakpointLocation(); |
108 | 111 |
109 RawFunction* function() const { return function_; } | 112 RawFunction* function() const { return function_; } |
110 intptr_t token_pos() const { return token_pos_; } | 113 intptr_t token_pos() const { return token_pos_; } |
111 intptr_t end_token_pos() const { return end_token_pos_; } | 114 intptr_t end_token_pos() const { return end_token_pos_; } |
112 | 115 |
113 RawScript* script() const { return script_; } | 116 RawScript* script() const { return script_; } |
114 RawString* url() const { return url_; } | 117 RawString* url() const { return url_; } |
| 118 |
| 119 intptr_t requested_line_number() const { return requested_line_number_; } |
| 120 intptr_t requested_column_number() const { return requested_column_number_; } |
| 121 |
115 intptr_t LineNumber(); | 122 intptr_t LineNumber(); |
| 123 intptr_t ColumnNumber(); |
116 | 124 |
117 void GetCodeLocation(Library* lib, Script* script, intptr_t* token_pos); | 125 void GetCodeLocation(Library* lib, |
| 126 Script* script, |
| 127 intptr_t* token_pos) const; |
118 | 128 |
119 Breakpoint* AddRepeated(Debugger* dbg); | 129 Breakpoint* AddRepeated(Debugger* dbg); |
120 Breakpoint* AddSingleShot(Debugger* dbg); | 130 Breakpoint* AddSingleShot(Debugger* dbg); |
121 Breakpoint* AddPerClosure(Debugger* dbg, const Instance& closure); | 131 Breakpoint* AddPerClosure(Debugger* dbg, const Instance& closure); |
122 | 132 |
123 bool AnyEnabled() const; | 133 bool AnyEnabled() const; |
124 bool IsResolved() const { return is_resolved_; } | 134 bool IsResolved() const { return is_resolved_; } |
125 bool IsLatent() const { return token_pos_ < 0; } | 135 bool IsLatent() const { return token_pos_ < 0; } |
126 | 136 |
127 private: | 137 private: |
128 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 138 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
129 | 139 |
130 void SetResolved(const Function& func, intptr_t token_pos); | 140 void SetResolved(const Function& func, intptr_t token_pos); |
131 | 141 |
132 BreakpointLocation* next() const { return this->next_; } | 142 BreakpointLocation* next() const { return this->next_; } |
133 void set_next(BreakpointLocation* value) { next_ = value; } | 143 void set_next(BreakpointLocation* value) { next_ = value; } |
134 | 144 |
135 void AddBreakpoint(Breakpoint* bpt, Debugger* dbg); | 145 void AddBreakpoint(Breakpoint* bpt, Debugger* dbg); |
136 | 146 |
137 Breakpoint* breakpoints() const { return this->conditions_; } | 147 Breakpoint* breakpoints() const { return this->conditions_; } |
138 void set_breakpoints(Breakpoint* head) { this->conditions_ = head; } | 148 void set_breakpoints(Breakpoint* head) { this->conditions_ = head; } |
139 | 149 |
140 RawScript* script_; | 150 RawScript* script_; |
141 RawString* url_; | 151 RawString* url_; |
142 intptr_t token_pos_; | 152 intptr_t token_pos_; |
143 intptr_t end_token_pos_; | 153 intptr_t end_token_pos_; |
144 bool is_resolved_; | 154 bool is_resolved_; |
145 BreakpointLocation* next_; | 155 BreakpointLocation* next_; |
146 Breakpoint* conditions_; | 156 Breakpoint* conditions_; |
| 157 intptr_t requested_line_number_; |
| 158 intptr_t requested_column_number_; |
147 | 159 |
148 // Valid for resolved breakpoints: | 160 // Valid for resolved breakpoints: |
149 RawFunction* function_; | 161 RawFunction* function_; |
150 intptr_t line_number_; | 162 intptr_t line_number_; |
| 163 intptr_t column_number_; |
151 | 164 |
152 friend class Debugger; | 165 friend class Debugger; |
153 DISALLOW_COPY_AND_ASSIGN(BreakpointLocation); | 166 DISALLOW_COPY_AND_ASSIGN(BreakpointLocation); |
154 }; | 167 }; |
155 | 168 |
156 | 169 |
157 // CodeBreakpoint represents a location in compiled code. There may be | 170 // CodeBreakpoint represents a location in compiled code. There may be |
158 // more than one CodeBreakpoint for one BreakpointLocation, e.g. when a | 171 // more than one CodeBreakpoint for one BreakpointLocation, e.g. when a |
159 // function gets compiled as a regular function and as a closure. | 172 // function gets compiled as a regular function and as a closure. |
160 class CodeBreakpoint { | 173 class CodeBreakpoint { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 466 |
454 // Set breakpoint at closest location to function entry. | 467 // Set breakpoint at closest location to function entry. |
455 Breakpoint* SetBreakpointAtEntry(const Function& target_function, | 468 Breakpoint* SetBreakpointAtEntry(const Function& target_function, |
456 bool single_shot); | 469 bool single_shot); |
457 Breakpoint* SetBreakpointAtActivation(const Instance& closure); | 470 Breakpoint* SetBreakpointAtActivation(const Instance& closure); |
458 Breakpoint* BreakpointAtActivation(const Instance& closure); | 471 Breakpoint* BreakpointAtActivation(const Instance& closure); |
459 | 472 |
460 // TODO(turnidge): script_url may no longer be specific enough. | 473 // TODO(turnidge): script_url may no longer be specific enough. |
461 Breakpoint* SetBreakpointAtLine(const String& script_url, | 474 Breakpoint* SetBreakpointAtLine(const String& script_url, |
462 intptr_t line_number); | 475 intptr_t line_number); |
| 476 Breakpoint* SetBreakpointAtLineCol(const String& script_url, |
| 477 intptr_t line_number, |
| 478 intptr_t column_number); |
463 RawError* OneTimeBreakAtEntry(const Function& target_function); | 479 RawError* OneTimeBreakAtEntry(const Function& target_function); |
464 | 480 |
465 BreakpointLocation* BreakpointLocationAtLine(const String& script_url, | 481 BreakpointLocation* BreakpointLocationAtLineCol(const String& script_url, |
466 intptr_t line_number); | 482 intptr_t line_number, |
| 483 intptr_t column_number); |
467 | 484 |
468 | 485 |
469 void RemoveBreakpoint(intptr_t bp_id); | 486 void RemoveBreakpoint(intptr_t bp_id); |
470 Breakpoint* GetBreakpointById(intptr_t id); | 487 Breakpoint* GetBreakpointById(intptr_t id); |
471 | 488 |
472 void SetStepOver(); | 489 void SetStepOver(); |
473 void SetSingleStep(); | 490 void SetSingleStep(); |
474 void SetStepOut(); | 491 void SetStepOut(); |
475 bool IsStepping() const { return resume_action_ != kContinue; } | 492 bool IsStepping() const { return resume_action_ != kContinue; } |
476 | 493 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 585 |
569 void FindCompiledFunctions(const Script& script, | 586 void FindCompiledFunctions(const Script& script, |
570 intptr_t start_pos, | 587 intptr_t start_pos, |
571 intptr_t end_pos, | 588 intptr_t end_pos, |
572 GrowableObjectArray* function_list); | 589 GrowableObjectArray* function_list); |
573 RawFunction* FindBestFit(const Script& script, intptr_t token_pos); | 590 RawFunction* FindBestFit(const Script& script, intptr_t token_pos); |
574 RawFunction* FindInnermostClosure(const Function& function, | 591 RawFunction* FindInnermostClosure(const Function& function, |
575 intptr_t token_pos); | 592 intptr_t token_pos); |
576 intptr_t ResolveBreakpointPos(const Function& func, | 593 intptr_t ResolveBreakpointPos(const Function& func, |
577 intptr_t requested_token_pos, | 594 intptr_t requested_token_pos, |
578 intptr_t last_token_pos); | 595 intptr_t last_token_pos, |
| 596 intptr_t requested_column); |
579 void DeoptimizeWorld(); | 597 void DeoptimizeWorld(); |
580 BreakpointLocation* SetBreakpoint(const Script& script, | 598 BreakpointLocation* SetBreakpoint(const Script& script, |
581 intptr_t token_pos, | 599 intptr_t token_pos, |
582 intptr_t last_token_pos); | 600 intptr_t last_token_pos, |
| 601 intptr_t requested_line, |
| 602 intptr_t requested_column); |
583 void RemoveInternalBreakpoints(); | 603 void RemoveInternalBreakpoints(); |
584 void UnlinkCodeBreakpoints(BreakpointLocation* bpt_location); | 604 void UnlinkCodeBreakpoints(BreakpointLocation* bpt_location); |
585 BreakpointLocation* GetLatentBreakpoint(const String& url, intptr_t line); | 605 BreakpointLocation* GetLatentBreakpoint(const String& url, |
| 606 intptr_t line, |
| 607 intptr_t column); |
586 void RegisterBreakpointLocation(BreakpointLocation* bpt); | 608 void RegisterBreakpointLocation(BreakpointLocation* bpt); |
587 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); | 609 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); |
588 BreakpointLocation* GetBreakpointLocation(const Script& script, | 610 BreakpointLocation* GetBreakpointLocation(const Script& script, |
589 intptr_t token_pos); | 611 intptr_t token_pos, |
| 612 intptr_t requested_column); |
590 void MakeCodeBreakpointAt(const Function& func, | 613 void MakeCodeBreakpointAt(const Function& func, |
591 BreakpointLocation* bpt); | 614 BreakpointLocation* bpt); |
592 // Returns NULL if no breakpoint exists for the given address. | 615 // Returns NULL if no breakpoint exists for the given address. |
593 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 616 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
594 | 617 |
595 void SyncBreakpointLocation(BreakpointLocation* loc); | 618 void SyncBreakpointLocation(BreakpointLocation* loc); |
596 | 619 |
597 ActivationFrame* TopDartFrame() const; | 620 ActivationFrame* TopDartFrame() const; |
598 static ActivationFrame* CollectDartFrame(Isolate* isolate, | 621 static ActivationFrame* CollectDartFrame(Isolate* isolate, |
599 uword pc, | 622 uword pc, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 690 |
668 friend class Isolate; | 691 friend class Isolate; |
669 friend class BreakpointLocation; | 692 friend class BreakpointLocation; |
670 DISALLOW_COPY_AND_ASSIGN(Debugger); | 693 DISALLOW_COPY_AND_ASSIGN(Debugger); |
671 }; | 694 }; |
672 | 695 |
673 | 696 |
674 } // namespace dart | 697 } // namespace dart |
675 | 698 |
676 #endif // VM_DEBUGGER_H_ | 699 #endif // VM_DEBUGGER_H_ |
OLD | NEW |