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

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

Issue 8069002: Fixed deadlock in the debugger agent in Windows. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 | « src/platform-win32.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 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 5827 matching lines...) Expand 10 before | Expand all | Expand 10 after
5838 5838
5839 5839
5840 TEST(DebuggerAgent) { 5840 TEST(DebuggerAgent) {
5841 v8::V8::Initialize(); 5841 v8::V8::Initialize();
5842 i::Debugger* debugger = i::Isolate::Current()->debugger(); 5842 i::Debugger* debugger = i::Isolate::Current()->debugger();
5843 // Make sure these ports is not used by other tests to allow tests to run in 5843 // Make sure these ports is not used by other tests to allow tests to run in
5844 // parallel. 5844 // parallel.
5845 const int kPort1 = 5858; 5845 const int kPort1 = 5858;
5846 const int kPort2 = 5857; 5846 const int kPort2 = 5857;
5847 const int kPort3 = 5856; 5847 const int kPort3 = 5856;
5848 const int kPort4 = 5855;
5848 5849
5849 // Make a string with the port2 number. 5850 // Make a string with the port2 number.
5850 const int kPortBufferLen = 6; 5851 const int kPortBufferLen = 6;
5851 char port2_str[kPortBufferLen]; 5852 char port2_str[kPortBufferLen];
5852 OS::SNPrintF(i::Vector<char>(port2_str, kPortBufferLen), "%d", kPort2); 5853 OS::SNPrintF(i::Vector<char>(port2_str, kPortBufferLen), "%d", kPort2);
5854 char port4_str[kPortBufferLen];
5855 OS::SNPrintF(i::Vector<char>(port4_str, kPortBufferLen), "%d", kPort4);
5853 5856
5854 bool ok; 5857 bool ok;
5855 5858
5856 // Initialize the socket library. 5859 // Initialize the socket library.
5857 i::Socket::Setup(); 5860 i::Socket::Setup();
5858 5861
5859 // Test starting and stopping the agent without any client connection. 5862 // Test starting and stopping the agent without any client connection.
5860 debugger->StartAgent("test", kPort1); 5863 debugger->StartAgent("test", kPort1);
5861 debugger->StopAgent(); 5864 debugger->StopAgent();
5862 // Test starting the agent, connecting a client and shutting down the agent 5865 // Test starting the agent, connecting a client and shutting down the agent
(...skipping 15 matching lines...) Expand all
5878 5881
5879 // Test starting and stopping the agent with the required port already 5882 // Test starting and stopping the agent with the required port already
5880 // occoupied. 5883 // occoupied.
5881 i::Socket* server = i::OS::CreateSocket(); 5884 i::Socket* server = i::OS::CreateSocket();
5882 server->Bind(kPort3); 5885 server->Bind(kPort3);
5883 5886
5884 debugger->StartAgent("test", kPort3); 5887 debugger->StartAgent("test", kPort3);
5885 debugger->StopAgent(); 5888 debugger->StopAgent();
5886 5889
5887 delete server; 5890 delete server;
5891
5892 // Test responsiveness after connecting and disconnecting a client.
5893 ok = debugger->StartAgent("test", kPort4);
5894 CHECK(ok);
5895 client = i::OS::CreateSocket();
5896 ok = client->Connect("localhost", port4_str);
5897 CHECK(ok);
5898 ok = client->Receive(&buf, 1) == 1;
5899 CHECK(ok);
5900 ok = client->Send(
5901 "{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}", 49);
5902 CHECK(ok);
5903 client->Shutdown();
5904 delete client;
5905 // Is the server still responsive?
5906 client = i::OS::CreateSocket();
5907 ok = client->Connect("localhost", port4_str);
5908 CHECK(ok);
5909 client->Shutdown();
5910 delete client;
5911 debugger->StopAgent();
5888 } 5912 }
5889 5913
5890 5914
5891 class DebuggerAgentProtocolServerThread : public i::Thread { 5915 class DebuggerAgentProtocolServerThread : public i::Thread {
5892 public: 5916 public:
5893 explicit DebuggerAgentProtocolServerThread(int port) 5917 explicit DebuggerAgentProtocolServerThread(int port)
5894 : Thread("DebuggerAgentProtocolServerThread"), 5918 : Thread("DebuggerAgentProtocolServerThread"),
5895 port_(port), 5919 port_(port),
5896 server_(NULL), 5920 server_(NULL),
5897 client_(NULL), 5921 client_(NULL),
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
7289 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); 7313 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
7290 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); 7314 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
7291 7315
7292 // Get rid of the debug event listener. 7316 // Get rid of the debug event listener.
7293 v8::Debug::SetDebugEventListener(NULL); 7317 v8::Debug::SetDebugEventListener(NULL);
7294 CheckDebuggerUnloaded(); 7318 CheckDebuggerUnloaded();
7295 } 7319 }
7296 7320
7297 7321
7298 #endif // ENABLE_DEBUGGER_SUPPORT 7322 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698