| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 bool* caught_exception); | 411 bool* caught_exception); |
| 412 static Handle<Object> MakeExceptionEvent(Handle<Object> exec_state, | 412 static Handle<Object> MakeExceptionEvent(Handle<Object> exec_state, |
| 413 Handle<Object> exception, | 413 Handle<Object> exception, |
| 414 bool uncaught, | 414 bool uncaught, |
| 415 bool* caught_exception); | 415 bool* caught_exception); |
| 416 static Handle<Object> MakeNewFunctionEvent(Handle<Object> func, | 416 static Handle<Object> MakeNewFunctionEvent(Handle<Object> func, |
| 417 bool* caught_exception); | 417 bool* caught_exception); |
| 418 static Handle<Object> MakeCompileEvent(Handle<Script> script, | 418 static Handle<Object> MakeCompileEvent(Handle<Script> script, |
| 419 bool before, | 419 bool before, |
| 420 bool* caught_exception); | 420 bool* caught_exception); |
| 421 static void OnDebugBreak(Handle<Object> break_points_hit); | 421 static void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); |
| 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 static void SetEventListener(Handle<Object> callback, Handle<Object> data); | 430 static void SetEventListener(Handle<Object> callback, Handle<Object> data); |
| 430 static void SetMessageHandler(v8::DebugMessageHandler handler, void* data); | 431 static void SetMessageHandler(v8::DebugMessageHandler handler, void* data); |
| 431 static void SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, | 432 static void SetHostDispatchHandler(v8::DebugHostDispatchHandler handler, |
| 432 void* data); | 433 void* data); |
| 433 static void SendMessage(Vector<uint16_t> message); | 434 static void SendMessage(Vector<uint16_t> message); |
| 434 static void ProcessCommand(Vector<const uint16_t> command); | 435 static void ProcessCommand(Vector<const uint16_t> command); |
| 436 static bool HasCommands(); |
| 435 static void ProcessHostDispatch(void* dispatch); | 437 static void ProcessHostDispatch(void* dispatch); |
| 436 static void UpdateActiveDebugger(); | 438 static void UpdateActiveDebugger(); |
| 437 static Handle<Object> Call(Handle<JSFunction> fun, | 439 static Handle<Object> Call(Handle<JSFunction> fun, |
| 438 Handle<Object> data, | 440 Handle<Object> data, |
| 439 bool* pending_exception); | 441 bool* pending_exception); |
| 440 | 442 |
| 441 // Start the debugger agent listening on the provided port. | 443 // Start the debugger agent listening on the provided port. |
| 442 static bool StartAgent(int port); | 444 static bool StartAgent(int port); |
| 443 | 445 |
| 444 inline static bool EventActive(v8::DebugEvent event) { | 446 inline static bool EventActive(v8::DebugEvent event) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 */ | 523 */ |
| 522 class DebugMessageThread: public Thread { | 524 class DebugMessageThread: public Thread { |
| 523 public: | 525 public: |
| 524 DebugMessageThread(); // Called from API thread. | 526 DebugMessageThread(); // Called from API thread. |
| 525 virtual ~DebugMessageThread(); // Never called. | 527 virtual ~DebugMessageThread(); // Never called. |
| 526 // Called by V8 thread. Reports events from V8 VM. | 528 // Called by V8 thread. Reports events from V8 VM. |
| 527 // Also handles command processing in stopped state of V8, | 529 // Also handles command processing in stopped state of V8, |
| 528 // when host_running_ is false. | 530 // when host_running_ is false. |
| 529 void DebugEvent(v8::DebugEvent, | 531 void DebugEvent(v8::DebugEvent, |
| 530 Handle<Object> exec_state, | 532 Handle<Object> exec_state, |
| 531 Handle<Object> event_data); | 533 Handle<Object> event_data, |
| 534 bool auto_continue); |
| 532 // Puts event on the output queue. Called by V8. | 535 // Puts event on the output queue. Called by V8. |
| 533 // This is where V8 hands off | 536 // This is where V8 hands off |
| 534 // processing of the event to the DebugMessageThread thread, | 537 // processing of the event to the DebugMessageThread thread, |
| 535 // which forwards it to the debug_message_handler set by the API. | 538 // which forwards it to the debug_message_handler set by the API. |
| 536 void SendMessage(Vector<uint16_t> event_json); | 539 void SendMessage(Vector<uint16_t> event_json); |
| 537 // Formats an event into JSON, and calls SendMessage. | 540 // Formats an event into JSON, and calls SendMessage. |
| 538 bool SetEventJSONFromEvent(Handle<Object> event_data); | 541 bool SetEventJSONFromEvent(Handle<Object> event_data); |
| 539 // Puts a command coming from the public API on the queue. Called | 542 // Puts a command coming from the public API on the queue. Called |
| 540 // by the API client thread. This is where the API client hands off | 543 // by the API client thread. This is where the API client hands off |
| 541 // processing of the command to the DebugMessageThread thread. | 544 // processing of the command to the DebugMessageThread thread. |
| 542 void ProcessCommand(Vector<uint16_t> command); | 545 void ProcessCommand(Vector<uint16_t> command); |
| 543 void ProcessHostDispatch(void* dispatch); | 546 void ProcessHostDispatch(void* dispatch); |
| 544 void OnDebuggerInactive(); | 547 void OnDebuggerInactive(); |
| 545 | 548 |
| 546 // Main function of DebugMessageThread thread. | 549 // Main function of DebugMessageThread thread. |
| 547 void Run(); | 550 void Run(); |
| 548 | 551 |
| 552 // Check whether there are commands in the queue. |
| 553 bool HasCommands() { return !command_queue_.IsEmpty(); } |
| 554 |
| 549 bool host_running_; // Is the debugging host running or stopped? | 555 bool host_running_; // Is the debugging host running or stopped? |
| 550 Semaphore* command_received_; // Non-zero when command queue is non-empty. | 556 Semaphore* command_received_; // Non-zero when command queue is non-empty. |
| 551 Semaphore* message_received_; // Exactly equal to message queue length. | 557 Semaphore* message_received_; // Exactly equal to message queue length. |
| 552 private: | 558 private: |
| 553 bool TwoByteEqualsAscii(Vector<uint16_t> two_byte, const char* ascii); | 559 bool TwoByteEqualsAscii(Vector<uint16_t> two_byte, const char* ascii); |
| 554 | 560 |
| 555 static const int kQueueInitialSize = 4; | 561 static const int kQueueInitialSize = 4; |
| 556 LockingMessageQueue command_queue_; | 562 LockingMessageQueue command_queue_; |
| 557 LockingMessageQueue message_queue_; | 563 LockingMessageQueue message_queue_; |
| 558 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); | 564 DISALLOW_COPY_AND_ASSIGN(DebugMessageThread); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 Debug::SetBreak(break_frame_id_, break_id_); | 615 Debug::SetBreak(break_frame_id_, break_id_); |
| 610 | 616 |
| 611 // Request preemption when leaving the last debugger entry and a preemption | 617 // Request preemption when leaving the last debugger entry and a preemption |
| 612 // had been recorded while debugging. This is to avoid starvation in some | 618 // had been recorded while debugging. This is to avoid starvation in some |
| 613 // debugging scenarios. | 619 // debugging scenarios. |
| 614 if (prev_ == NULL && Debug::preemption_pending()) { | 620 if (prev_ == NULL && Debug::preemption_pending()) { |
| 615 StackGuard::Preempt(); | 621 StackGuard::Preempt(); |
| 616 Debug::set_preemption_pending(false); | 622 Debug::set_preemption_pending(false); |
| 617 } | 623 } |
| 618 | 624 |
| 625 // If there are commands in the queue when leaving the debugger request that |
| 626 // these commands are processed. |
| 627 if (prev_ == NULL && Debugger::HasCommands()) { |
| 628 StackGuard::DebugCommand(); |
| 629 } |
| 630 |
| 619 // Leaving this debugger entry. | 631 // Leaving this debugger entry. |
| 620 Debug::set_debugger_entry(prev_); | 632 Debug::set_debugger_entry(prev_); |
| 621 } | 633 } |
| 622 | 634 |
| 623 // Check whether the debugger could be entered. | 635 // Check whether the debugger could be entered. |
| 624 inline bool FailedToEnter() { return load_failed_; } | 636 inline bool FailedToEnter() { return load_failed_; } |
| 625 | 637 |
| 626 // Check whether there are any JavaScript frames on the stack. | 638 // Check whether there are any JavaScript frames on the stack. |
| 627 inline bool HasJavaScriptFrames() { return has_js_frames_; } | 639 inline bool HasJavaScriptFrames() { return has_js_frames_; } |
| 628 | 640 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 705 } |
| 694 private: | 706 private: |
| 695 Debug::AddressId id_; | 707 Debug::AddressId id_; |
| 696 int reg_; | 708 int reg_; |
| 697 }; | 709 }; |
| 698 | 710 |
| 699 | 711 |
| 700 } } // namespace v8::internal | 712 } } // namespace v8::internal |
| 701 | 713 |
| 702 #endif // V8_V8_DEBUG_H_ | 714 #endif // V8_V8_DEBUG_H_ |
| OLD | NEW |