| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 static void OnException(Handle<Object> exception, bool uncaught); | 422 static void OnException(Handle<Object> exception, bool uncaught); |
| 423 static void OnBeforeCompile(Handle<Script> script); | 423 static void OnBeforeCompile(Handle<Script> script); |
| 424 static void OnAfterCompile(Handle<Script> script, | 424 static void OnAfterCompile(Handle<Script> script, |
| 425 Handle<JSFunction> fun); | 425 Handle<JSFunction> fun); |
| 426 static void OnNewFunction(Handle<JSFunction> fun); | 426 static void OnNewFunction(Handle<JSFunction> fun); |
| 427 static void ProcessDebugEvent(v8::DebugEvent event, | 427 static void ProcessDebugEvent(v8::DebugEvent event, |
| 428 Handle<Object> event_data, | 428 Handle<Object> event_data, |
| 429 bool auto_continue); | 429 bool auto_continue); |
| 430 static void SetEventListener(Handle<Object> callback, Handle<Object> data); | 430 static void SetEventListener(Handle<Object> callback, Handle<Object> data); |
| 431 static void SetMessageHandler(v8::DebugMessageHandler handler, void* data); | 431 static void SetMessageHandler(v8::DebugMessageHandler handler, void* data); |
| 432 static void TearDown(); |
| 432 static void SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, | 433 static void SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, |
| 433 void* data); | 434 void* data); |
| 434 static void SendMessage(Vector<uint16_t> message); | 435 static void SendMessage(Vector<uint16_t> message); |
| 435 static void ProcessCommand(Vector<const uint16_t> command); | 436 static void ProcessCommand(Vector<const uint16_t> command); |
| 436 static bool HasCommands(); | 437 static bool HasCommands(); |
| 437 static void ProcessHostDispatch(void* dispatch); | 438 static void ProcessHostDispatch(void* dispatch); |
| 438 static void UpdateActiveDebugger(); | 439 static void UpdateActiveDebugger(); |
| 439 static Handle<Object> Call(Handle<JSFunction> fun, | 440 static Handle<Object> Call(Handle<JSFunction> fun, |
| 440 Handle<Object> data, | 441 Handle<Object> data, |
| 441 bool* pending_exception); | 442 bool* pending_exception); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 }; | 521 }; |
| 521 | 522 |
| 522 | 523 |
| 523 /* This class is the data for a running thread that serializes | 524 /* This class is the data for a running thread that serializes |
| 524 * event messages and command processing for the debugger. | 525 * event messages and command processing for the debugger. |
| 525 * All uncommented methods are called only from this message thread. | 526 * All uncommented methods are called only from this message thread. |
| 526 */ | 527 */ |
| 527 class DebugMessageThread: public Thread { | 528 class DebugMessageThread: public Thread { |
| 528 public: | 529 public: |
| 529 DebugMessageThread(); // Called from API thread. | 530 DebugMessageThread(); // Called from API thread. |
| 530 virtual ~DebugMessageThread(); // Never called. | 531 virtual ~DebugMessageThread(); |
| 531 // Called by V8 thread. Reports events from V8 VM. | 532 // Called by V8 thread. Reports events from V8 VM. |
| 532 // Also handles command processing in stopped state of V8, | 533 // Also handles command processing in stopped state of V8, |
| 533 // when host_running_ is false. | 534 // when host_running_ is false. |
| 534 void DebugEvent(v8::DebugEvent, | 535 void DebugEvent(v8::DebugEvent, |
| 535 Handle<Object> exec_state, | 536 Handle<Object> exec_state, |
| 536 Handle<Object> event_data, | 537 Handle<Object> event_data, |
| 537 bool auto_continue); | 538 bool auto_continue); |
| 538 // Puts event on the output queue. Called by V8. | 539 // Puts event on the output queue. Called by V8. |
| 539 // This is where V8 hands off | 540 // This is where V8 hands off |
| 540 // processing of the event to the DebugMessageThread thread, | 541 // processing of the event to the DebugMessageThread thread, |
| 541 // which forwards it to the debug_message_handler set by the API. | 542 // which forwards it to the debug_message_handler set by the API. |
| 542 void SendMessage(Vector<uint16_t> event_json); | 543 void SendMessage(Vector<uint16_t> event_json); |
| 543 // Formats an event into JSON, and calls SendMessage. | 544 // Formats an event into JSON, and calls SendMessage. |
| 544 bool SetEventJSONFromEvent(Handle<Object> event_data); | 545 bool SetEventJSONFromEvent(Handle<Object> event_data); |
| 545 // Puts a command coming from the public API on the queue. Called | 546 // Puts a command coming from the public API on the queue. Called |
| 546 // by the API client thread. This is where the API client hands off | 547 // by the API client thread. This is where the API client hands off |
| 547 // processing of the command to the DebugMessageThread thread. | 548 // processing of the command to the DebugMessageThread thread. |
| 548 void ProcessCommand(Vector<uint16_t> command); | 549 void ProcessCommand(Vector<uint16_t> command); |
| 549 void ProcessHostDispatch(void* dispatch); | 550 void ProcessHostDispatch(void* dispatch); |
| 550 void OnDebuggerInactive(); | 551 void OnDebuggerInactive(); |
| 551 | 552 |
| 552 // Main function of DebugMessageThread thread. | 553 // Main function of DebugMessageThread thread. |
| 553 void Run(); | 554 void Run(); |
| 554 | 555 |
| 555 // Check whether there are commands in the queue. | 556 // Check whether there are commands in the queue. |
| 556 bool HasCommands() { return !command_queue_.IsEmpty(); } | 557 bool HasCommands() { return !command_queue_.IsEmpty(); } |
| 558 void Stop(); |
| 557 | 559 |
| 558 bool host_running_; // Is the debugging host running or stopped? | 560 bool host_running_; // Is the debugging host running or stopped? |
| 559 Semaphore* command_received_; // Non-zero when command queue is non-empty. | 561 Semaphore* command_received_; // Non-zero when command queue is non-empty. |
| 560 Semaphore* message_received_; // Exactly equal to message queue length. | 562 Semaphore* message_received_; // Exactly equal to message queue length. |
| 561 private: | 563 private: |
| 562 bool TwoByteEqualsAscii(Vector<uint16_t> two_byte, const char* ascii); | 564 bool TwoByteEqualsAscii(Vector<uint16_t> two_byte, const char* ascii); |
| 563 | 565 |
| 564 static const int kQueueInitialSize = 4; | 566 static const int kQueueInitialSize = 4; |
| 565 LockingMessageQueue command_queue_; | 567 LockingMessageQueue command_queue_; |
| 566 LockingMessageQueue message_queue_; | 568 LockingMessageQueue message_queue_; |
| 569 bool keep_running_; |
| 567 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); | 570 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); |
| 568 }; | 571 }; |
| 569 | 572 |
| 570 | 573 |
| 571 // This class is used for entering the debugger. Create an instance in the stack | 574 // This class is used for entering the debugger. Create an instance in the stack |
| 572 // to enter the debugger. This will set the current break state, make sure the | 575 // to enter the debugger. This will set the current break state, make sure the |
| 573 // debugger is loaded and switch to the debugger context. If the debugger for | 576 // debugger is loaded and switch to the debugger context. If the debugger for |
| 574 // some reason could not be entered FailedToEnter will return true. | 577 // some reason could not be entered FailedToEnter will return true. |
| 575 class EnterDebugger BASE_EMBEDDED { | 578 class EnterDebugger BASE_EMBEDDED { |
| 576 public: | 579 public: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 } | 701 } |
| 699 private: | 702 private: |
| 700 Debug::AddressId id_; | 703 Debug::AddressId id_; |
| 701 int reg_; | 704 int reg_; |
| 702 }; | 705 }; |
| 703 | 706 |
| 704 | 707 |
| 705 } } // namespace v8::internal | 708 } } // namespace v8::internal |
| 706 | 709 |
| 707 #endif // V8_V8_DEBUG_H_ | 710 #endif // V8_V8_DEBUG_H_ |
| OLD | NEW |