Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); | 482 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); |
| 483 }; | 483 }; |
| 484 | 484 |
| 485 | 485 |
| 486 // This class is used for entering the debugger. Create an instance in the stack | 486 // This class is used for entering the debugger. Create an instance in the stack |
| 487 // to enter the debugger. This will set the current break state, make sure the | 487 // to enter the debugger. This will set the current break state, make sure the |
| 488 // debugger is loaded and switch to the debugger context. If the debugger for | 488 // debugger is loaded and switch to the debugger context. If the debugger for |
| 489 // some reason could not be entered FailedToEnter will return true. | 489 // some reason could not be entered FailedToEnter will return true. |
| 490 class EnterDebugger BASE_EMBEDDED { | 490 class EnterDebugger BASE_EMBEDDED { |
| 491 public: | 491 public: |
| 492 EnterDebugger() : set_(!it_.done()) { | 492 EnterDebugger() : has_js_frames_(!it_.done()) { |
| 493 // If there is no JavaScript frames on the stack don't switch to new break | 493 // Store the previous break id and frame id. |
| 494 // and break frame. | 494 break_id_ = Top::break_id(); |
| 495 if (set_) { | 495 break_frame_id_ = Top::break_frame_id(); |
| 496 // Store the previous break is and frame id. | |
| 497 break_id_ = Top::break_id(); | |
| 498 break_frame_id_ = Top::break_frame_id(); | |
| 499 | 496 |
| 500 // Create the new break info. | 497 // Create the new break info. If there is no JavaScript frames there is no |
| 498 // break frame id. | |
| 499 if (has_js_frames_) { | |
| 501 Top::new_break(it_.frame()->id()); | 500 Top::new_break(it_.frame()->id()); |
| 501 } else { | |
| 502 Top::new_break(StackFrame::NO_ID); | |
| 502 } | 503 } |
| 503 | 504 |
| 504 // Make sure that debugger is loaded and enter the debugger context. | 505 // Make sure that debugger is loaded and enter the debugger context. |
| 505 load_failed_ = !Debug::Load(); | 506 load_failed_ = !Debug::Load(); |
| 506 if (!load_failed_) { | 507 if (!load_failed_) { |
| 507 // NOTE the member variable save which saves the previous context before | 508 // NOTE the member variable save which saves the previous context before |
| 508 // this change. | 509 // this change. |
| 509 Top::set_context(*Debug::debug_context()); | 510 Top::set_context(*Debug::debug_context()); |
| 510 } | 511 } |
| 511 } | 512 } |
| 512 | 513 |
| 513 ~EnterDebugger() { | 514 ~EnterDebugger() { |
| 514 if (set_) { | 515 // Restore to the previous break state. |
| 515 // Restore to the previous break state. | 516 Top::set_break(break_frame_id_, break_id_); |
| 516 Top::set_break(break_frame_id_, break_id_); | |
| 517 } | |
| 518 } | 517 } |
| 519 | 518 |
| 520 // Check whether the debugger could be entered. | 519 // Check whether the debugger could be entered. |
| 521 inline bool FailedToEnter() { return load_failed_; } | 520 inline bool FailedToEnter() { return load_failed_; } |
| 522 | 521 |
| 523 // Check whether there are any JavaScript frames on the stack. | 522 // Check whether there are any JavaScript frames on the stack. |
| 524 inline bool HasJavaScriptFrames() { return set_; } | 523 inline bool HasJavaScriptFrames() { return has_js_frames_; } |
| 525 | 524 |
| 526 private: | 525 private: |
| 527 JavaScriptFrameIterator it_; | 526 JavaScriptFrameIterator it_; |
| 528 const bool set_; // Was the break actually set? | 527 const bool has_js_frames_; // Where there any JavaScript frames? |
|
Mads Ager (chromium)
2008/12/11 07:56:54
Where -> Were
Søren Thygesen Gjesse
2008/12/11 08:04:49
Done.
| |
| 529 StackFrame::Id break_frame_id_; // Previous break frame id. | 528 StackFrame::Id break_frame_id_; // Previous break frame id. |
| 530 int break_id_; // Previous break id. | 529 int break_id_; // Previous break id. |
| 531 bool load_failed_; // Did the debugger fail to load? | 530 bool load_failed_; // Did the debugger fail to load? |
| 532 SaveContext save_; // Saves previous context. | 531 SaveContext save_; // Saves previous context. |
| 533 }; | 532 }; |
| 534 | 533 |
| 535 | 534 |
| 536 // Stack allocated class for disabling break. | 535 // Stack allocated class for disabling break. |
| 537 class DisableBreak BASE_EMBEDDED { | 536 class DisableBreak BASE_EMBEDDED { |
| 538 public: | 537 public: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 } | 588 } |
| 590 private: | 589 private: |
| 591 Debug::AddressId id_; | 590 Debug::AddressId id_; |
| 592 int reg_; | 591 int reg_; |
| 593 }; | 592 }; |
| 594 | 593 |
| 595 | 594 |
| 596 } } // namespace v8::internal | 595 } } // namespace v8::internal |
| 597 | 596 |
| 598 #endif // V8_V8_DEBUG_H_ | 597 #endif // V8_V8_DEBUG_H_ |
| OLD | NEW |