Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Side by Side Diff: src/debug.h

Issue 56102: Change handling of debugger unloading (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // Send the JSON message for a debug event. 488 // Send the JSON message for a debug event.
489 static bool SendEventMessage(Handle<Object> event_data); 489 static bool SendEventMessage(Handle<Object> event_data);
490 490
491 // Add a debugger command to the command queue. 491 // Add a debugger command to the command queue.
492 static void ProcessCommand(Vector<const uint16_t> command); 492 static void ProcessCommand(Vector<const uint16_t> command);
493 493
494 // Check whether there are commands in the command queue. 494 // Check whether there are commands in the command queue.
495 static bool HasCommands(); 495 static bool HasCommands();
496 496
497 static void ProcessHostDispatch(void* dispatch); 497 static void ProcessHostDispatch(void* dispatch);
498 static void UpdateActiveDebugger();
499 static Handle<Object> Call(Handle<JSFunction> fun, 498 static Handle<Object> Call(Handle<JSFunction> fun,
500 Handle<Object> data, 499 Handle<Object> data,
501 bool* pending_exception); 500 bool* pending_exception);
502 501
503 // Start the debugger agent listening on the provided port. 502 // Start the debugger agent listening on the provided port.
504 static bool StartAgent(const char* name, int port); 503 static bool StartAgent(const char* name, int port);
505 504
506 // Stop the debugger agent. 505 // Stop the debugger agent.
507 static void StopAgent(); 506 static void StopAgent();
508 507
508 // Unload the debugger if possible. Only called when no debugger is currently
509 // active.
510 static void UnloadDebugger();
511
509 inline static bool EventActive(v8::DebugEvent event) { 512 inline static bool EventActive(v8::DebugEvent event) {
513 ScopedLock with(debugger_access_);
514
515 // Check whether the message handler was been cleared.
516 if (message_handler_cleared_) {
517 UnloadDebugger();
518 }
519
510 // Currently argument event is not used. 520 // Currently argument event is not used.
511 return !Debugger::compiling_natives_ && Debugger::debugger_active_; 521 return !compiling_natives_ && Debugger::IsDebuggerActive();
512 } 522 }
513 523
514 static void set_debugger_active(bool debugger_active) {
515 Debugger::debugger_active_ = debugger_active;
516 }
517 static bool debugger_active() { return Debugger::debugger_active_; }
518 static void set_compiling_natives(bool compiling_natives) { 524 static void set_compiling_natives(bool compiling_natives) {
519 Debugger::compiling_natives_ = compiling_natives; 525 Debugger::compiling_natives_ = compiling_natives;
520 } 526 }
521 static bool compiling_natives() { return Debugger::compiling_natives_; } 527 static bool compiling_natives() { return Debugger::compiling_natives_; }
522 static void set_loading_debugger(bool v) { is_loading_debugger_ = v; } 528 static void set_loading_debugger(bool v) { is_loading_debugger_ = v; }
523 static bool is_loading_debugger() { return Debugger::is_loading_debugger_; } 529 static bool is_loading_debugger() { return Debugger::is_loading_debugger_; }
524 530
525 private: 531 private:
526 static Handle<Object> event_listener_; // Global handle to listener 532 static bool IsDebuggerActive();
533
534 static Mutex* debugger_access_; // Mutex guarding debugger variables.
535 static Handle<Object> event_listener_; // Global handle to listener.
527 static Handle<Object> event_listener_data_; 536 static Handle<Object> event_listener_data_;
528 static bool debugger_active_; // Are there any active debugger?
529 static bool compiling_natives_; // Are we compiling natives? 537 static bool compiling_natives_; // Are we compiling natives?
530 static bool is_loading_debugger_; // Are we loading the debugger? 538 static bool is_loading_debugger_; // Are we loading the debugger?
539 static bool never_unload_debugger_; // Can we unload the debugger?
531 static DebugMessageThread* message_thread_; 540 static DebugMessageThread* message_thread_;
532 static v8::DebugMessageHandler message_handler_; 541 static v8::DebugMessageHandler message_handler_;
542 static bool message_handler_cleared_; // Was message handler cleared?
533 static void* message_handler_data_; 543 static void* message_handler_data_;
534 static v8::DebugHostDispatchHandler host_dispatch_handler_; 544 static v8::DebugHostDispatchHandler host_dispatch_handler_;
535 static void* host_dispatch_handler_data_; 545 static void* host_dispatch_handler_data_;
536 546
537 static DebuggerAgent* agent_; 547 static DebuggerAgent* agent_;
538 548
539 static const int kQueueInitialSize = 4; 549 static const int kQueueInitialSize = 4;
540 static LockingMessageQueue command_queue_; 550 static LockingMessageQueue command_queue_;
541 static LockingMessageQueue message_queue_; 551 static LockingMessageQueue message_queue_;
542 static Semaphore* command_received_; // Signaled for each command received. 552 static Semaphore* command_received_; // Signaled for each command received.
543 static Semaphore* message_received_; // Signalled for each message send. 553 static Semaphore* message_received_; // Signalled for each message send.
544 554
555 friend class EnterDebugger;
545 friend class DebugMessageThread; 556 friend class DebugMessageThread;
546 }; 557 };
547 558
548 559
549 // Thread to read messages from the message queue and invoke the debug message 560 // Thread to read messages from the message queue and invoke the debug message
550 // handler in another thread as the V8 thread. This thread is started if the 561 // handler in another thread as the V8 thread. This thread is started if the
551 // registration of the debug message handler requested to be called in a thread 562 // registration of the debug message handler requested to be called in a thread
552 // seperate from the V8 thread. 563 // seperate from the V8 thread.
553 class DebugMessageThread: public Thread { 564 class DebugMessageThread: public Thread {
554 public: 565 public:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 StackGuard::Preempt(); 622 StackGuard::Preempt();
612 Debug::set_preemption_pending(false); 623 Debug::set_preemption_pending(false);
613 } 624 }
614 625
615 // If there are commands in the queue when leaving the debugger request that 626 // If there are commands in the queue when leaving the debugger request that
616 // these commands are processed. 627 // these commands are processed.
617 if (prev_ == NULL && Debugger::HasCommands()) { 628 if (prev_ == NULL && Debugger::HasCommands()) {
618 StackGuard::DebugCommand(); 629 StackGuard::DebugCommand();
619 } 630 }
620 631
632 // If leaving the debugger with the debugger no longer active unload it.
633 if (prev_ == NULL) {
634 if (!Debugger::IsDebuggerActive()) {
635 Debugger::UnloadDebugger();
636 }
637 }
638
621 // Leaving this debugger entry. 639 // Leaving this debugger entry.
622 Debug::set_debugger_entry(prev_); 640 Debug::set_debugger_entry(prev_);
623 } 641 }
624 642
625 // Check whether the debugger could be entered. 643 // Check whether the debugger could be entered.
626 inline bool FailedToEnter() { return load_failed_; } 644 inline bool FailedToEnter() { return load_failed_; }
627 645
628 // Check whether there are any JavaScript frames on the stack. 646 // Check whether there are any JavaScript frames on the stack.
629 inline bool HasJavaScriptFrames() { return has_js_frames_; } 647 inline bool HasJavaScriptFrames() { return has_js_frames_; }
630 648
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } 713 }
696 private: 714 private:
697 Debug::AddressId id_; 715 Debug::AddressId id_;
698 int reg_; 716 int reg_;
699 }; 717 };
700 718
701 719
702 } } // namespace v8::internal 720 } } // namespace v8::internal
703 721
704 #endif // V8_V8_DEBUG_H_ 722 #endif // V8_V8_DEBUG_H_
OLDNEW
« no previous file with comments | « no previous file | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698