OLD | NEW |
---|---|
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 Loading... | |
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_action_ = StepNone; | |
546 thread_local_.queued_step_count_ = 0; | |
545 thread_local_.step_into_fp_ = 0; | 547 thread_local_.step_into_fp_ = 0; |
546 thread_local_.step_out_fp_ = 0; | 548 thread_local_.step_out_fp_ = 0; |
547 thread_local_.after_break_target_ = 0; | 549 thread_local_.after_break_target_ = 0; |
548 // TODO(isolates): frames_are_dropped_? | 550 // TODO(isolates): frames_are_dropped_? |
549 thread_local_.debugger_entry_ = NULL; | 551 thread_local_.debugger_entry_ = NULL; |
550 thread_local_.pending_interrupts_ = 0; | 552 thread_local_.pending_interrupts_ = 0; |
551 thread_local_.restarter_frame_function_pointer_ = NULL; | 553 thread_local_.restarter_frame_function_pointer_ = NULL; |
552 } | 554 } |
553 | 555 |
554 | 556 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 ASSERT(thread_local_.step_count_ == 0); | 952 ASSERT(thread_local_.step_count_ == 0); |
951 } else if (!break_points_hit->IsUndefined() || | 953 } else if (!break_points_hit->IsUndefined() || |
952 (thread_local_.last_step_action_ != StepNone && | 954 (thread_local_.last_step_action_ != StepNone && |
953 thread_local_.step_count_ == 0)) { | 955 thread_local_.step_count_ == 0)) { |
954 // Notify debugger if a real break point is triggered or if performing | 956 // 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. | 957 // single stepping with no more steps to perform. Otherwise do another step. |
956 | 958 |
957 // Clear all current stepping setup. | 959 // Clear all current stepping setup. |
958 ClearStepping(); | 960 ClearStepping(); |
959 | 961 |
960 // Notify the debug event listeners. | 962 if (thread_local_.queued_step_count_ > 0) { |
961 isolate_->debugger()->OnDebugBreak(break_points_hit, false); | 963 // Perform queued step |
964 StepAction step_action = thread_local_.queued_step_action_; | |
965 int step_count = thread_local_.queued_step_count_; | |
966 | |
967 // Clear queue | |
968 thread_local_.queued_step_action_ = StepNone; | |
969 thread_local_.queued_step_count_ = 0; | |
970 | |
971 PrepareStep(step_action, step_count); | |
972 } else { | |
973 // Notify the debug event listeners. | |
974 isolate_->debugger()->OnDebugBreak(break_points_hit, false); | |
975 } | |
962 } else if (thread_local_.last_step_action_ != StepNone) { | 976 } else if (thread_local_.last_step_action_ != StepNone) { |
963 // Hold on to last step action as it is cleared by the call to | 977 // Hold on to last step action as it is cleared by the call to |
964 // ClearStepping. | 978 // ClearStepping. |
965 StepAction step_action = thread_local_.last_step_action_; | 979 StepAction step_action = thread_local_.last_step_action_; |
966 int step_count = thread_local_.step_count_; | 980 int step_count = thread_local_.step_count_; |
967 | 981 |
982 // If StepNext gone deeper in code | |
983 // StepOut until original frame | |
984 if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) { | |
985 // Count frames until target frame | |
986 int count = 0; | |
987 JavaScriptFrameIterator it(isolate_); | |
988 while (!it.done() && it.frame()->fp() != thread_local_.last_fp_) { | |
989 count++; | |
990 it.Advance(); | |
991 } | |
992 | |
993 // If we found original frame | |
994 if (it.frame()->fp() == thread_local_.last_fp_) { | |
995 if (step_count > 1) { | |
996 // Save old count and action to continue stepping after | |
997 // StepOut | |
998 thread_local_.queued_step_action_ = step_action; | |
Yang
2011/09/13 14:23:16
From what I can see, the only step action that is
| |
999 thread_local_.queued_step_count_ = step_count - 1; | |
1000 } | |
1001 | |
1002 // Set up for StepOut to reach target frame | |
1003 step_action = StepOut; | |
1004 step_count = count; | |
1005 } | |
1006 } | |
1007 | |
968 // Clear all current stepping setup. | 1008 // Clear all current stepping setup. |
969 ClearStepping(); | 1009 ClearStepping(); |
970 | 1010 |
971 // Set up for the remaining steps. | 1011 // Set up for the remaining steps. |
972 PrepareStep(step_action, step_count); | 1012 PrepareStep(step_action, step_count); |
973 } | 1013 } |
974 | 1014 |
975 if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) { | 1015 if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) { |
976 SetAfterBreakTarget(frame); | 1016 SetAfterBreakTarget(frame); |
977 } else if (thread_local_.frame_drop_mode_ == | 1017 } else if (thread_local_.frame_drop_mode_ == |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1441 | 1481 |
1442 | 1482 |
1443 // Check whether the current debug break should be reported to the debugger. It | 1483 // 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 | 1484 // 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 | 1485 // 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 | 1486 // 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 | 1487 // flooded with one-shot break points. This function helps to perform several |
1448 // steps before reporting break back to the debugger. | 1488 // steps before reporting break back to the debugger. |
1449 bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator, | 1489 bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator, |
1450 JavaScriptFrame* frame) { | 1490 JavaScriptFrame* frame) { |
1491 // StepNext and StepOut shouldn't bring us deeper in code | |
1492 // So last frame shouldn't be a one of parents of current frame | |
1493 if (thread_local_.last_step_action_ == StepNext || | |
1494 thread_local_.last_step_action_ == StepOut) { | |
1495 if (frame->fp() < thread_local_.last_fp_) return true; | |
1496 } | |
1497 | |
1451 // If the step last action was step next or step in make sure that a new | 1498 // If the step last action was step next or step in make sure that a new |
1452 // statement is hit. | 1499 // statement is hit. |
1453 if (thread_local_.last_step_action_ == StepNext || | 1500 if (thread_local_.last_step_action_ == StepNext || |
1454 thread_local_.last_step_action_ == StepIn) { | 1501 thread_local_.last_step_action_ == StepIn) { |
1455 // Never continue if returning from function. | 1502 // Never continue if returning from function. |
1456 if (break_location_iterator->IsExit()) return false; | 1503 if (break_location_iterator->IsExit()) return false; |
1457 | 1504 |
1458 // Continue if we are still on the same frame and in the same statement. | 1505 // Continue if we are still on the same frame and in the same statement. |
1459 int current_statement_position = | 1506 int current_statement_position = |
1460 break_location_iterator->code()->SourceStatementPosition(frame->pc()); | 1507 break_location_iterator->code()->SourceStatementPosition(frame->pc()); |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3126 { | 3173 { |
3127 Locker locker; | 3174 Locker locker; |
3128 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3175 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
3129 } | 3176 } |
3130 } | 3177 } |
3131 } | 3178 } |
3132 | 3179 |
3133 #endif // ENABLE_DEBUGGER_SUPPORT | 3180 #endif // ENABLE_DEBUGGER_SUPPORT |
3134 | 3181 |
3135 } } // namespace v8::internal | 3182 } } // namespace v8::internal |
OLD | NEW |