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

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

Issue 552068: Fix disable_break parameter (Closed)
Patch Set: merge Created 10 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
« no previous file with comments | « src/debug-delay.js ('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 4246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 * breakpoint is hit when enabled, and missed when disabled. 4257 * breakpoint is hit when enabled, and missed when disabled.
4258 */ 4258 */
4259 4259
4260 class BreakpointsV8Thread : public v8::internal::Thread { 4260 class BreakpointsV8Thread : public v8::internal::Thread {
4261 public: 4261 public:
4262 void Run(); 4262 void Run();
4263 }; 4263 };
4264 4264
4265 class BreakpointsDebuggerThread : public v8::internal::Thread { 4265 class BreakpointsDebuggerThread : public v8::internal::Thread {
4266 public: 4266 public:
4267 BreakpointsDebuggerThread(bool global_evaluate)
4268 : global_evaluate_(global_evaluate) {}
4267 void Run(); 4269 void Run();
4270
4271 private:
4272 bool global_evaluate_;
4268 }; 4273 };
4269 4274
4270 4275
4271 Barriers* breakpoints_barriers; 4276 Barriers* breakpoints_barriers;
4272 int break_event_breakpoint_id; 4277 int break_event_breakpoint_id;
4273 int evaluate_int_result; 4278 int evaluate_int_result;
4274 4279
4275 static void BreakpointsMessageHandler(const v8::Debug::Message& message) { 4280 static void BreakpointsMessageHandler(const v8::Debug::Message& message) {
4276 static char print_buffer[1000]; 4281 static char print_buffer[1000];
4277 v8::String::Value json(message.GetJSON()); 4282 v8::String::Value json(message.GetJSON());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4325 uint16_t buffer[kBufSize]; 4330 uint16_t buffer[kBufSize];
4326 4331
4327 const char* command_1 = "{\"seq\":101," 4332 const char* command_1 = "{\"seq\":101,"
4328 "\"type\":\"request\"," 4333 "\"type\":\"request\","
4329 "\"command\":\"setbreakpoint\"," 4334 "\"command\":\"setbreakpoint\","
4330 "\"arguments\":{\"type\":\"function\",\"target\":\"cat\",\"line\":3}}"; 4335 "\"arguments\":{\"type\":\"function\",\"target\":\"cat\",\"line\":3}}";
4331 const char* command_2 = "{\"seq\":102," 4336 const char* command_2 = "{\"seq\":102,"
4332 "\"type\":\"request\"," 4337 "\"type\":\"request\","
4333 "\"command\":\"setbreakpoint\"," 4338 "\"command\":\"setbreakpoint\","
4334 "\"arguments\":{\"type\":\"function\",\"target\":\"dog\",\"line\":3}}"; 4339 "\"arguments\":{\"type\":\"function\",\"target\":\"dog\",\"line\":3}}";
4335 const char* command_3 = "{\"seq\":103," 4340 const char* command_3;
4336 "\"type\":\"request\"," 4341 if (this->global_evaluate_) {
4337 "\"command\":\"evaluate\"," 4342 command_3 = "{\"seq\":103,"
4338 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":false}}"; 4343 "\"type\":\"request\","
4339 const char* command_4 = "{\"seq\":104," 4344 "\"command\":\"evaluate\","
4340 "\"type\":\"request\"," 4345 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":false,"
4341 "\"command\":\"evaluate\"," 4346 "\"global\":true}}";
4342 "\"arguments\":{\"expression\":\"x + 1\",\"disable_break\":true}}"; 4347 } else {
4348 command_3 = "{\"seq\":103,"
4349 "\"type\":\"request\","
4350 "\"command\":\"evaluate\","
4351 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":false}}";
4352 }
4353 const char* command_4;
4354 if (this->global_evaluate_) {
4355 command_4 = "{\"seq\":104,"
4356 "\"type\":\"request\","
4357 "\"command\":\"evaluate\","
4358 "\"arguments\":{\"expression\":\"100 + 8\",\"disable_break\":true,"
4359 "\"global\":true}}";
4360 } else {
4361 command_4 = "{\"seq\":104,"
4362 "\"type\":\"request\","
4363 "\"command\":\"evaluate\","
4364 "\"arguments\":{\"expression\":\"x + 1\",\"disable_break\":true}}";
4365 }
4343 const char* command_5 = "{\"seq\":105," 4366 const char* command_5 = "{\"seq\":105,"
4344 "\"type\":\"request\"," 4367 "\"type\":\"request\","
4345 "\"command\":\"continue\"}"; 4368 "\"command\":\"continue\"}";
4346 const char* command_6 = "{\"seq\":106," 4369 const char* command_6 = "{\"seq\":106,"
4347 "\"type\":\"request\"," 4370 "\"type\":\"request\","
4348 "\"command\":\"continue\"}"; 4371 "\"command\":\"continue\"}";
4349 const char* command_7 = "{\"seq\":107," 4372 const char* command_7;
4350 "\"type\":\"request\"," 4373 if (this->global_evaluate_) {
4351 "\"command\":\"evaluate\"," 4374 command_7 = "{\"seq\":107,"
4352 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":true}}"; 4375 "\"type\":\"request\","
4376 "\"command\":\"evaluate\","
4377 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":true,"
4378 "\"global\":true}}";
4379 } else {
4380 command_7 = "{\"seq\":107,"
4381 "\"type\":\"request\","
4382 "\"command\":\"evaluate\","
4383 "\"arguments\":{\"expression\":\"dog()\",\"disable_break\":true}}";
4384 }
4353 const char* command_8 = "{\"seq\":108," 4385 const char* command_8 = "{\"seq\":108,"
4354 "\"type\":\"request\"," 4386 "\"type\":\"request\","
4355 "\"command\":\"continue\"}"; 4387 "\"command\":\"continue\"}";
4356 4388
4357 4389
4358 // v8 thread initializes, runs source_1 4390 // v8 thread initializes, runs source_1
4359 breakpoints_barriers->barrier_1.Wait(); 4391 breakpoints_barriers->barrier_1.Wait();
4360 // 1:Set breakpoint in cat() (will get id 1). 4392 // 1:Set breakpoint in cat() (will get id 1).
4361 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer)); 4393 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_1, buffer));
4362 // 2:Set breakpoint in dog() (will get id 2). 4394 // 2:Set breakpoint in dog() (will get id 2).
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4399 // 8: Evaluate dog() with breaks disabled. 4431 // 8: Evaluate dog() with breaks disabled.
4400 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer)); 4432 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_7, buffer));
4401 // Evaluate dog() finishes. 4433 // Evaluate dog() finishes.
4402 breakpoints_barriers->semaphore_1->Wait(); 4434 breakpoints_barriers->semaphore_1->Wait();
4403 // Must have result 116. 4435 // Must have result 116.
4404 CHECK_EQ(116, evaluate_int_result); 4436 CHECK_EQ(116, evaluate_int_result);
4405 // 9: Continue evaluation of source2, reach end. 4437 // 9: Continue evaluation of source2, reach end.
4406 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer)); 4438 v8::Debug::SendCommand(buffer, AsciiToUtf16(command_8, buffer));
4407 } 4439 }
4408 4440
4409 BreakpointsDebuggerThread breakpoints_debugger_thread; 4441 void TestRecursiveBreakpointsGeneric(bool global_evaluate) {
4410 BreakpointsV8Thread breakpoints_v8_thread; 4442 i::FLAG_debugger_auto_break = true;
4411 4443
4412 TEST(RecursiveBreakpoints) { 4444 BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate);
4413 i::FLAG_debugger_auto_break = true; 4445 BreakpointsV8Thread breakpoints_v8_thread;
4414 4446
4415 // Create a V8 environment 4447 // Create a V8 environment
4416 Barriers stack_allocated_breakpoints_barriers; 4448 Barriers stack_allocated_breakpoints_barriers;
4417 stack_allocated_breakpoints_barriers.Initialize(); 4449 stack_allocated_breakpoints_barriers.Initialize();
4418 breakpoints_barriers = &stack_allocated_breakpoints_barriers; 4450 breakpoints_barriers = &stack_allocated_breakpoints_barriers;
4419 4451
4420 breakpoints_v8_thread.Start(); 4452 breakpoints_v8_thread.Start();
4421 breakpoints_debugger_thread.Start(); 4453 breakpoints_debugger_thread.Start();
4422 4454
4423 breakpoints_v8_thread.Join(); 4455 breakpoints_v8_thread.Join();
4424 breakpoints_debugger_thread.Join(); 4456 breakpoints_debugger_thread.Join();
4425 } 4457 }
4426 4458
4459 TEST(RecursiveBreakpoints) {
4460 TestRecursiveBreakpointsGeneric(false);
4461 }
4462
4463 TEST(RecursiveBreakpointsGlobal) {
4464 TestRecursiveBreakpointsGeneric(true);
4465 }
4466
4427 4467
4428 static void DummyDebugEventListener(v8::DebugEvent event, 4468 static void DummyDebugEventListener(v8::DebugEvent event,
4429 v8::Handle<v8::Object> exec_state, 4469 v8::Handle<v8::Object> exec_state,
4430 v8::Handle<v8::Object> event_data, 4470 v8::Handle<v8::Object> event_data,
4431 v8::Handle<v8::Value> data) { 4471 v8::Handle<v8::Value> data) {
4432 } 4472 }
4433 4473
4434 4474
4435 TEST(SetDebugEventListenerOnUninitializedVM) { 4475 TEST(SetDebugEventListenerOnUninitializedVM) {
4436 v8::Debug::SetDebugEventListener(DummyDebugEventListener); 4476 v8::Debug::SetDebugEventListener(DummyDebugEventListener);
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after
6032 6072
6033 break_point_hit_count = 0; 6073 break_point_hit_count = 0;
6034 foo->Call(env->Global(), 0, NULL); 6074 foo->Call(env->Global(), 0, NULL);
6035 CHECK_EQ(1, break_point_hit_count); 6075 CHECK_EQ(1, break_point_hit_count);
6036 6076
6037 v8::Debug::SetDebugEventListener(NULL); 6077 v8::Debug::SetDebugEventListener(NULL);
6038 debugee_context = v8::Handle<v8::Context>(); 6078 debugee_context = v8::Handle<v8::Context>();
6039 debugger_context = v8::Handle<v8::Context>(); 6079 debugger_context = v8::Handle<v8::Context>();
6040 CheckDebuggerUnloaded(); 6080 CheckDebuggerUnloaded();
6041 } 6081 }
OLDNEW
« no previous file with comments | « src/debug-delay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698