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

Side by Side Diff: test/cctest/test-debug.cc

Issue 395013: Add DebugMessageDispatchHandler (Closed)
Patch Set: Created 11 years, 1 month 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
« include/v8-debug.h ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-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 4673 matching lines...) Expand 10 before | Expand all | Expand 10 after
4684 host_dispatch_barriers = &stack_allocated_host_dispatch_barriers; 4684 host_dispatch_barriers = &stack_allocated_host_dispatch_barriers;
4685 4685
4686 host_dispatch_v8_thread.Start(); 4686 host_dispatch_v8_thread.Start();
4687 host_dispatch_debugger_thread.Start(); 4687 host_dispatch_debugger_thread.Start();
4688 4688
4689 host_dispatch_v8_thread.Join(); 4689 host_dispatch_v8_thread.Join();
4690 host_dispatch_debugger_thread.Join(); 4690 host_dispatch_debugger_thread.Join();
4691 } 4691 }
4692 4692
4693 4693
4694 /* Test DebugMessageDispatch */
4695 /* In this test, the V8 thread waits for a message from the debug thread.
4696 * The DebugMessageDispatchHandler is executed from the debugger thread
4697 * which signals the V8 thread to wake up.
4698 */
4699
4700 class DebugMessageDispatchV8Thread : public v8::internal::Thread {
4701 public:
4702 void Run();
4703 };
4704
4705 class DebugMessageDispatchDebuggerThread : public v8::internal::Thread {
4706 public:
4707 void Run();
4708 };
4709
4710 Barriers* debug_message_dispatch_barriers;
4711
4712
4713 static void DebugMessageHandler() {
4714 debug_message_dispatch_barriers->semaphore_1->Signal();
4715 }
4716
4717
4718 void DebugMessageDispatchV8Thread::Run() {
4719 v8::HandleScope scope;
4720 DebugLocalContext env;
4721
4722 // Setup debug message dispatch handler.
4723 v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler);
4724
4725 CompileRun("var y = 1 + 2;\n");
4726 debug_message_dispatch_barriers->barrier_1.Wait();
4727 debug_message_dispatch_barriers->semaphore_1->Wait();
4728 debug_message_dispatch_barriers->barrier_2.Wait();
4729 }
4730
4731
4732 void DebugMessageDispatchDebuggerThread::Run() {
4733 debug_message_dispatch_barriers->barrier_1.Wait();
4734 SendContinueCommand();
4735 debug_message_dispatch_barriers->barrier_2.Wait();
4736 }
4737
4738 DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread;
4739 DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread;
4740
4741
4742 TEST(DebuggerDebugMessageDispatch) {
4743 i::FLAG_debugger_auto_break = true;
4744
4745 // Create a V8 environment
4746 Barriers stack_allocated_debug_message_dispatch_barriers;
4747 stack_allocated_debug_message_dispatch_barriers.Initialize();
4748 debug_message_dispatch_barriers = &stack_allocated_debug_message_dispatch_barr iers;
Søren Thygesen Gjesse 2009/11/18 08:40:57 Long line.
4749
4750 debug_message_dispatch_v8_thread.Start();
4751 debug_message_dispatch_debugger_thread.Start();
4752
4753 debug_message_dispatch_v8_thread.Join();
4754 debug_message_dispatch_debugger_thread.Join();
4755 }
4756
4757
4694 TEST(DebuggerAgent) { 4758 TEST(DebuggerAgent) {
4695 // Make sure these ports is not used by other tests to allow tests to run in 4759 // Make sure these ports is not used by other tests to allow tests to run in
4696 // parallel. 4760 // parallel.
4697 const int kPort1 = 5858; 4761 const int kPort1 = 5858;
4698 const int kPort2 = 5857; 4762 const int kPort2 = 5857;
4699 const int kPort3 = 5856; 4763 const int kPort3 = 5856;
4700 4764
4701 // Make a string with the port2 number. 4765 // Make a string with the port2 number.
4702 const int kPortBufferLen = 6; 4766 const int kPortBufferLen = 6;
4703 char port2_str[kPortBufferLen]; 4767 char port2_str[kPortBufferLen];
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
5598 break_point_hit_count = 0; 5662 break_point_hit_count = 0;
5599 max_break_point_hit_count = 10000; // 10000 => infinite loop. 5663 max_break_point_hit_count = 10000; // 10000 => infinite loop.
5600 foo->Call(env->Global(), 0, NULL); 5664 foo->Call(env->Global(), 0, NULL);
5601 5665
5602 // When keeping the debug break several break will happen. 5666 // When keeping the debug break several break will happen.
5603 CHECK_EQ(3, break_point_hit_count); 5667 CHECK_EQ(3, break_point_hit_count);
5604 5668
5605 v8::Debug::SetDebugEventListener(NULL); 5669 v8::Debug::SetDebugEventListener(NULL);
5606 CheckDebuggerUnloaded(); 5670 CheckDebuggerUnloaded();
5607 } 5671 }
OLDNEW
« include/v8-debug.h ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698