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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 // Threading support. | 323 // Threading support. |
324 void Debug::ThreadInit() { | 324 void Debug::ThreadInit() { |
325 thread_local_.break_count_ = 0; | 325 thread_local_.break_count_ = 0; |
326 thread_local_.break_id_ = 0; | 326 thread_local_.break_id_ = 0; |
327 thread_local_.break_frame_id_ = StackFrame::NO_ID; | 327 thread_local_.break_frame_id_ = StackFrame::NO_ID; |
328 thread_local_.last_step_action_ = StepNone; | 328 thread_local_.last_step_action_ = StepNone; |
329 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; | 329 thread_local_.last_statement_position_ = RelocInfo::kNoPosition; |
330 thread_local_.step_count_ = 0; | 330 thread_local_.step_count_ = 0; |
331 thread_local_.last_fp_ = 0; | 331 thread_local_.last_fp_ = 0; |
332 thread_local_.queued_step_count_ = 0; | |
333 thread_local_.step_out_fp_ = 0; | 332 thread_local_.step_out_fp_ = 0; |
334 thread_local_.step_in_enabled_ = false; | 333 thread_local_.step_in_enabled_ = false; |
335 // TODO(isolates): frames_are_dropped_? | 334 // TODO(isolates): frames_are_dropped_? |
336 base::NoBarrier_Store(&thread_local_.current_debug_scope_, | 335 base::NoBarrier_Store(&thread_local_.current_debug_scope_, |
337 static_cast<base::AtomicWord>(0)); | 336 static_cast<base::AtomicWord>(0)); |
338 } | 337 } |
339 | 338 |
340 | 339 |
341 char* Debug::ArchiveDebug(char* storage) { | 340 char* Debug::ArchiveDebug(char* storage) { |
342 char* to = storage; | 341 char* to = storage; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // Step count should always be 0 for StepOut. | 476 // Step count should always be 0 for StepOut. |
478 DCHECK(thread_local_.step_count_ == 0); | 477 DCHECK(thread_local_.step_count_ == 0); |
479 } else if (!break_points_hit->IsUndefined() || | 478 } else if (!break_points_hit->IsUndefined() || |
480 (thread_local_.last_step_action_ != StepNone && | 479 (thread_local_.last_step_action_ != StepNone && |
481 thread_local_.step_count_ == 0)) { | 480 thread_local_.step_count_ == 0)) { |
482 // Notify debugger if a real break point is triggered or if performing | 481 // Notify debugger if a real break point is triggered or if performing |
483 // single stepping with no more steps to perform. Otherwise do another step. | 482 // single stepping with no more steps to perform. Otherwise do another step. |
484 | 483 |
485 // Clear all current stepping setup. | 484 // Clear all current stepping setup. |
486 ClearStepping(); | 485 ClearStepping(); |
487 | 486 // Notify the debug event listeners. |
488 if (thread_local_.queued_step_count_ > 0) { | 487 OnDebugBreak(break_points_hit, false); |
489 // Perform queued steps | |
490 int step_count = thread_local_.queued_step_count_; | |
491 | |
492 // Clear queue | |
493 thread_local_.queued_step_count_ = 0; | |
494 | |
495 PrepareStep(StepNext, step_count); | |
496 } else { | |
497 // Notify the debug event listeners. | |
498 OnDebugBreak(break_points_hit, false); | |
499 } | |
500 } else if (thread_local_.last_step_action_ != StepNone) { | 488 } else if (thread_local_.last_step_action_ != StepNone) { |
501 // Hold on to last step action as it is cleared by the call to | 489 // Hold on to last step action as it is cleared by the call to |
502 // ClearStepping. | 490 // ClearStepping. |
503 StepAction step_action = thread_local_.last_step_action_; | 491 StepAction step_action = thread_local_.last_step_action_; |
504 int step_count = thread_local_.step_count_; | 492 int step_count = thread_local_.step_count_; |
505 | 493 |
506 // If StepNext goes deeper in code, StepOut until original frame | 494 // If StepNext goes deeper into code, just return. The functions we need |
507 // and keep step count queued up in the meantime. | 495 // to have flooded with one-shots are already flooded. |
508 if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) { | 496 if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) return; |
509 // Count frames until target frame | |
510 int count = 0; | |
511 JavaScriptFrameIterator it(isolate_); | |
512 while (!it.done() && it.frame()->fp() < thread_local_.last_fp_) { | |
513 count++; | |
514 it.Advance(); | |
515 } | |
516 | |
517 // Check that we indeed found the frame we are looking for. | |
518 CHECK(!it.done() && (it.frame()->fp() == thread_local_.last_fp_)); | |
519 if (step_count > 1) { | |
520 // Save old count and action to continue stepping after StepOut. | |
521 thread_local_.queued_step_count_ = step_count - 1; | |
522 } | |
523 | |
524 // Set up for StepOut to reach target frame. | |
525 step_action = StepOut; | |
526 step_count = count; | |
527 } | |
528 | 497 |
529 // Clear all current stepping setup. | 498 // Clear all current stepping setup. |
530 ClearStepping(); | 499 ClearStepping(); |
531 | 500 |
532 // Set up for the remaining steps. | 501 // Set up for the remaining steps. |
533 PrepareStep(step_action, step_count); | 502 PrepareStep(step_action, step_count); |
534 } | 503 } |
535 } | 504 } |
536 | 505 |
537 | 506 |
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2498 } | 2467 } |
2499 | 2468 |
2500 | 2469 |
2501 void LockingCommandMessageQueue::Clear() { | 2470 void LockingCommandMessageQueue::Clear() { |
2502 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2471 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2503 queue_.Clear(); | 2472 queue_.Clear(); |
2504 } | 2473 } |
2505 | 2474 |
2506 } // namespace internal | 2475 } // namespace internal |
2507 } // namespace v8 | 2476 } // namespace v8 |
OLD | NEW |