Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: runtime/vm/debugger.h

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

Powered by Google App Engine
This is Rietveld 408576698