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

Side by Side Diff: src/debug.cc

Issue 7780033: Debugger: fix stepping next with trycatch recursion (Closed) Base URL: gh:indutny/v8@master
Patch Set: remove queued_step_action_ Created 9 years, 3 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
« no previous file with comments | « src/debug.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 535
536 // Threading support. 536 // Threading support.
537 void Debug::ThreadInit() { 537 void Debug::ThreadInit() {
538 thread_local_.break_count_ = 0; 538 thread_local_.break_count_ = 0;
539 thread_local_.break_id_ = 0; 539 thread_local_.break_id_ = 0;
540 thread_local_.break_frame_id_ = StackFrame::NO_ID; 540 thread_local_.break_frame_id_ = StackFrame::NO_ID;
541 thread_local_.last_step_action_ = StepNone; 541 thread_local_.last_step_action_ = StepNone;
542 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; 542 thread_local_.last_statement_position_ = RelocInfo::kNoPosition;
543 thread_local_.step_count_ = 0; 543 thread_local_.step_count_ = 0;
544 thread_local_.last_fp_ = 0; 544 thread_local_.last_fp_ = 0;
545 thread_local_.queued_step_count_ = 0;
545 thread_local_.step_into_fp_ = 0; 546 thread_local_.step_into_fp_ = 0;
546 thread_local_.step_out_fp_ = 0; 547 thread_local_.step_out_fp_ = 0;
547 thread_local_.after_break_target_ = 0; 548 thread_local_.after_break_target_ = 0;
548 // TODO(isolates): frames_are_dropped_? 549 // TODO(isolates): frames_are_dropped_?
549 thread_local_.debugger_entry_ = NULL; 550 thread_local_.debugger_entry_ = NULL;
550 thread_local_.pending_interrupts_ = 0; 551 thread_local_.pending_interrupts_ = 0;
551 thread_local_.restarter_frame_function_pointer_ = NULL; 552 thread_local_.restarter_frame_function_pointer_ = NULL;
552 } 553 }
553 554
554 555
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 ASSERT(thread_local_.step_count_ == 0); 951 ASSERT(thread_local_.step_count_ == 0);
951 } else if (!break_points_hit->IsUndefined() || 952 } else if (!break_points_hit->IsUndefined() ||
952 (thread_local_.last_step_action_ != StepNone && 953 (thread_local_.last_step_action_ != StepNone &&
953 thread_local_.step_count_ == 0)) { 954 thread_local_.step_count_ == 0)) {
954 // Notify debugger if a real break point is triggered or if performing 955 // Notify debugger if a real break point is triggered or if performing
955 // single stepping with no more steps to perform. Otherwise do another step. 956 // single stepping with no more steps to perform. Otherwise do another step.
956 957
957 // Clear all current stepping setup. 958 // Clear all current stepping setup.
958 ClearStepping(); 959 ClearStepping();
959 960
960 // Notify the debug event listeners. 961 if (thread_local_.queued_step_count_ > 0) {
961 isolate_->debugger()->OnDebugBreak(break_points_hit, false); 962 // Perform queued steps
963 int step_count = thread_local_.queued_step_count_;
964
965 // Clear queue
966 thread_local_.queued_step_count_ = 0;
967
968 PrepareStep(StepNext, step_count);
969 } else {
970 // Notify the debug event listeners.
971 isolate_->debugger()->OnDebugBreak(break_points_hit, false);
972 }
962 } else if (thread_local_.last_step_action_ != StepNone) { 973 } else if (thread_local_.last_step_action_ != StepNone) {
963 // Hold on to last step action as it is cleared by the call to 974 // Hold on to last step action as it is cleared by the call to
964 // ClearStepping. 975 // ClearStepping.
965 StepAction step_action = thread_local_.last_step_action_; 976 StepAction step_action = thread_local_.last_step_action_;
966 int step_count = thread_local_.step_count_; 977 int step_count = thread_local_.step_count_;
967 978
979 // If StepNext gone deeper in code
980 // StepOut until original frame
981 if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) {
982 // Count frames until target frame
983 int count = 0;
984 JavaScriptFrameIterator it(isolate_);
985 while (!it.done() && it.frame()->fp() != thread_local_.last_fp_) {
986 count++;
987 it.Advance();
988 }
989
990 // If we found original frame
991 if (it.frame()->fp() == thread_local_.last_fp_) {
992 if (step_count > 1) {
993 // Save old count and action to continue stepping after
994 // StepOut
995 thread_local_.queued_step_count_ = step_count - 1;
996 }
997
998 // Set up for StepOut to reach target frame
999 step_action = StepOut;
1000 step_count = count;
1001 }
1002 }
1003
968 // Clear all current stepping setup. 1004 // Clear all current stepping setup.
969 ClearStepping(); 1005 ClearStepping();
970 1006
971 // Set up for the remaining steps. 1007 // Set up for the remaining steps.
972 PrepareStep(step_action, step_count); 1008 PrepareStep(step_action, step_count);
973 } 1009 }
974 1010
975 if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) { 1011 if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) {
976 SetAfterBreakTarget(frame); 1012 SetAfterBreakTarget(frame);
977 } else if (thread_local_.frame_drop_mode_ == 1013 } else if (thread_local_.frame_drop_mode_ ==
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1477
1442 1478
1443 // Check whether the current debug break should be reported to the debugger. It 1479 // Check whether the current debug break should be reported to the debugger. It
1444 // is used to have step next and step in only report break back to the debugger 1480 // is used to have step next and step in only report break back to the debugger
1445 // if on a different frame or in a different statement. In some situations 1481 // if on a different frame or in a different statement. In some situations
1446 // there will be several break points in the same statement when the code is 1482 // there will be several break points in the same statement when the code is
1447 // flooded with one-shot break points. This function helps to perform several 1483 // flooded with one-shot break points. This function helps to perform several
1448 // steps before reporting break back to the debugger. 1484 // steps before reporting break back to the debugger.
1449 bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator, 1485 bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator,
1450 JavaScriptFrame* frame) { 1486 JavaScriptFrame* frame) {
1487 // StepNext and StepOut shouldn't bring us deeper in code
1488 // So last frame shouldn't be a one of parents of current frame
1489 if (thread_local_.last_step_action_ == StepNext ||
1490 thread_local_.last_step_action_ == StepOut) {
1491 if (frame->fp() < thread_local_.last_fp_) return true;
1492 }
1493
1451 // If the step last action was step next or step in make sure that a new 1494 // If the step last action was step next or step in make sure that a new
1452 // statement is hit. 1495 // statement is hit.
1453 if (thread_local_.last_step_action_ == StepNext || 1496 if (thread_local_.last_step_action_ == StepNext ||
1454 thread_local_.last_step_action_ == StepIn) { 1497 thread_local_.last_step_action_ == StepIn) {
1455 // Never continue if returning from function. 1498 // Never continue if returning from function.
1456 if (break_location_iterator->IsExit()) return false; 1499 if (break_location_iterator->IsExit()) return false;
1457 1500
1458 // Continue if we are still on the same frame and in the same statement. 1501 // Continue if we are still on the same frame and in the same statement.
1459 int current_statement_position = 1502 int current_statement_position =
1460 break_location_iterator->code()->SourceStatementPosition(frame->pc()); 1503 break_location_iterator->code()->SourceStatementPosition(frame->pc());
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 { 3169 {
3127 Locker locker; 3170 Locker locker;
3128 Isolate::Current()->debugger()->CallMessageDispatchHandler(); 3171 Isolate::Current()->debugger()->CallMessageDispatchHandler();
3129 } 3172 }
3130 } 3173 }
3131 } 3174 }
3132 3175
3133 #endif // ENABLE_DEBUGGER_SUPPORT 3176 #endif // ENABLE_DEBUGGER_SUPPORT
3134 3177
3135 } } // namespace v8::internal 3178 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698