| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 RawScript* SourceScript(); | 269 RawScript* SourceScript(); |
| 270 RawLibrary* Library(); | 270 RawLibrary* Library(); |
| 271 TokenPosition TokenPos(); | 271 TokenPosition TokenPos(); |
| 272 intptr_t LineNumber(); | 272 intptr_t LineNumber(); |
| 273 intptr_t ColumnNumber(); | 273 intptr_t ColumnNumber(); |
| 274 | 274 |
| 275 // Returns true if this frame is for a function that is visible | 275 // Returns true if this frame is for a function that is visible |
| 276 // to the user and can be debugged. | 276 // to the user and can be debugged. |
| 277 bool IsDebuggable() const; | 277 bool IsDebuggable() const; |
| 278 | 278 |
| 279 // Returns true if it is possible to rewind the debugger to this frame. | |
| 280 bool IsRewindable() const; | |
| 281 | |
| 282 // The context level of a frame is the context level at the | 279 // The context level of a frame is the context level at the |
| 283 // PC/token index of the frame. It determines the depth of the context | 280 // PC/token index of the frame. It determines the depth of the context |
| 284 // chain that belongs to the function of this activation frame. | 281 // chain that belongs to the function of this activation frame. |
| 285 intptr_t ContextLevel(); | 282 intptr_t ContextLevel(); |
| 286 | 283 |
| 287 const char* ToCString(); | 284 const char* ToCString(); |
| 288 | 285 |
| 289 intptr_t NumLocalVariables(); | 286 intptr_t NumLocalVariables(); |
| 290 | 287 |
| 291 void VariableAt(intptr_t i, | 288 void VariableAt(intptr_t i, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 void AddActivation(ActivationFrame* frame); | 366 void AddActivation(ActivationFrame* frame); |
| 370 ZoneGrowableArray<ActivationFrame*> trace_; | 367 ZoneGrowableArray<ActivationFrame*> trace_; |
| 371 | 368 |
| 372 friend class Debugger; | 369 friend class Debugger; |
| 373 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); | 370 DISALLOW_COPY_AND_ASSIGN(DebuggerStackTrace); |
| 374 }; | 371 }; |
| 375 | 372 |
| 376 | 373 |
| 377 class Debugger { | 374 class Debugger { |
| 378 public: | 375 public: |
| 379 enum ResumeAction { | |
| 380 kContinue, | |
| 381 kStepInto, | |
| 382 kStepOver, | |
| 383 kStepOut, | |
| 384 kStepRewind, | |
| 385 kStepOverAsyncSuspension, | |
| 386 }; | |
| 387 | |
| 388 typedef void EventHandler(ServiceEvent* event); | 376 typedef void EventHandler(ServiceEvent* event); |
| 389 | 377 |
| 390 Debugger(); | 378 Debugger(); |
| 391 ~Debugger(); | 379 ~Debugger(); |
| 392 | 380 |
| 393 void Initialize(Isolate* isolate); | 381 void Initialize(Isolate* isolate); |
| 394 void NotifyIsolateCreated(); | 382 void NotifyIsolateCreated(); |
| 395 void Shutdown(); | 383 void Shutdown(); |
| 396 | 384 |
| 397 void NotifyCompilation(const Function& func); | 385 void NotifyCompilation(const Function& func); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 417 RawError* OneTimeBreakAtEntry(const Function& target_function); | 405 RawError* OneTimeBreakAtEntry(const Function& target_function); |
| 418 | 406 |
| 419 BreakpointLocation* BreakpointLocationAtLineCol(const String& script_url, | 407 BreakpointLocation* BreakpointLocationAtLineCol(const String& script_url, |
| 420 intptr_t line_number, | 408 intptr_t line_number, |
| 421 intptr_t column_number); | 409 intptr_t column_number); |
| 422 | 410 |
| 423 | 411 |
| 424 void RemoveBreakpoint(intptr_t bp_id); | 412 void RemoveBreakpoint(intptr_t bp_id); |
| 425 Breakpoint* GetBreakpointById(intptr_t id); | 413 Breakpoint* GetBreakpointById(intptr_t id); |
| 426 | 414 |
| 427 bool SetResumeAction(ResumeAction action, | 415 // Will return false if we are not at an await. |
| 428 intptr_t frame_index = 1, | 416 bool SetupStepOverAsyncSuspension(); |
| 429 const char** error = NULL); | 417 void SetStepOver(); |
| 430 | 418 void SetSingleStep(); |
| 419 void SetStepOut(); |
| 431 bool IsStepping() const { return resume_action_ != kContinue; } | 420 bool IsStepping() const { return resume_action_ != kContinue; } |
| 432 | 421 |
| 433 bool IsPaused() const { return pause_event_ != NULL; } | 422 bool IsPaused() const { return pause_event_ != NULL; } |
| 434 | 423 |
| 435 // Put the isolate into single stepping mode when Dart code next runs. | 424 // Put the isolate into single stepping mode when Dart code next runs. |
| 436 // | 425 // |
| 437 // This is used by the vm service to allow the user to step while | 426 // This is used by the vm service to allow the user to step while |
| 438 // paused at isolate start. | 427 // paused at isolate start. |
| 439 void EnterSingleStepMode(); | 428 void EnterSingleStepMode(); |
| 440 | 429 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 506 |
| 518 RawCode* GetPatchedStubAddress(uword breakpoint_address); | 507 RawCode* GetPatchedStubAddress(uword breakpoint_address); |
| 519 | 508 |
| 520 void PrintBreakpointsToJSONArray(JSONArray* jsarr) const; | 509 void PrintBreakpointsToJSONArray(JSONArray* jsarr) const; |
| 521 void PrintSettingsToJSONObject(JSONObject* jsobj) const; | 510 void PrintSettingsToJSONObject(JSONObject* jsobj) const; |
| 522 | 511 |
| 523 static bool IsDebuggable(const Function& func); | 512 static bool IsDebuggable(const Function& func); |
| 524 | 513 |
| 525 intptr_t limitBreakpointId() { return next_id_; } | 514 intptr_t limitBreakpointId() { return next_id_; } |
| 526 | 515 |
| 527 // Callback to the debugger to continue frame rewind, post-deoptimization. | 516 private: |
| 528 void RewindPostDeopt(); | 517 enum ResumeAction { kContinue, kStepOver, kStepOut, kSingleStep }; |
| 529 | 518 |
| 530 private: | |
| 531 RawError* PauseRequest(ServiceEvent::EventKind kind); | 519 RawError* PauseRequest(ServiceEvent::EventKind kind); |
| 532 | 520 |
| 533 // Will return false if we are not at an await. | |
| 534 bool SetupStepOverAsyncSuspension(const char** error); | |
| 535 | |
| 536 bool NeedsIsolateEvents(); | 521 bool NeedsIsolateEvents(); |
| 537 bool NeedsDebugEvents(); | 522 bool NeedsDebugEvents(); |
| 538 void InvokeEventHandler(ServiceEvent* event); | 523 void InvokeEventHandler(ServiceEvent* event); |
| 539 | 524 |
| 540 void SendBreakpointEvent(ServiceEvent::EventKind kind, Breakpoint* bpt); | 525 void SendBreakpointEvent(ServiceEvent::EventKind kind, Breakpoint* bpt); |
| 541 | 526 |
| 542 bool IsAtAsyncJump(ActivationFrame* top_frame); | 527 bool IsAtAsyncJump(ActivationFrame* top_frame); |
| 543 void FindCompiledFunctions(const Script& script, | 528 void FindCompiledFunctions(const Script& script, |
| 544 TokenPosition start_pos, | 529 TokenPosition start_pos, |
| 545 TokenPosition end_pos, | 530 TokenPosition end_pos, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 const String& prefix, | 581 const String& prefix, |
| 597 bool include_private_fields); | 582 bool include_private_fields); |
| 598 | 583 |
| 599 // Handles any events which pause vm execution. Breakpoints, | 584 // Handles any events which pause vm execution. Breakpoints, |
| 600 // interrupts, etc. | 585 // interrupts, etc. |
| 601 void Pause(ServiceEvent* event); | 586 void Pause(ServiceEvent* event); |
| 602 | 587 |
| 603 void HandleSteppingRequest(DebuggerStackTrace* stack_trace, | 588 void HandleSteppingRequest(DebuggerStackTrace* stack_trace, |
| 604 bool skip_next_step = false); | 589 bool skip_next_step = false); |
| 605 | 590 |
| 606 // Can we rewind to the indicated frame? | |
| 607 bool CanRewindFrame(intptr_t frame_index, const char** error) const; | |
| 608 | |
| 609 void RewindToFrame(intptr_t frame_index); | |
| 610 void RewindToUnoptimizedFrame(StackFrame* frame, const Code& code); | |
| 611 void RewindToOptimizedFrame(StackFrame* frame, | |
| 612 const Code& code, | |
| 613 intptr_t post_deopt_frame_index); | |
| 614 | |
| 615 Isolate* isolate_; | 591 Isolate* isolate_; |
| 616 Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. | 592 Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. |
| 617 bool initialized_; | 593 bool initialized_; |
| 618 | 594 |
| 619 // ID number generator. | 595 // ID number generator. |
| 620 intptr_t next_id_; | 596 intptr_t next_id_; |
| 621 | 597 |
| 622 BreakpointLocation* latent_locations_; | 598 BreakpointLocation* latent_locations_; |
| 623 BreakpointLocation* breakpoint_locations_; | 599 BreakpointLocation* breakpoint_locations_; |
| 624 CodeBreakpoint* code_breakpoints_; | 600 CodeBreakpoint* code_breakpoints_; |
| 625 | 601 |
| 626 // Tells debugger what to do when resuming execution after a breakpoint. | 602 // Tells debugger what to do when resuming execution after a breakpoint. |
| 627 ResumeAction resume_action_; | 603 ResumeAction resume_action_; |
| 628 intptr_t resume_frame_index_; | |
| 629 intptr_t post_deopt_frame_index_; | |
| 630 | 604 |
| 631 // Do not call back to breakpoint handler if this flag is set. | 605 // Do not call back to breakpoint handler if this flag is set. |
| 632 // Effectively this means ignoring breakpoints. Set when Dart code may | 606 // Effectively this means ignoring breakpoints. Set when Dart code may |
| 633 // be run as a side effect of getting values of fields. | 607 // be run as a side effect of getting values of fields. |
| 634 bool ignore_breakpoints_; | 608 bool ignore_breakpoints_; |
| 635 | 609 |
| 636 // Indicates why the debugger is currently paused. If the debugger | 610 // Indicates why the debugger is currently paused. If the debugger |
| 637 // is not paused, this is NULL. Note that the debugger can be | 611 // is not paused, this is NULL. Note that the debugger can be |
| 638 // paused for breakpoints, isolate interruption, and (sometimes) | 612 // paused for breakpoints, isolate interruption, and (sometimes) |
| 639 // exceptions. | 613 // exceptions. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 666 | 640 |
| 667 friend class Isolate; | 641 friend class Isolate; |
| 668 friend class BreakpointLocation; | 642 friend class BreakpointLocation; |
| 669 DISALLOW_COPY_AND_ASSIGN(Debugger); | 643 DISALLOW_COPY_AND_ASSIGN(Debugger); |
| 670 }; | 644 }; |
| 671 | 645 |
| 672 | 646 |
| 673 } // namespace dart | 647 } // namespace dart |
| 674 | 648 |
| 675 #endif // RUNTIME_VM_DEBUGGER_H_ | 649 #endif // RUNTIME_VM_DEBUGGER_H_ |
| OLD | NEW |