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

Side by Side Diff: src/debug.h

Issue 300683005: Rename EnterDebugger to DebugScope. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/debug.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_DEBUG_H_ 5 #ifndef V8_DEBUG_H_
6 #define V8_DEBUG_H_ 6 #define V8_DEBUG_H_
7 7
8 #include "allocation.h" 8 #include "allocation.h"
9 #include "arguments.h" 9 #include "arguments.h"
10 #include "assembler.h" 10 #include "assembler.h"
11 #include "execution.h" 11 #include "execution.h"
12 #include "factory.h" 12 #include "factory.h"
13 #include "flags.h" 13 #include "flags.h"
14 #include "frames-inl.h" 14 #include "frames-inl.h"
15 #include "hashmap.h" 15 #include "hashmap.h"
16 #include "liveedit.h" 16 #include "liveedit.h"
17 #include "platform.h" 17 #include "platform.h"
18 #include "string-stream.h" 18 #include "string-stream.h"
19 #include "v8threads.h" 19 #include "v8threads.h"
20 20
21 #include "../include/v8-debug.h" 21 #include "../include/v8-debug.h"
22 22
23 namespace v8 { 23 namespace v8 {
24 namespace internal { 24 namespace internal {
25 25
26 26
27 // Forward declarations. 27 // Forward declarations.
28 class EnterDebugger; 28 class DebugScope;
29 29
30 30
31 // Step actions. NOTE: These values are in macros.py as well. 31 // Step actions. NOTE: These values are in macros.py as well.
32 enum StepAction { 32 enum StepAction {
33 StepNone = -1, // Stepping not prepared. 33 StepNone = -1, // Stepping not prepared.
34 StepOut = 0, // Step out of the current function. 34 StepOut = 0, // Step out of the current function.
35 StepNext = 1, // Step to the next statement in the current function. 35 StepNext = 1, // Step to the next statement in the current function.
36 StepIn = 2, // Step into new functions invoked or the next statement 36 StepIn = 2, // Step into new functions invoked or the next statement
37 // in the current function. 37 // in the current function.
38 StepMin = 3, // Perform a minimum step in the current function. 38 StepMin = 3, // Perform a minimum step in the current function.
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 static int ArchiveSpacePerThread(); 479 static int ArchiveSpacePerThread();
480 void FreeThreadResources() { } 480 void FreeThreadResources() { }
481 481
482 // Record function from which eval was called. 482 // Record function from which eval was called.
483 static void RecordEvalCaller(Handle<Script> script); 483 static void RecordEvalCaller(Handle<Script> script);
484 484
485 // Garbage collection notifications. 485 // Garbage collection notifications.
486 void AfterGarbageCollection(); 486 void AfterGarbageCollection();
487 487
488 // Flags and states. 488 // Flags and states.
489 EnterDebugger* debugger_entry() { return thread_local_.debugger_entry_; } 489 DebugScope* debugger_entry() { return thread_local_.current_debug_scope_; }
490 inline Handle<Context> debug_context() { return debug_context_; } 490 inline Handle<Context> debug_context() { return debug_context_; }
491 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } 491 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; }
492 bool live_edit_enabled() const { 492 bool live_edit_enabled() const {
493 return FLAG_enable_liveedit && live_edit_enabled_ ; 493 return FLAG_enable_liveedit && live_edit_enabled_ ;
494 } 494 }
495 495
496 inline bool is_active() const { return is_active_; } 496 inline bool is_active() const { return is_active_; }
497 inline bool is_loaded() const { return !debug_context_.is_null(); } 497 inline bool is_loaded() const { return !debug_context_.is_null(); }
498 inline bool has_break_points() const { return has_break_points_; } 498 inline bool has_break_points() const { return has_break_points_; }
499 inline bool is_entered() const { 499 inline bool in_debug_scope() const {
500 return thread_local_.debugger_entry_ != NULL; 500 return thread_local_.current_debug_scope_ != NULL;
501 } 501 }
502 void set_disable_break(bool v) { break_disabled_ = v; } 502 void set_disable_break(bool v) { break_disabled_ = v; }
503 503
504 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; } 504 StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; }
505 int break_id() { return thread_local_.break_id_; } 505 int break_id() { return thread_local_.break_id_; }
506 506
507 // Support for embedding into generated code. 507 // Support for embedding into generated code.
508 Address after_break_target_address() { 508 Address after_break_target_address() {
509 return reinterpret_cast<Address>(&after_break_target_); 509 return reinterpret_cast<Address>(&after_break_target_);
510 } 510 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 void ClearOneShot(); 570 void ClearOneShot();
571 void ActivateStepIn(StackFrame* frame); 571 void ActivateStepIn(StackFrame* frame);
572 void ClearStepIn(); 572 void ClearStepIn();
573 void ActivateStepOut(StackFrame* frame); 573 void ActivateStepOut(StackFrame* frame);
574 void ClearStepNext(); 574 void ClearStepNext();
575 // Returns whether the compile succeeded. 575 // Returns whether the compile succeeded.
576 void RemoveDebugInfo(Handle<DebugInfo> debug_info); 576 void RemoveDebugInfo(Handle<DebugInfo> debug_info);
577 Handle<Object> CheckBreakPoints(Handle<Object> break_point); 577 Handle<Object> CheckBreakPoints(Handle<Object> break_point);
578 bool CheckBreakPoint(Handle<Object> break_point_object); 578 bool CheckBreakPoint(Handle<Object> break_point_object);
579 579
580 inline void AssertDebugContext() {
581 ASSERT(isolate_->context() == *debug_context());
582 ASSERT(in_debug_scope());
583 }
584
580 void ThreadInit(); 585 void ThreadInit();
581 586
582 // Global handles. 587 // Global handles.
583 Handle<Context> debug_context_; 588 Handle<Context> debug_context_;
584 Handle<Object> event_listener_; 589 Handle<Object> event_listener_;
585 Handle<Object> event_listener_data_; 590 Handle<Object> event_listener_data_;
586 591
587 v8::Debug::MessageHandler message_handler_; 592 v8::Debug::MessageHandler message_handler_;
588 593
589 static const int kQueueInitialSize = 4; 594 static const int kQueueInitialSize = 4;
(...skipping 14 matching lines...) Expand all
604 609
605 // Storage location for jump when exiting debug break calls. 610 // Storage location for jump when exiting debug break calls.
606 // Note that this address is not GC safe. It should be computed immediately 611 // Note that this address is not GC safe. It should be computed immediately
607 // before returning to the DebugBreakCallHelper. 612 // before returning to the DebugBreakCallHelper.
608 Address after_break_target_; 613 Address after_break_target_;
609 614
610 // Per-thread data. 615 // Per-thread data.
611 class ThreadLocal { 616 class ThreadLocal {
612 public: 617 public:
613 // Top debugger entry. 618 // Top debugger entry.
614 EnterDebugger* debugger_entry_; 619 DebugScope* current_debug_scope_;
615 620
616 // Counter for generating next break id. 621 // Counter for generating next break id.
617 int break_count_; 622 int break_count_;
618 623
619 // Current break id. 624 // Current break id.
620 int break_id_; 625 int break_id_;
621 626
622 // Frame id for the frame of the current break. 627 // Frame id for the frame of the current break.
623 StackFrame::Id break_frame_id_; 628 StackFrame::Id break_frame_id_;
624 629
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 // Due to the possibility of reentry we use a linked list. 665 // Due to the possibility of reentry we use a linked list.
661 PromiseOnStack* promise_on_stack_; 666 PromiseOnStack* promise_on_stack_;
662 }; 667 };
663 668
664 // Storage location for registers when handling debug break calls 669 // Storage location for registers when handling debug break calls
665 ThreadLocal thread_local_; 670 ThreadLocal thread_local_;
666 671
667 Isolate* isolate_; 672 Isolate* isolate_;
668 673
669 friend class Isolate; 674 friend class Isolate;
670 friend class EnterDebugger; 675 friend class DebugScope;
671 friend class FrameDropper;
672 friend class DisableBreak; 676 friend class DisableBreak;
673 friend class SuppressDebug; 677 friend class SuppressDebug;
674 678
675 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc 679 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc
676 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc 680 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc
677 681
678 DISALLOW_COPY_AND_ASSIGN(Debug); 682 DISALLOW_COPY_AND_ASSIGN(Debug);
679 }; 683 };
680 684
681 685
682 DECLARE_RUNTIME_FUNCTION(Debug_Break); 686 DECLARE_RUNTIME_FUNCTION(Debug_Break);
683 687
684 688
685 // This class is used for entering the debugger. Create an instance in the stack 689 // This scope is used to load and enter the debug context and create a new
686 // to enter the debugger. This will set the current break state, make sure the 690 // break state. Leaving the scope will restore the previous state.
687 // debugger is loaded and switch to the debugger context. If the debugger for 691 // On failure to load, FailedToEnter returns true.
688 // some reason could not be entered FailedToEnter will return true. 692 class DebugScope BASE_EMBEDDED {
689 class EnterDebugger BASE_EMBEDDED {
690 public: 693 public:
691 explicit EnterDebugger(Isolate* isolate); 694 explicit DebugScope(Debug* debug);
692 ~EnterDebugger(); 695 ~DebugScope();
693 696
694 // Check whether the debugger could be entered. 697 // Check whether loading was successful.
695 inline bool FailedToEnter() { return load_failed_; } 698 inline bool failed() { return failed_; }
696 699
697 // Get the active context from before entering the debugger. 700 // Get the active context from before entering the debugger.
698 inline Handle<Context> GetContext() { return save_.context(); } 701 inline Handle<Context> GetContext() { return save_.context(); }
699 702
700 private: 703 private:
701 Isolate* isolate_; 704 Isolate* isolate() { return debug_->isolate_; }
702 EnterDebugger* prev_; // Previous debugger entry if entered recursively. 705
706 Debug* debug_;
707 DebugScope* prev_; // Previous scope if entered recursively.
703 StackFrame::Id break_frame_id_; // Previous break frame id. 708 StackFrame::Id break_frame_id_; // Previous break frame id.
704 int break_id_; // Previous break id. 709 int break_id_; // Previous break id.
705 bool load_failed_; // Did the debugger fail to load? 710 bool failed_; // Did the debug context fail to load?
706 SaveContext save_; // Saves previous context. 711 SaveContext save_; // Saves previous context.
707 }; 712 };
708 713
709 714
710 // Stack allocated class for disabling break. 715 // Stack allocated class for disabling break.
711 class DisableBreak BASE_EMBEDDED { 716 class DisableBreak BASE_EMBEDDED {
712 public: 717 public:
713 explicit DisableBreak(Debug* debug, bool disable_break) 718 explicit DisableBreak(Debug* debug, bool disable_break)
714 : debug_(debug), old_state_(debug->break_disabled_) { 719 : debug_(debug), old_state_(debug->break_disabled_) {
715 debug_->break_disabled_ = disable_break; 720 debug_->break_disabled_ = disable_break;
716 } 721 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // several frames above. 764 // several frames above.
760 // There is no calling conventions here, because it never actually gets 765 // There is no calling conventions here, because it never actually gets
761 // called, it only gets returned to. 766 // called, it only gets returned to.
762 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); 767 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm);
763 }; 768 };
764 769
765 770
766 } } // namespace v8::internal 771 } } // namespace v8::internal
767 772
768 #endif // V8_DEBUG_H_ 773 #endif // V8_DEBUG_H_
OLDNEW
« no previous file with comments | « no previous file | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698