OLD | NEW |
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 #include "src/debug/debug.h" | 5 #include "src/debug/debug.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // Clear all current stepping setup. | 486 // Clear all current stepping setup. |
487 ClearStepping(); | 487 ClearStepping(); |
488 | 488 |
489 if (thread_local_.queued_step_count_ > 0) { | 489 if (thread_local_.queued_step_count_ > 0) { |
490 // Perform queued steps | 490 // Perform queued steps |
491 int step_count = thread_local_.queued_step_count_; | 491 int step_count = thread_local_.queued_step_count_; |
492 | 492 |
493 // Clear queue | 493 // Clear queue |
494 thread_local_.queued_step_count_ = 0; | 494 thread_local_.queued_step_count_ = 0; |
495 | 495 |
496 PrepareStep(StepNext, step_count, StackFrame::NO_ID); | 496 PrepareStep(StepNext, step_count); |
497 } else { | 497 } else { |
498 // Notify the debug event listeners. | 498 // Notify the debug event listeners. |
499 OnDebugBreak(break_points_hit, false); | 499 OnDebugBreak(break_points_hit, false); |
500 } | 500 } |
501 } else if (thread_local_.last_step_action_ != StepNone) { | 501 } else if (thread_local_.last_step_action_ != StepNone) { |
502 // Hold on to last step action as it is cleared by the call to | 502 // Hold on to last step action as it is cleared by the call to |
503 // ClearStepping. | 503 // ClearStepping. |
504 StepAction step_action = thread_local_.last_step_action_; | 504 StepAction step_action = thread_local_.last_step_action_; |
505 int step_count = thread_local_.step_count_; | 505 int step_count = thread_local_.step_count_; |
506 | 506 |
(...skipping 17 matching lines...) Expand all Loading... |
524 | 524 |
525 // Set up for StepOut to reach target frame. | 525 // Set up for StepOut to reach target frame. |
526 step_action = StepOut; | 526 step_action = StepOut; |
527 step_count = count; | 527 step_count = count; |
528 } | 528 } |
529 | 529 |
530 // Clear all current stepping setup. | 530 // Clear all current stepping setup. |
531 ClearStepping(); | 531 ClearStepping(); |
532 | 532 |
533 // Set up for the remaining steps. | 533 // Set up for the remaining steps. |
534 PrepareStep(step_action, step_count, StackFrame::NO_ID); | 534 PrepareStep(step_action, step_count); |
535 } | 535 } |
536 } | 536 } |
537 | 537 |
538 | 538 |
539 // Check the break point objects for whether one or more are actually | 539 // Check the break point objects for whether one or more are actually |
540 // triggered. This function returns a JSArray with the break point objects | 540 // triggered. This function returns a JSArray with the break point objects |
541 // which is triggered. | 541 // which is triggered. |
542 Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) { | 542 Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) { |
543 Factory* factory = isolate_->factory(); | 543 Factory* factory = isolate_->factory(); |
544 | 544 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 !it.frame()->function()->shared()->IsSubjectToDebugging()) { | 826 !it.frame()->function()->shared()->IsSubjectToDebugging()) { |
827 it.Advance(); | 827 it.Advance(); |
828 } | 828 } |
829 | 829 |
830 if (it.done()) return; // No suitable Javascript catch handler. | 830 if (it.done()) return; // No suitable Javascript catch handler. |
831 | 831 |
832 FloodWithOneShot(Handle<JSFunction>(it.frame()->function())); | 832 FloodWithOneShot(Handle<JSFunction>(it.frame()->function())); |
833 } | 833 } |
834 | 834 |
835 | 835 |
836 void Debug::PrepareStep(StepAction step_action, | 836 void Debug::PrepareStep(StepAction step_action, int step_count) { |
837 int step_count, | |
838 StackFrame::Id frame_id) { | |
839 HandleScope scope(isolate_); | 837 HandleScope scope(isolate_); |
840 | 838 |
841 DCHECK(in_debug_scope()); | 839 DCHECK(in_debug_scope()); |
842 | 840 |
843 // Get the frame where the execution has stopped and skip the debug frame if | 841 // Get the frame where the execution has stopped and skip the debug frame if |
844 // any. The debug frame will only be present if execution was stopped due to | 842 // any. The debug frame will only be present if execution was stopped due to |
845 // hitting a break point. In other situations (e.g. unhandled exception) the | 843 // hitting a break point. In other situations (e.g. unhandled exception) the |
846 // debug frame is not present. | 844 // debug frame is not present. |
847 StackFrame::Id id = break_frame_id(); | 845 StackFrame::Id frame_id = break_frame_id(); |
848 if (id == StackFrame::NO_ID) { | 846 // If there is no JavaScript stack don't do anything. |
849 // If there is no JavaScript stack don't do anything. | 847 if (frame_id == StackFrame::NO_ID) return; |
850 return; | 848 |
851 } | 849 JavaScriptFrameIterator frames_it(isolate_, frame_id); |
852 if (frame_id != StackFrame::NO_ID) { | |
853 id = frame_id; | |
854 } | |
855 JavaScriptFrameIterator frames_it(isolate_, id); | |
856 JavaScriptFrame* frame = frames_it.frame(); | 850 JavaScriptFrame* frame = frames_it.frame(); |
857 | 851 |
858 feature_tracker()->Track(DebugFeatureTracker::kStepping); | 852 feature_tracker()->Track(DebugFeatureTracker::kStepping); |
859 | 853 |
860 // Remember this step action and count. | 854 // Remember this step action and count. |
861 thread_local_.last_step_action_ = step_action; | 855 thread_local_.last_step_action_ = step_action; |
862 STATIC_ASSERT(StepFrame > StepIn); | 856 STATIC_ASSERT(StepFrame > StepIn); |
863 thread_local_.step_in_enabled_ = (step_action >= StepIn); | 857 thread_local_.step_in_enabled_ = (step_action >= StepIn); |
864 if (step_action == StepOut) { | 858 if (step_action == StepOut) { |
865 // For step out target frame will be found on the stack so there is no need | 859 // For step out target frame will be found on the stack so there is no need |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 } | 2507 } |
2514 | 2508 |
2515 | 2509 |
2516 void LockingCommandMessageQueue::Clear() { | 2510 void LockingCommandMessageQueue::Clear() { |
2517 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2511 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2518 queue_.Clear(); | 2512 queue_.Clear(); |
2519 } | 2513 } |
2520 | 2514 |
2521 } // namespace internal | 2515 } // namespace internal |
2522 } // namespace v8 | 2516 } // namespace v8 |
OLD | NEW |