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 2824007: Fix a bug when top level break points fall into the last function in script. (Closed)
Patch Set: Update after review Created 10 years, 6 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/runtime.cc ('k') | test/mjsunit/debug-setbreakpoint.js » ('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 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 ClearBreakPointFromJS(sbp6); 2021 ClearBreakPointFromJS(sbp6);
2022 break_point_hit_count = 0; 2022 break_point_hit_count = 0;
2023 v8::Script::Compile(script, &origin)->Run(); 2023 v8::Script::Compile(script, &origin)->Run();
2024 CHECK_EQ(0, break_point_hit_count); 2024 CHECK_EQ(0, break_point_hit_count);
2025 2025
2026 v8::Debug::SetDebugEventListener(NULL); 2026 v8::Debug::SetDebugEventListener(NULL);
2027 CheckDebuggerUnloaded(); 2027 CheckDebuggerUnloaded();
2028 } 2028 }
2029 2029
2030 2030
2031 // Test top level script break points set on lines.
2032 TEST(ScriptBreakPointLineTopLevel) {
2033 v8::HandleScope scope;
2034 DebugLocalContext env;
2035 env.ExposeDebug();
2036
2037 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
2038 v8::Undefined());
2039
2040 v8::Local<v8::String> script = v8::String::New(
2041 "function f() {\n"
2042 " a = 1; // line 1\n"
2043 "}\n"
2044 "a = 2; // line 3\n");
2045 v8::Local<v8::Function> f;
2046 {
2047 v8::HandleScope scope;
2048 v8::Script::Compile(script, v8::String::New("test.html"))->Run();
2049 }
2050 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2051
2052 Heap::CollectAllGarbage(false);
2053
2054 SetScriptBreakPointByNameFromJS("test.html", 3, -1);
2055
2056 // Call f and check that there was no break points.
2057 break_point_hit_count = 0;
2058 f->Call(env->Global(), 0, NULL);
2059 CHECK_EQ(0, break_point_hit_count);
2060
2061 // Recompile and run script and check that break point was hit.
2062 break_point_hit_count = 0;
2063 v8::Script::Compile(script, v8::String::New("test.html"))->Run();
2064 CHECK_EQ(1, break_point_hit_count);
2065
2066 // Call f and check that there are still no break points.
2067 break_point_hit_count = 0;
2068 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
2069 CHECK_EQ(0, break_point_hit_count);
2070
2071 v8::Debug::SetDebugEventListener(NULL);
2072 CheckDebuggerUnloaded();
2073 }
2074
2075
2031 // Test that it is possible to remove the last break point for a function 2076 // Test that it is possible to remove the last break point for a function
2032 // inside the break handling of that break point. 2077 // inside the break handling of that break point.
2033 TEST(RemoveBreakPointInBreak) { 2078 TEST(RemoveBreakPointInBreak) {
2034 v8::HandleScope scope; 2079 v8::HandleScope scope;
2035 DebugLocalContext env; 2080 DebugLocalContext env;
2036 2081
2037 v8::Local<v8::Function> foo = 2082 v8::Local<v8::Function> foo =
2038 CompileFunction(&env, "function foo(){a=1;}", "foo"); 2083 CompileFunction(&env, "function foo(){a=1;}", "foo");
2039 debug_event_remove_break_point = SetBreakPoint(foo, 0); 2084 debug_event_remove_break_point = SetBreakPoint(foo, 0);
2040 2085
(...skipping 4522 matching lines...) Expand 10 before | Expand all | Expand 10 after
6563 expected_context = v8::Context::New(); 6608 expected_context = v8::Context::New();
6564 v8::Context::Scope context_scope(expected_context); 6609 v8::Context::Scope context_scope(expected_context);
6565 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); 6610 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
6566 expected_context.Dispose(); 6611 expected_context.Dispose();
6567 expected_context.Clear(); 6612 expected_context.Clear();
6568 v8::Debug::SetDebugEventListener(NULL); 6613 v8::Debug::SetDebugEventListener(NULL);
6569 expected_context_data = v8::Handle<v8::Value>(); 6614 expected_context_data = v8::Handle<v8::Value>();
6570 CheckDebuggerUnloaded(); 6615 CheckDebuggerUnloaded();
6571 } 6616 }
6572 6617
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/debug-setbreakpoint.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698