| 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_V8_DEBUG_H_ | 28 #ifndef V8_V8_DEBUG_H_ |
| 29 #define V8_V8_DEBUG_H_ | 29 #define V8_V8_DEBUG_H_ |
| 30 | 30 |
| 31 #include "../include/v8-debug.h" | 31 #include "../include/v8-debug.h" |
| 32 #include "assembler.h" | 32 #include "assembler.h" |
| 33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
| 34 #include "execution.h" |
| 34 #include "factory.h" | 35 #include "factory.h" |
| 35 #include "platform.h" | 36 #include "platform.h" |
| 36 #include "string-stream.h" | 37 #include "string-stream.h" |
| 37 | 38 |
| 38 | 39 |
| 39 namespace v8 { namespace internal { | 40 namespace v8 { namespace internal { |
| 40 | 41 |
| 41 // Step actions. NOTE: These values are in macros.py as well. | 42 // Step actions. NOTE: These values are in macros.py as well. |
| 42 enum StepAction { | 43 enum StepAction { |
| 43 StepNone = -1, // Stepping not prepared. | 44 StepNone = -1, // Stepping not prepared. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 private: | 463 private: |
| 463 bool TwoByteEqualsAscii(Vector<uint16_t> two_byte, const char* ascii); | 464 bool TwoByteEqualsAscii(Vector<uint16_t> two_byte, const char* ascii); |
| 464 | 465 |
| 465 static const int kQueueInitialSize = 4; | 466 static const int kQueueInitialSize = 4; |
| 466 LockingMessageQueue command_queue_; | 467 LockingMessageQueue command_queue_; |
| 467 LockingMessageQueue message_queue_; | 468 LockingMessageQueue message_queue_; |
| 468 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); | 469 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); |
| 469 }; | 470 }; |
| 470 | 471 |
| 471 | 472 |
| 472 // Helper class to support saving/restoring the top break frame id. | 473 // This class is used for entering the debugger. Create an instance in the stack |
| 473 class SaveBreakFrame { | 474 // to enter the debugger. This will set the current break state, make sure the |
| 475 // debugger is loaded and switch to the debugger context. If the debugger for |
| 476 // some reason could not be entered FailedToEnter will return true. |
| 477 class EnterDebugger BASE_EMBEDDED { |
| 474 public: | 478 public: |
| 475 SaveBreakFrame() : set_(!it_.done()) { | 479 EnterDebugger() : set_(!it_.done()) { |
| 480 // If there is no JavaScript frames on the stack don't switch to new break |
| 481 // and break frame. |
| 476 if (set_) { | 482 if (set_) { |
| 477 // Store the previous break is and frame id. | 483 // Store the previous break is and frame id. |
| 478 break_id_ = Top::break_id(); | 484 break_id_ = Top::break_id(); |
| 479 break_frame_id_ = Top::break_frame_id(); | 485 break_frame_id_ = Top::break_frame_id(); |
| 480 | 486 |
| 481 // Create the new break info. | 487 // Create the new break info. |
| 482 Top::new_break(it_.frame()->id()); | 488 Top::new_break(it_.frame()->id()); |
| 483 } | 489 } |
| 490 |
| 491 // Make sure that debugger is loaded and enter the debugger context. |
| 492 load_failed_ = !Debug::Load(); |
| 493 if (!load_failed_) { |
| 494 // NOTE the member variable save which saves the previous context before |
| 495 // this change. |
| 496 Top::set_context(*Debug::debug_context()); |
| 497 Top::set_security_context(*Debug::debug_context()); |
| 498 } |
| 484 } | 499 } |
| 485 | 500 |
| 486 ~SaveBreakFrame() { | 501 ~EnterDebugger() { |
| 487 if (set_) { | 502 if (set_) { |
| 488 // restore to the previous break state. | 503 // Restore to the previous break state. |
| 489 Top::set_break(break_frame_id_, break_id_); | 504 Top::set_break(break_frame_id_, break_id_); |
| 490 } | 505 } |
| 491 } | 506 } |
| 492 | 507 |
| 508 // Check whether the debugger could be entered. |
| 509 inline bool FailedToEnter() { return load_failed_; } |
| 510 |
| 493 private: | 511 private: |
| 494 JavaScriptFrameIterator it_; | 512 JavaScriptFrameIterator it_; |
| 495 const bool set_; // Was the break actually set? | 513 const bool set_; // Was the break actually set? |
| 496 StackFrame::Id break_frame_id_; // Previous break frame id. | 514 StackFrame::Id break_frame_id_; // Previous break frame id. |
| 497 int break_id_; // Previous break id. | 515 int break_id_; // Previous break id. |
| 498 }; | 516 bool load_failed_; // Did the debugger fail to load? |
| 499 | 517 SaveContext save_; // Saves previous context. |
| 500 | |
| 501 class EnterDebuggerContext BASE_EMBEDDED { | |
| 502 public: | |
| 503 // Enter the debugger by storing the previous top context and setting the | |
| 504 // current top context to the debugger context. | |
| 505 EnterDebuggerContext() { | |
| 506 // NOTE the member variable save which saves the previous context before | |
| 507 // this change. | |
| 508 Top::set_context(*Debug::debug_context()); | |
| 509 Top::set_security_context(*Debug::debug_context()); | |
| 510 } | |
| 511 | |
| 512 private: | |
| 513 SaveContext save; | |
| 514 }; | 518 }; |
| 515 | 519 |
| 516 | 520 |
| 517 // Stack allocated class for disabling break. | 521 // Stack allocated class for disabling break. |
| 518 class DisableBreak BASE_EMBEDDED { | 522 class DisableBreak BASE_EMBEDDED { |
| 519 public: | 523 public: |
| 520 // Enter the debugger by storing the previous top context and setting the | 524 // Enter the debugger by storing the previous top context and setting the |
| 521 // current top context to the debugger context. | 525 // current top context to the debugger context. |
| 522 explicit DisableBreak(bool disable_break) { | 526 explicit DisableBreak(bool disable_break) { |
| 523 prev_disable_break_ = Debug::disable_break(); | 527 prev_disable_break_ = Debug::disable_break(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 574 } |
| 571 private: | 575 private: |
| 572 Debug::AddressId id_; | 576 Debug::AddressId id_; |
| 573 int reg_; | 577 int reg_; |
| 574 }; | 578 }; |
| 575 | 579 |
| 576 | 580 |
| 577 } } // namespace v8::internal | 581 } } // namespace v8::internal |
| 578 | 582 |
| 579 #endif // V8_V8_DEBUG_H_ | 583 #endif // V8_V8_DEBUG_H_ |
| OLD | NEW |