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

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

Issue 9227007: Version 3.8.6 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 11 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 | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-disasm-arm.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 v8::Local<v8::Array> a = v8::Array::New(10); 2736 v8::Local<v8::Array> a = v8::Array::New(10);
2737 for (int i = 0; i < 10; i++) { 2737 for (int i = 0; i < 10; i++) {
2738 a->Set(v8::Number::New(i), v8::Number::New(i)); 2738 a->Set(v8::Number::New(i), v8::Number::New(i));
2739 } 2739 }
2740 2740
2741 // Call function without any break points to ensure inlining is in place. 2741 // Call function without any break points to ensure inlining is in place.
2742 const int kArgc = 1; 2742 const int kArgc = 1;
2743 v8::Handle<v8::Value> args[kArgc] = { a }; 2743 v8::Handle<v8::Value> args[kArgc] = { a };
2744 foo->Call(env->Global(), kArgc, args); 2744 foo->Call(env->Global(), kArgc, args);
2745 2745
2746 // Setup break point and step through the function. 2746 // Set up break point and step through the function.
2747 SetBreakPoint(foo, 3); 2747 SetBreakPoint(foo, 3);
2748 step_action = StepNext; 2748 step_action = StepNext;
2749 break_point_hit_count = 0; 2749 break_point_hit_count = 0;
2750 foo->Call(env->Global(), kArgc, args); 2750 foo->Call(env->Global(), kArgc, args);
2751 2751
2752 // With stepping all break locations are hit. 2752 // With stepping all break locations are hit.
2753 CHECK_EQ(33, break_point_hit_count); 2753 CHECK_EQ(33, break_point_hit_count);
2754 2754
2755 v8::Debug::SetDebugEventListener(NULL); 2755 v8::Debug::SetDebugEventListener(NULL);
2756 CheckDebuggerUnloaded(); 2756 CheckDebuggerUnloaded();
(...skipping 26 matching lines...) Expand all
2783 v8::Local<v8::Array> a = v8::Array::New(10); 2783 v8::Local<v8::Array> a = v8::Array::New(10);
2784 for (int i = 0; i < 10; i++) { 2784 for (int i = 0; i < 10; i++) {
2785 a->Set(v8::Number::New(i), v8::Number::New(i)); 2785 a->Set(v8::Number::New(i), v8::Number::New(i));
2786 } 2786 }
2787 2787
2788 // Call function without any break points to ensure inlining is in place. 2788 // Call function without any break points to ensure inlining is in place.
2789 const int kArgc = 1; 2789 const int kArgc = 1;
2790 v8::Handle<v8::Value> args[kArgc] = { a }; 2790 v8::Handle<v8::Value> args[kArgc] = { a };
2791 foo->Call(env->Global(), kArgc, args); 2791 foo->Call(env->Global(), kArgc, args);
2792 2792
2793 // Setup break point and step through the function. 2793 // Set up break point and step through the function.
2794 SetBreakPoint(foo, 3); 2794 SetBreakPoint(foo, 3);
2795 step_action = StepNext; 2795 step_action = StepNext;
2796 break_point_hit_count = 0; 2796 break_point_hit_count = 0;
2797 foo->Call(env->Global(), kArgc, args); 2797 foo->Call(env->Global(), kArgc, args);
2798 2798
2799 // With stepping all break locations are hit. 2799 // With stepping all break locations are hit.
2800 CHECK_EQ(32, break_point_hit_count); 2800 CHECK_EQ(32, break_point_hit_count);
2801 2801
2802 v8::Debug::SetDebugEventListener(NULL); 2802 v8::Debug::SetDebugEventListener(NULL);
2803 CheckDebuggerUnloaded(); 2803 CheckDebuggerUnloaded();
(...skipping 23 matching lines...) Expand all
2827 "}\n" 2827 "}\n"
2828 "function V(x, y) {\n" 2828 "function V(x, y) {\n"
2829 " this.x = x;\n" 2829 " this.x = x;\n"
2830 " this.y = y;\n" 2830 " this.y = y;\n"
2831 "}\n", 2831 "}\n",
2832 "foo"); 2832 "foo");
2833 2833
2834 // Call function without any break points to ensure inlining is in place. 2834 // Call function without any break points to ensure inlining is in place.
2835 foo->Call(env->Global(), 0, NULL); 2835 foo->Call(env->Global(), 0, NULL);
2836 2836
2837 // Setup break point and step through the function. 2837 // Set up break point and step through the function.
2838 SetBreakPoint(foo, 4); 2838 SetBreakPoint(foo, 4);
2839 step_action = StepNext; 2839 step_action = StepNext;
2840 break_point_hit_count = 0; 2840 break_point_hit_count = 0;
2841 foo->Call(env->Global(), 0, NULL); 2841 foo->Call(env->Global(), 0, NULL);
2842 2842
2843 // With stepping all break locations are hit. 2843 // With stepping all break locations are hit.
2844 CHECK_EQ(53, break_point_hit_count); 2844 CHECK_EQ(53, break_point_hit_count);
2845 2845
2846 v8::Debug::SetDebugEventListener(NULL); 2846 v8::Debug::SetDebugEventListener(NULL);
2847 CheckDebuggerUnloaded(); 2847 CheckDebuggerUnloaded();
(...skipping 14 matching lines...) Expand all
2862 " var a = {a:1};\n" 2862 " var a = {a:1};\n"
2863 " for (var i = 0; i < 10; i++) {\n" 2863 " for (var i = 0; i < 10; i++) {\n"
2864 " a.a = 2\n" 2864 " a.a = 2\n"
2865 " }\n" 2865 " }\n"
2866 "}\n", 2866 "}\n",
2867 "foo"); 2867 "foo");
2868 2868
2869 // Call function without any break points to ensure inlining is in place. 2869 // Call function without any break points to ensure inlining is in place.
2870 foo->Call(env->Global(), 0, NULL); 2870 foo->Call(env->Global(), 0, NULL);
2871 2871
2872 // Setup break point and step through the function. 2872 // Set up break point and step through the function.
2873 SetBreakPoint(foo, 3); 2873 SetBreakPoint(foo, 3);
2874 step_action = StepNext; 2874 step_action = StepNext;
2875 break_point_hit_count = 0; 2875 break_point_hit_count = 0;
2876 foo->Call(env->Global(), 0, NULL); 2876 foo->Call(env->Global(), 0, NULL);
2877 2877
2878 // With stepping all expected break locations are hit. 2878 // With stepping all expected break locations are hit.
2879 CHECK_EQ(expected, break_point_hit_count); 2879 CHECK_EQ(expected, break_point_hit_count);
2880 2880
2881 v8::Debug::SetDebugEventListener(NULL); 2881 v8::Debug::SetDebugEventListener(NULL);
2882 CheckDebuggerUnloaded(); 2882 CheckDebuggerUnloaded();
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after
5702 " y_global = 5;\n" 5702 " y_global = 5;\n"
5703 " return x;\n" 5703 " return x;\n"
5704 "}\n" 5704 "}\n"
5705 "\n"; 5705 "\n";
5706 const char* source_2 = "cat(17);\n"; 5706 const char* source_2 = "cat(17);\n";
5707 5707
5708 v8::V8::Initialize(); 5708 v8::V8::Initialize();
5709 v8::HandleScope scope; 5709 v8::HandleScope scope;
5710 DebugLocalContext env; 5710 DebugLocalContext env;
5711 5711
5712 // Setup message and host dispatch handlers. 5712 // Set up message and host dispatch handlers.
5713 v8::Debug::SetMessageHandler2(HostDispatchMessageHandler); 5713 v8::Debug::SetMessageHandler2(HostDispatchMessageHandler);
5714 v8::Debug::SetHostDispatchHandler(HostDispatchDispatchHandler, 10 /* ms */); 5714 v8::Debug::SetHostDispatchHandler(HostDispatchDispatchHandler, 10 /* ms */);
5715 5715
5716 CompileRun(source_1); 5716 CompileRun(source_1);
5717 host_dispatch_barriers->barrier_1.Wait(); 5717 host_dispatch_barriers->barrier_1.Wait();
5718 host_dispatch_barriers->barrier_2.Wait(); 5718 host_dispatch_barriers->barrier_2.Wait();
5719 CompileRun(source_2); 5719 CompileRun(source_2);
5720 } 5720 }
5721 5721
5722 5722
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5790 static void DebugMessageHandler() { 5790 static void DebugMessageHandler() {
5791 debug_message_dispatch_barriers->semaphore_1->Signal(); 5791 debug_message_dispatch_barriers->semaphore_1->Signal();
5792 } 5792 }
5793 5793
5794 5794
5795 void DebugMessageDispatchV8Thread::Run() { 5795 void DebugMessageDispatchV8Thread::Run() {
5796 v8::V8::Initialize(); 5796 v8::V8::Initialize();
5797 v8::HandleScope scope; 5797 v8::HandleScope scope;
5798 DebugLocalContext env; 5798 DebugLocalContext env;
5799 5799
5800 // Setup debug message dispatch handler. 5800 // Set up debug message dispatch handler.
5801 v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler); 5801 v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler);
5802 5802
5803 CompileRun("var y = 1 + 2;\n"); 5803 CompileRun("var y = 1 + 2;\n");
5804 debug_message_dispatch_barriers->barrier_1.Wait(); 5804 debug_message_dispatch_barriers->barrier_1.Wait();
5805 debug_message_dispatch_barriers->semaphore_1->Wait(); 5805 debug_message_dispatch_barriers->semaphore_1->Wait();
5806 debug_message_dispatch_barriers->barrier_2.Wait(); 5806 debug_message_dispatch_barriers->barrier_2.Wait();
5807 } 5807 }
5808 5808
5809 5809
5810 void DebugMessageDispatchDebuggerThread::Run() { 5810 void DebugMessageDispatchDebuggerThread::Run() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5844 const int kPort3 = 5856; 5844 const int kPort3 = 5856;
5845 5845
5846 // Make a string with the port2 number. 5846 // Make a string with the port2 number.
5847 const int kPortBufferLen = 6; 5847 const int kPortBufferLen = 6;
5848 char port2_str[kPortBufferLen]; 5848 char port2_str[kPortBufferLen];
5849 OS::SNPrintF(i::Vector<char>(port2_str, kPortBufferLen), "%d", kPort2); 5849 OS::SNPrintF(i::Vector<char>(port2_str, kPortBufferLen), "%d", kPort2);
5850 5850
5851 bool ok; 5851 bool ok;
5852 5852
5853 // Initialize the socket library. 5853 // Initialize the socket library.
5854 i::Socket::Setup(); 5854 i::Socket::SetUp();
5855 5855
5856 // Test starting and stopping the agent without any client connection. 5856 // Test starting and stopping the agent without any client connection.
5857 debugger->StartAgent("test", kPort1); 5857 debugger->StartAgent("test", kPort1);
5858 debugger->StopAgent(); 5858 debugger->StopAgent();
5859 // Test starting the agent, connecting a client and shutting down the agent 5859 // Test starting the agent, connecting a client and shutting down the agent
5860 // with the client connected. 5860 // with the client connected.
5861 ok = debugger->StartAgent("test", kPort2); 5861 ok = debugger->StartAgent("test", kPort2);
5862 CHECK(ok); 5862 CHECK(ok);
5863 debugger->WaitForAgent(); 5863 debugger->WaitForAgent();
5864 i::Socket* client = i::OS::CreateSocket(); 5864 i::Socket* client = i::OS::CreateSocket();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5942 // parallel. 5942 // parallel.
5943 const int kPort = 5860; 5943 const int kPort = 5860;
5944 static const char* kLocalhost = "localhost"; 5944 static const char* kLocalhost = "localhost";
5945 5945
5946 // Make a string with the port number. 5946 // Make a string with the port number.
5947 const int kPortBufferLen = 6; 5947 const int kPortBufferLen = 6;
5948 char port_str[kPortBufferLen]; 5948 char port_str[kPortBufferLen];
5949 OS::SNPrintF(i::Vector<char>(port_str, kPortBufferLen), "%d", kPort); 5949 OS::SNPrintF(i::Vector<char>(port_str, kPortBufferLen), "%d", kPort);
5950 5950
5951 // Initialize the socket library. 5951 // Initialize the socket library.
5952 i::Socket::Setup(); 5952 i::Socket::SetUp();
5953 5953
5954 // Create a socket server to receive a debugger agent message. 5954 // Create a socket server to receive a debugger agent message.
5955 DebuggerAgentProtocolServerThread* server = 5955 DebuggerAgentProtocolServerThread* server =
5956 new DebuggerAgentProtocolServerThread(kPort); 5956 new DebuggerAgentProtocolServerThread(kPort);
5957 server->Start(); 5957 server->Start();
5958 server->WaitForListening(); 5958 server->WaitForListening();
5959 5959
5960 // Connect. 5960 // Connect.
5961 i::Socket* client = i::OS::CreateSocket(); 5961 i::Socket* client = i::OS::CreateSocket();
5962 CHECK(client != NULL); 5962 CHECK(client != NULL);
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
7286 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); 7286 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
7287 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); 7287 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
7288 7288
7289 // Get rid of the debug event listener. 7289 // Get rid of the debug event listener.
7290 v8::Debug::SetDebugEventListener(NULL); 7290 v8::Debug::SetDebugEventListener(NULL);
7291 CheckDebuggerUnloaded(); 7291 CheckDebuggerUnloaded();
7292 } 7292 }
7293 7293
7294 7294
7295 #endif // ENABLE_DEBUGGER_SUPPORT 7295 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698