| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // the definitive source location yet. The requested source location may | 91 // the definitive source location yet. The requested source location may |
| 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 TokenDescriptor token_pos, |
| 102 intptr_t end_token_pos, | 102 TokenDescriptor end_token_pos, |
| 103 intptr_t requested_line_number, | 103 intptr_t requested_line_number, |
| 104 intptr_t requested_column_number); | 104 intptr_t requested_column_number); |
| 105 // Create a new latent breakpoint. | 105 // Create a new latent breakpoint. |
| 106 BreakpointLocation(const String& url, | 106 BreakpointLocation(const String& url, |
| 107 intptr_t requested_line_number, | 107 intptr_t requested_line_number, |
| 108 intptr_t requested_column_number); | 108 intptr_t requested_column_number); |
| 109 | 109 |
| 110 ~BreakpointLocation(); | 110 ~BreakpointLocation(); |
| 111 | 111 |
| 112 RawFunction* function() const { return function_; } | 112 RawFunction* function() const { return function_; } |
| 113 intptr_t token_pos() const { return token_pos_; } | 113 TokenDescriptor token_pos() const { return token_pos_; } |
| 114 intptr_t end_token_pos() const { return end_token_pos_; } | 114 TokenDescriptor end_token_pos() const { return end_token_pos_; } |
| 115 | 115 |
| 116 RawScript* script() const { return script_; } | 116 RawScript* script() const { return script_; } |
| 117 RawString* url() const { return url_; } | 117 RawString* url() const { return url_; } |
| 118 | 118 |
| 119 intptr_t requested_line_number() const { return requested_line_number_; } | 119 intptr_t requested_line_number() const { return requested_line_number_; } |
| 120 intptr_t requested_column_number() const { return requested_column_number_; } | 120 intptr_t requested_column_number() const { return requested_column_number_; } |
| 121 | 121 |
| 122 intptr_t LineNumber(); | 122 intptr_t LineNumber(); |
| 123 intptr_t ColumnNumber(); | 123 intptr_t ColumnNumber(); |
| 124 | 124 |
| 125 void GetCodeLocation(Library* lib, | 125 void GetCodeLocation(Library* lib, |
| 126 Script* script, | 126 Script* script, |
| 127 intptr_t* token_pos) const; | 127 TokenDescriptor* token_pos) const; |
| 128 | 128 |
| 129 Breakpoint* AddRepeated(Debugger* dbg); | 129 Breakpoint* AddRepeated(Debugger* dbg); |
| 130 Breakpoint* AddSingleShot(Debugger* dbg); | 130 Breakpoint* AddSingleShot(Debugger* dbg); |
| 131 Breakpoint* AddPerClosure(Debugger* dbg, const Instance& closure); | 131 Breakpoint* AddPerClosure(Debugger* dbg, const Instance& closure); |
| 132 | 132 |
| 133 bool AnyEnabled() const; | 133 bool AnyEnabled() const; |
| 134 bool IsResolved() const { return is_resolved_; } | 134 bool IsResolved() const { return is_resolved_; } |
| 135 bool IsLatent() const { return token_pos_ < 0; } | 135 bool IsLatent() const { return !token_pos_.IsReal(); } |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 138 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 139 | 139 |
| 140 void SetResolved(const Function& func, intptr_t token_pos); | 140 void SetResolved(const Function& func, TokenDescriptor token_pos); |
| 141 | 141 |
| 142 BreakpointLocation* next() const { return this->next_; } | 142 BreakpointLocation* next() const { return this->next_; } |
| 143 void set_next(BreakpointLocation* value) { next_ = value; } | 143 void set_next(BreakpointLocation* value) { next_ = value; } |
| 144 | 144 |
| 145 void AddBreakpoint(Breakpoint* bpt, Debugger* dbg); | 145 void AddBreakpoint(Breakpoint* bpt, Debugger* dbg); |
| 146 | 146 |
| 147 Breakpoint* breakpoints() const { return this->conditions_; } | 147 Breakpoint* breakpoints() const { return this->conditions_; } |
| 148 void set_breakpoints(Breakpoint* head) { this->conditions_ = head; } | 148 void set_breakpoints(Breakpoint* head) { this->conditions_ = head; } |
| 149 | 149 |
| 150 RawScript* script_; | 150 RawScript* script_; |
| 151 RawString* url_; | 151 RawString* url_; |
| 152 intptr_t token_pos_; | 152 TokenDescriptor token_pos_; |
| 153 intptr_t end_token_pos_; | 153 TokenDescriptor end_token_pos_; |
| 154 bool is_resolved_; | 154 bool is_resolved_; |
| 155 BreakpointLocation* next_; | 155 BreakpointLocation* next_; |
| 156 Breakpoint* conditions_; | 156 Breakpoint* conditions_; |
| 157 intptr_t requested_line_number_; | 157 intptr_t requested_line_number_; |
| 158 intptr_t requested_column_number_; | 158 intptr_t requested_column_number_; |
| 159 | 159 |
| 160 // Valid for resolved breakpoints: | 160 // Valid for resolved breakpoints: |
| 161 RawFunction* function_; | 161 RawFunction* function_; |
| 162 intptr_t line_number_; | 162 intptr_t line_number_; |
| 163 intptr_t column_number_; | 163 intptr_t column_number_; |
| 164 | 164 |
| 165 friend class Debugger; | 165 friend class Debugger; |
| 166 DISALLOW_COPY_AND_ASSIGN(BreakpointLocation); | 166 DISALLOW_COPY_AND_ASSIGN(BreakpointLocation); |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 | 169 |
| 170 // CodeBreakpoint represents a location in compiled code. There may be | 170 // CodeBreakpoint represents a location in compiled code. There may be |
| 171 // more than one CodeBreakpoint for one BreakpointLocation, e.g. when a | 171 // more than one CodeBreakpoint for one BreakpointLocation, e.g. when a |
| 172 // function gets compiled as a regular function and as a closure. | 172 // function gets compiled as a regular function and as a closure. |
| 173 class CodeBreakpoint { | 173 class CodeBreakpoint { |
| 174 public: | 174 public: |
| 175 CodeBreakpoint(const Code& code, | 175 CodeBreakpoint(const Code& code, |
| 176 intptr_t token_pos, | 176 TokenDescriptor token_pos, |
| 177 uword pc, | 177 uword pc, |
| 178 RawPcDescriptors::Kind kind); | 178 RawPcDescriptors::Kind kind); |
| 179 ~CodeBreakpoint(); | 179 ~CodeBreakpoint(); |
| 180 | 180 |
| 181 RawFunction* function() const; | 181 RawFunction* function() const; |
| 182 uword pc() const { return pc_; } | 182 uword pc() const { return pc_; } |
| 183 intptr_t token_pos() const { return token_pos_; } | 183 TokenDescriptor token_pos() const { return token_pos_; } |
| 184 bool IsInternal() const { return bpt_location_ == NULL; } | 184 bool IsInternal() const { return bpt_location_ == NULL; } |
| 185 | 185 |
| 186 RawScript* SourceCode(); | 186 RawScript* SourceCode(); |
| 187 RawString* SourceUrl(); | 187 RawString* SourceUrl(); |
| 188 intptr_t LineNumber(); | 188 intptr_t LineNumber(); |
| 189 | 189 |
| 190 void Enable(); | 190 void Enable(); |
| 191 void Disable(); | 191 void Disable(); |
| 192 bool IsEnabled() const { return is_enabled_; } | 192 bool IsEnabled() const { return is_enabled_; } |
| 193 | 193 |
| 194 RawCode* OrigStubAddress() const; | 194 RawCode* OrigStubAddress() const; |
| 195 | 195 |
| 196 private: | 196 private: |
| 197 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 197 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 198 | 198 |
| 199 BreakpointLocation* bpt_location() const { return bpt_location_; } | 199 BreakpointLocation* bpt_location() const { return bpt_location_; } |
| 200 void set_bpt_location(BreakpointLocation* value) { bpt_location_ = value; } | 200 void set_bpt_location(BreakpointLocation* value) { bpt_location_ = value; } |
| 201 | 201 |
| 202 void set_next(CodeBreakpoint* value) { next_ = value; } | 202 void set_next(CodeBreakpoint* value) { next_ = value; } |
| 203 CodeBreakpoint* next() const { return this->next_; } | 203 CodeBreakpoint* next() const { return this->next_; } |
| 204 | 204 |
| 205 void PatchCode(); | 205 void PatchCode(); |
| 206 void RestoreCode(); | 206 void RestoreCode(); |
| 207 | 207 |
| 208 RawCode* code_; | 208 RawCode* code_; |
| 209 intptr_t token_pos_; | 209 TokenDescriptor token_pos_; |
| 210 uword pc_; | 210 uword pc_; |
| 211 intptr_t line_number_; | 211 intptr_t line_number_; |
| 212 bool is_enabled_; | 212 bool is_enabled_; |
| 213 | 213 |
| 214 BreakpointLocation* bpt_location_; | 214 BreakpointLocation* bpt_location_; |
| 215 CodeBreakpoint* next_; | 215 CodeBreakpoint* next_; |
| 216 | 216 |
| 217 RawPcDescriptors::Kind breakpoint_kind_; | 217 RawPcDescriptors::Kind breakpoint_kind_; |
| 218 RawCode* saved_value_; | 218 RawCode* saved_value_; |
| 219 | 219 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 238 } | 238 } |
| 239 const Code& code() const { | 239 const Code& code() const { |
| 240 ASSERT(!code_.IsNull()); | 240 ASSERT(!code_.IsNull()); |
| 241 return code_; | 241 return code_; |
| 242 } | 242 } |
| 243 | 243 |
| 244 RawString* QualifiedFunctionName(); | 244 RawString* QualifiedFunctionName(); |
| 245 RawString* SourceUrl(); | 245 RawString* SourceUrl(); |
| 246 RawScript* SourceScript(); | 246 RawScript* SourceScript(); |
| 247 RawLibrary* Library(); | 247 RawLibrary* Library(); |
| 248 intptr_t TokenPos(); | 248 TokenDescriptor TokenPos(); |
| 249 intptr_t LineNumber(); | 249 intptr_t LineNumber(); |
| 250 intptr_t ColumnNumber(); | 250 intptr_t ColumnNumber(); |
| 251 | 251 |
| 252 // Returns true if this frame is for a function that is visible | 252 // Returns true if this frame is for a function that is visible |
| 253 // to the user and can be debugged. | 253 // to the user and can be debugged. |
| 254 bool IsDebuggable() const; | 254 bool IsDebuggable() const; |
| 255 | 255 |
| 256 // The context level of a frame is the context level at the | 256 // The context level of a frame is the context level at the |
| 257 // PC/token index of the frame. It determines the depth of the context | 257 // PC/token index of the frame. It determines the depth of the context |
| 258 // chain that belongs to the function of this activation frame. | 258 // chain that belongs to the function of this activation frame. |
| 259 intptr_t ContextLevel(); | 259 intptr_t ContextLevel(); |
| 260 | 260 |
| 261 const char* ToCString(); | 261 const char* ToCString(); |
| 262 | 262 |
| 263 intptr_t NumLocalVariables(); | 263 intptr_t NumLocalVariables(); |
| 264 | 264 |
| 265 void VariableAt(intptr_t i, | 265 void VariableAt(intptr_t i, |
| 266 String* name, | 266 String* name, |
| 267 intptr_t* token_pos, | 267 TokenDescriptor* token_pos, |
| 268 intptr_t* end_pos, | 268 TokenDescriptor* end_pos, |
| 269 Object* value); | 269 Object* value); |
| 270 | 270 |
| 271 RawArray* GetLocalVariables(); | 271 RawArray* GetLocalVariables(); |
| 272 RawObject* GetParameter(intptr_t index); | 272 RawObject* GetParameter(intptr_t index); |
| 273 RawObject* GetClosure(); | 273 RawObject* GetClosure(); |
| 274 RawObject* GetReceiver(); | 274 RawObject* GetReceiver(); |
| 275 | 275 |
| 276 const Context& GetSavedCurrentContext(); | 276 const Context& GetSavedCurrentContext(); |
| 277 RawObject* GetAsyncOperation(); | 277 RawObject* GetAsyncOperation(); |
| 278 | 278 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 298 | 298 |
| 299 uword pc_; | 299 uword pc_; |
| 300 uword fp_; | 300 uword fp_; |
| 301 uword sp_; | 301 uword sp_; |
| 302 | 302 |
| 303 // The anchor of the context chain for this function. | 303 // The anchor of the context chain for this function. |
| 304 Context& ctx_; | 304 Context& ctx_; |
| 305 const Code& code_; | 305 const Code& code_; |
| 306 const Function& function_; | 306 const Function& function_; |
| 307 bool token_pos_initialized_; | 307 bool token_pos_initialized_; |
| 308 intptr_t token_pos_; | 308 TokenDescriptor token_pos_; |
| 309 intptr_t try_index_; | 309 intptr_t try_index_; |
| 310 | 310 |
| 311 intptr_t line_number_; | 311 intptr_t line_number_; |
| 312 intptr_t column_number_; | 312 intptr_t column_number_; |
| 313 intptr_t context_level_; | 313 intptr_t context_level_; |
| 314 | 314 |
| 315 // Some frames are deoptimized into a side array in order to inspect them. | 315 // Some frames are deoptimized into a side array in order to inspect them. |
| 316 const Array& deopt_frame_; | 316 const Array& deopt_frame_; |
| 317 const intptr_t deopt_frame_offset_; | 317 const intptr_t deopt_frame_offset_; |
| 318 | 318 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 kStepOver, | 582 kStepOver, |
| 583 kStepOut, | 583 kStepOut, |
| 584 kSingleStep | 584 kSingleStep |
| 585 }; | 585 }; |
| 586 | 586 |
| 587 static bool HasAnyEventHandler(); | 587 static bool HasAnyEventHandler(); |
| 588 static bool HasDebugEventHandler(); | 588 static bool HasDebugEventHandler(); |
| 589 void InvokeEventHandler(DebuggerEvent* event); | 589 void InvokeEventHandler(DebuggerEvent* event); |
| 590 | 590 |
| 591 void FindCompiledFunctions(const Script& script, | 591 void FindCompiledFunctions(const Script& script, |
| 592 intptr_t start_pos, | 592 TokenDescriptor start_pos, |
| 593 intptr_t end_pos, | 593 TokenDescriptor end_pos, |
| 594 GrowableObjectArray* function_list); | 594 GrowableObjectArray* function_list); |
| 595 RawFunction* FindBestFit(const Script& script, intptr_t token_pos); | 595 RawFunction* FindBestFit(const Script& script, TokenDescriptor token_pos); |
| 596 RawFunction* FindInnermostClosure(const Function& function, | 596 RawFunction* FindInnermostClosure(const Function& function, |
| 597 intptr_t token_pos); | 597 TokenDescriptor token_pos); |
| 598 intptr_t ResolveBreakpointPos(const Function& func, | 598 TokenDescriptor ResolveBreakpointPos(const Function& func, |
| 599 intptr_t requested_token_pos, | 599 TokenDescriptor requested_token_pos, |
| 600 intptr_t last_token_pos, | 600 TokenDescriptor last_token_pos, |
| 601 intptr_t requested_column); | 601 intptr_t requested_column); |
| 602 void DeoptimizeWorld(); | 602 void DeoptimizeWorld(); |
| 603 BreakpointLocation* SetBreakpoint(const Script& script, | 603 BreakpointLocation* SetBreakpoint(const Script& script, |
| 604 intptr_t token_pos, | 604 TokenDescriptor token_pos, |
| 605 intptr_t last_token_pos, | 605 TokenDescriptor last_token_pos, |
| 606 intptr_t requested_line, | 606 intptr_t requested_line, |
| 607 intptr_t requested_column); | 607 intptr_t requested_column); |
| 608 void RemoveInternalBreakpoints(); | 608 void RemoveInternalBreakpoints(); |
| 609 void UnlinkCodeBreakpoints(BreakpointLocation* bpt_location); | 609 void UnlinkCodeBreakpoints(BreakpointLocation* bpt_location); |
| 610 BreakpointLocation* GetLatentBreakpoint(const String& url, | 610 BreakpointLocation* GetLatentBreakpoint(const String& url, |
| 611 intptr_t line, | 611 intptr_t line, |
| 612 intptr_t column); | 612 intptr_t column); |
| 613 void RegisterBreakpointLocation(BreakpointLocation* bpt); | 613 void RegisterBreakpointLocation(BreakpointLocation* bpt); |
| 614 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); | 614 void RegisterCodeBreakpoint(CodeBreakpoint* bpt); |
| 615 BreakpointLocation* GetBreakpointLocation(const Script& script, | 615 BreakpointLocation* GetBreakpointLocation(const Script& script, |
| 616 intptr_t token_pos, | 616 TokenDescriptor token_pos, |
| 617 intptr_t requested_column); | 617 intptr_t requested_column); |
| 618 void MakeCodeBreakpointAt(const Function& func, | 618 void MakeCodeBreakpointAt(const Function& func, |
| 619 BreakpointLocation* bpt); | 619 BreakpointLocation* bpt); |
| 620 // Returns NULL if no breakpoint exists for the given address. | 620 // Returns NULL if no breakpoint exists for the given address. |
| 621 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 621 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
| 622 | 622 |
| 623 void SyncBreakpointLocation(BreakpointLocation* loc); | 623 void SyncBreakpointLocation(BreakpointLocation* loc); |
| 624 | 624 |
| 625 ActivationFrame* TopDartFrame() const; | 625 ActivationFrame* TopDartFrame() const; |
| 626 static ActivationFrame* CollectDartFrame(Isolate* isolate, | 626 static ActivationFrame* CollectDartFrame(Isolate* isolate, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 702 |
| 703 friend class Isolate; | 703 friend class Isolate; |
| 704 friend class BreakpointLocation; | 704 friend class BreakpointLocation; |
| 705 DISALLOW_COPY_AND_ASSIGN(Debugger); | 705 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 706 }; | 706 }; |
| 707 | 707 |
| 708 | 708 |
| 709 } // namespace dart | 709 } // namespace dart |
| 710 | 710 |
| 711 #endif // VM_DEBUGGER_H_ | 711 #endif // VM_DEBUGGER_H_ |
| OLD | NEW |