| 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 RUNTIME_VM_DEBUGGER_H_ | 5 #ifndef RUNTIME_VM_DEBUGGER_H_ |
| 6 #define RUNTIME_VM_DEBUGGER_H_ | 6 #define RUNTIME_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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 | 254 |
| 255 // ActivationFrame represents one dart function activation frame | 255 // ActivationFrame represents one dart function activation frame |
| 256 // on the call stack. | 256 // on the call stack. |
| 257 class ActivationFrame : public ZoneAllocated { | 257 class ActivationFrame : public ZoneAllocated { |
| 258 public: | 258 public: |
| 259 enum Kind { | 259 enum Kind { |
| 260 kRegular, | 260 kRegular, |
| 261 kAsyncSuspensionMarker, | 261 kAsyncSuspensionMarker, |
| 262 kAsyncCausal, | 262 kAsyncCausal, |
| 263 kAsyncActivation, |
| 263 }; | 264 }; |
| 264 | 265 |
| 265 ActivationFrame(uword pc, | 266 ActivationFrame(uword pc, |
| 266 uword fp, | 267 uword fp, |
| 267 uword sp, | 268 uword sp, |
| 268 const Code& code, | 269 const Code& code, |
| 269 const Array& deopt_frame, | 270 const Array& deopt_frame, |
| 270 intptr_t deopt_frame_offset, | 271 intptr_t deopt_frame_offset, |
| 271 Kind kind = kRegular); | 272 Kind kind = kRegular); |
| 272 | 273 |
| 273 ActivationFrame(uword pc, const Code& code); | 274 ActivationFrame(uword pc, const Code& code); |
| 274 | 275 |
| 275 explicit ActivationFrame(Kind kind); | 276 explicit ActivationFrame(Kind kind); |
| 276 | 277 |
| 278 explicit ActivationFrame(const Closure& async_activation); |
| 279 |
| 277 uword pc() const { return pc_; } | 280 uword pc() const { return pc_; } |
| 278 uword fp() const { return fp_; } | 281 uword fp() const { return fp_; } |
| 279 uword sp() const { return sp_; } | 282 uword sp() const { return sp_; } |
| 280 const Function& function() const { | 283 const Function& function() const { |
| 281 ASSERT(!function_.IsNull()); | 284 ASSERT(!function_.IsNull()); |
| 282 return function_; | 285 return function_; |
| 283 } | 286 } |
| 284 const Code& code() const { | 287 const Code& code() const { |
| 285 ASSERT(!code_.IsNull()); | 288 ASSERT(!code_.IsNull()); |
| 286 return code_; | 289 return code_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 const Context& GetSavedCurrentContext(); | 328 const Context& GetSavedCurrentContext(); |
| 326 RawObject* GetAsyncOperation(); | 329 RawObject* GetAsyncOperation(); |
| 327 | 330 |
| 328 RawObject* Evaluate(const String& expr); | 331 RawObject* Evaluate(const String& expr); |
| 329 | 332 |
| 330 // Print the activation frame into |jsobj|. if |full| is false, script | 333 // Print the activation frame into |jsobj|. if |full| is false, script |
| 331 // and local variable objects are only references. if |full| is true, | 334 // and local variable objects are only references. if |full| is true, |
| 332 // the complete script, function, and, local variable objects are included. | 335 // the complete script, function, and, local variable objects are included. |
| 333 void PrintToJSONObject(JSONObject* jsobj, bool full = false); | 336 void PrintToJSONObject(JSONObject* jsobj, bool full = false); |
| 334 | 337 |
| 338 RawObject* GetAsyncAwaiter(); |
| 339 |
| 340 bool HandlesException(const Instance& exc_obj); |
| 341 |
| 335 private: | 342 private: |
| 336 void PrintToJSONObjectRegular(JSONObject* jsobj, bool full); | 343 void PrintToJSONObjectRegular(JSONObject* jsobj, bool full); |
| 337 void PrintToJSONObjectAsyncCausal(JSONObject* jsobj, bool full); | 344 void PrintToJSONObjectAsyncCausal(JSONObject* jsobj, bool full); |
| 338 void PrintToJSONObjectAsyncSuspensionMarker(JSONObject* jsobj, bool full); | 345 void PrintToJSONObjectAsyncSuspensionMarker(JSONObject* jsobj, bool full); |
| 339 | 346 |
| 340 void PrintContextMismatchError(intptr_t ctx_slot, | 347 void PrintContextMismatchError(intptr_t ctx_slot, |
| 341 intptr_t frame_ctx_level, | 348 intptr_t frame_ctx_level, |
| 342 intptr_t var_ctx_level); | 349 intptr_t var_ctx_level); |
| 343 | 350 |
| 344 intptr_t TryIndex(); | 351 intptr_t TryIndex(); |
| 345 void GetPcDescriptors(); | 352 void GetPcDescriptors(); |
| 346 void GetVarDescriptors(); | 353 void GetVarDescriptors(); |
| 347 void GetDescIndices(); | 354 void GetDescIndices(); |
| 348 | 355 |
| 356 RawObject* GetAsyncStreamControllerStreamAwaiter(const Object& stream); |
| 357 RawObject* GetAsyncStreamControllerStream(); |
| 358 RawObject* GetAsyncCompleterAwaiter(const Object& completer); |
| 359 RawObject* GetAsyncCompleter(); |
| 360 void ExtractTokenPositionFromAsyncClosure(); |
| 361 |
| 349 static const char* KindToCString(Kind kind) { | 362 static const char* KindToCString(Kind kind) { |
| 350 switch (kind) { | 363 switch (kind) { |
| 351 case kRegular: | 364 case kRegular: |
| 352 return "Regular"; | 365 return "Regular"; |
| 353 case kAsyncCausal: | 366 case kAsyncCausal: |
| 354 return "AsyncCausal"; | 367 return "AsyncCausal"; |
| 355 case kAsyncSuspensionMarker: | 368 case kAsyncSuspensionMarker: |
| 356 return "AsyncSuspensionMarker"; | 369 return "AsyncSuspensionMarker"; |
| 357 default: | 370 default: |
| 358 UNREACHABLE(); | 371 UNREACHABLE(); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 BreakpointLocation* GetBreakpointLocation(const Script& script, | 633 BreakpointLocation* GetBreakpointLocation(const Script& script, |
| 621 TokenPosition token_pos, | 634 TokenPosition token_pos, |
| 622 intptr_t requested_column); | 635 intptr_t requested_column); |
| 623 void MakeCodeBreakpointAt(const Function& func, BreakpointLocation* bpt); | 636 void MakeCodeBreakpointAt(const Function& func, BreakpointLocation* bpt); |
| 624 // Returns NULL if no breakpoint exists for the given address. | 637 // Returns NULL if no breakpoint exists for the given address. |
| 625 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); | 638 CodeBreakpoint* GetCodeBreakpoint(uword breakpoint_address); |
| 626 | 639 |
| 627 void SyncBreakpointLocation(BreakpointLocation* loc); | 640 void SyncBreakpointLocation(BreakpointLocation* loc); |
| 628 | 641 |
| 629 ActivationFrame* TopDartFrame() const; | 642 ActivationFrame* TopDartFrame() const; |
| 630 static ActivationFrame* CollectDartFrame(Isolate* isolate, | 643 static ActivationFrame* CollectDartFrame( |
| 631 uword pc, | 644 Isolate* isolate, |
| 632 StackFrame* frame, | 645 uword pc, |
| 633 const Code& code, | 646 StackFrame* frame, |
| 634 const Array& deopt_frame, | 647 const Code& code, |
| 635 intptr_t deopt_frame_offset); | 648 const Array& deopt_frame, |
| 649 intptr_t deopt_frame_offset, |
| 650 ActivationFrame::Kind kind = ActivationFrame::kRegular); |
| 636 static RawArray* DeoptimizeToArray(Thread* thread, | 651 static RawArray* DeoptimizeToArray(Thread* thread, |
| 637 StackFrame* frame, | 652 StackFrame* frame, |
| 638 const Code& code); | 653 const Code& code); |
| 639 // Appends at least one stack frame. Multiple frames will be appended | 654 // Appends at least one stack frame. Multiple frames will be appended |
| 640 // if |code| at the frame's pc contains inlined functions. | 655 // if |code| at the frame's pc contains inlined functions. |
| 641 static void AppendCodeFrames(Thread* thread, | 656 static void AppendCodeFrames(Thread* thread, |
| 642 Isolate* isolate, | 657 Isolate* isolate, |
| 643 Zone* zone, | 658 Zone* zone, |
| 644 DebuggerStackTrace* stack_trace, | 659 DebuggerStackTrace* stack_trace, |
| 645 StackFrame* frame, | 660 StackFrame* frame, |
| 646 Code* code, | 661 Code* code, |
| 647 Code* inlined_code, | 662 Code* inlined_code, |
| 648 Array* deopt_frame); | 663 Array* deopt_frame); |
| 649 static DebuggerStackTrace* CollectStackTrace(); | 664 static DebuggerStackTrace* CollectStackTrace(); |
| 650 static DebuggerStackTrace* CollectAsyncCausalStackTrace(); | 665 static DebuggerStackTrace* CollectAsyncCausalStackTrace(); |
| 666 static DebuggerStackTrace* CollectAwaiterReturnStackTrace(); |
| 651 void SignalPausedEvent(ActivationFrame* top_frame, Breakpoint* bpt); | 667 void SignalPausedEvent(ActivationFrame* top_frame, Breakpoint* bpt); |
| 652 | 668 |
| 653 intptr_t nextId() { return next_id_++; } | 669 intptr_t nextId() { return next_id_++; } |
| 654 | 670 |
| 671 bool ShouldPauseOnAsyncException(DebuggerStackTrace* stack_trace, |
| 672 const Instance& exc); |
| 673 |
| 655 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, | 674 bool ShouldPauseOnException(DebuggerStackTrace* stack_trace, |
| 656 const Instance& exc); | 675 const Instance& exc); |
| 657 | 676 |
| 658 void CollectLibraryFields(const GrowableObjectArray& field_list, | 677 void CollectLibraryFields(const GrowableObjectArray& field_list, |
| 659 const Library& lib, | 678 const Library& lib, |
| 660 const String& prefix, | 679 const String& prefix, |
| 661 bool include_private_fields); | 680 bool include_private_fields); |
| 662 | 681 |
| 663 // Handles any events which pause vm execution. Breakpoints, | 682 // Handles any events which pause vm execution. Breakpoints, |
| 664 // interrupts, etc. | 683 // interrupts, etc. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 757 |
| 739 friend class Isolate; | 758 friend class Isolate; |
| 740 friend class BreakpointLocation; | 759 friend class BreakpointLocation; |
| 741 DISALLOW_COPY_AND_ASSIGN(Debugger); | 760 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 742 }; | 761 }; |
| 743 | 762 |
| 744 | 763 |
| 745 } // namespace dart | 764 } // namespace dart |
| 746 | 765 |
| 747 #endif // RUNTIME_VM_DEBUGGER_H_ | 766 #endif // RUNTIME_VM_DEBUGGER_H_ |
| OLD | NEW |