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

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

Issue 345048: Fix issue 493: Infinite loop when debug break is set when entering function.apply (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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 | Annotate | Revision Log
« no previous file with comments | « src/x64/regexp-macro-assembler-x64.cc ('k') | test/cctest/test-serialize.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 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 // Run the garbage collector to enforce heap verification if option 865 // Run the garbage collector to enforce heap verification if option
866 // --verify-heap is set. 866 // --verify-heap is set.
867 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); 867 Heap::CollectGarbage(0, v8::internal::NEW_SPACE);
868 868
869 // Set the break flag again to come back here as soon as possible. 869 // Set the break flag again to come back here as soon as possible.
870 v8::Debug::DebugBreak(); 870 v8::Debug::DebugBreak();
871 } 871 }
872 } 872 }
873 873
874 874
875 // Debug event handler which re-issues a debug break until a limit has been
876 // reached.
877 int max_break_point_hit_count = 0;
878 static void DebugEventBreakMax(v8::DebugEvent event,
879 v8::Handle<v8::Object> exec_state,
880 v8::Handle<v8::Object> event_data,
881 v8::Handle<v8::Value> data) {
882 // When hitting a debug event listener there must be a break set.
883 CHECK_NE(v8::internal::Debug::break_id(), 0);
884
885 if (event == v8::Break && break_point_hit_count < max_break_point_hit_count) {
886 // Count the number of breaks.
887 break_point_hit_count++;
888
889 // Set the break flag again to come back here as soon as possible.
890 v8::Debug::DebugBreak();
891 }
892 }
893
894
875 // --- M e s s a g e C a l l b a c k 895 // --- M e s s a g e C a l l b a c k
876 896
877 897
878 // Message callback which counts the number of messages. 898 // Message callback which counts the number of messages.
879 int message_callback_count = 0; 899 int message_callback_count = 0;
880 900
881 static void MessageCallbackCountClear() { 901 static void MessageCallbackCountClear() {
882 message_callback_count = 0; 902 message_callback_count = 0;
883 } 903 }
884 904
(...skipping 4552 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 v8::Script::New( 5457 v8::Script::New(
5438 v8::String::New( 5458 v8::String::New(
5439 "function runTest(mirror) {" 5459 "function runTest(mirror) {"
5440 " return mirror.isString() && (mirror.length() == 5);" 5460 " return mirror.isString() && (mirror.length() == 5);"
5441 "}" 5461 "}"
5442 "" 5462 ""
5443 "runTest;"))->Run()); 5463 "runTest;"))->Run());
5444 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); 5464 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj);
5445 CHECK(result->IsTrue()); 5465 CHECK(result->IsTrue());
5446 } 5466 }
5467
5468
5469 // Test that the debug break flag works with function.apply.
5470 TEST(DebugBreakFunctionApply) {
5471 v8::HandleScope scope;
5472 DebugLocalContext env;
5473
5474 // Create a function for testing breaking in apply.
5475 v8::Local<v8::Function> foo = CompileFunction(
5476 &env,
5477 "function baz(x) { }"
5478 "function bar(x) { baz(); }"
5479 "function foo(){ bar.apply(this, [1]); }",
5480 "foo");
5481
5482 // Register a debug event listener which steps and counts.
5483 v8::Debug::SetDebugEventListener(DebugEventBreakMax);
5484
5485 // Set the debug break flag before calling the code using function.apply.
5486 v8::Debug::DebugBreak();
5487
5488 // Limit the number of debug breaks. This is a regression test for issue 493
5489 // where this test would enter an infinite loop.
5490 break_point_hit_count = 0;
5491 max_break_point_hit_count = 10000; // 10000 => infinite loop.
5492 foo->Call(env->Global(), 0, NULL);
5493
5494 // When keeping the debug break several break will happen.
5495 CHECK_EQ(3, break_point_hit_count);
5496
5497 v8::Debug::SetDebugEventListener(NULL);
5498 CheckDebuggerUnloaded();
5499 }
OLDNEW
« no previous file with comments | « src/x64/regexp-macro-assembler-x64.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698