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

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

Issue 196793013: Revert "New Compilation API, part 1" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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-log.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 2211
2212 v8::Local<v8::String> script = 2212 v8::Local<v8::String> script =
2213 v8::String::NewFromUtf8(env->GetIsolate(), 2213 v8::String::NewFromUtf8(env->GetIsolate(),
2214 "function f() {\n" 2214 "function f() {\n"
2215 " a = 1; // line 1\n" 2215 " a = 1; // line 1\n"
2216 "}\n" 2216 "}\n"
2217 "a = 2; // line 3\n"); 2217 "a = 2; // line 3\n");
2218 v8::Local<v8::Function> f; 2218 v8::Local<v8::Function> f;
2219 { 2219 {
2220 v8::HandleScope scope(env->GetIsolate()); 2220 v8::HandleScope scope(env->GetIsolate());
2221 CompileRunWithOrigin(script, "test.html"); 2221 v8::Script::Compile(
2222 script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run();
2222 } 2223 }
2223 f = v8::Local<v8::Function>::Cast( 2224 f = v8::Local<v8::Function>::Cast(
2224 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 2225 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
2225 2226
2226 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2227 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2227 2228
2228 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); 2229 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
2229 2230
2230 // Call f and check that there was no break points. 2231 // Call f and check that there was no break points.
2231 break_point_hit_count = 0; 2232 break_point_hit_count = 0;
2232 f->Call(env->Global(), 0, NULL); 2233 f->Call(env->Global(), 0, NULL);
2233 CHECK_EQ(0, break_point_hit_count); 2234 CHECK_EQ(0, break_point_hit_count);
2234 2235
2235 // Recompile and run script and check that break point was hit. 2236 // Recompile and run script and check that break point was hit.
2236 break_point_hit_count = 0; 2237 break_point_hit_count = 0;
2237 CompileRunWithOrigin(script, "test.html"); 2238 v8::Script::Compile(
2239 script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run();
2238 CHECK_EQ(1, break_point_hit_count); 2240 CHECK_EQ(1, break_point_hit_count);
2239 2241
2240 // Call f and check that there are still no break points. 2242 // Call f and check that there are still no break points.
2241 break_point_hit_count = 0; 2243 break_point_hit_count = 0;
2242 f = v8::Local<v8::Function>::Cast( 2244 f = v8::Local<v8::Function>::Cast(
2243 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 2245 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
2244 CHECK_EQ(0, break_point_hit_count); 2246 CHECK_EQ(0, break_point_hit_count);
2245 2247
2246 v8::Debug::SetDebugEventListener2(NULL); 2248 v8::Debug::SetDebugEventListener2(NULL);
2247 CheckDebuggerUnloaded(); 2249 CheckDebuggerUnloaded();
(...skipping 14 matching lines...) Expand all
2262 "function f() {\n" 2264 "function f() {\n"
2263 " return 0;\n" 2265 " return 0;\n"
2264 "}\n" 2266 "}\n"
2265 "f()"); 2267 "f()");
2266 2268
2267 int sbp1 = 2269 int sbp1 =
2268 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); 2270 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
2269 { 2271 {
2270 v8::HandleScope scope(env->GetIsolate()); 2272 v8::HandleScope scope(env->GetIsolate());
2271 break_point_hit_count = 0; 2273 break_point_hit_count = 0;
2272 CompileRunWithOrigin(script_source, "test.html"); 2274 v8::Script::Compile(script_source,
2275 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))
2276 ->Run();
2273 CHECK_EQ(1, break_point_hit_count); 2277 CHECK_EQ(1, break_point_hit_count);
2274 } 2278 }
2275 2279
2276 int sbp2 = 2280 int sbp2 =
2277 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); 2281 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
2278 ClearBreakPointFromJS(env->GetIsolate(), sbp1); 2282 ClearBreakPointFromJS(env->GetIsolate(), sbp1);
2279 ClearBreakPointFromJS(env->GetIsolate(), sbp2); 2283 ClearBreakPointFromJS(env->GetIsolate(), sbp2);
2280 2284
2281 v8::Debug::SetDebugEventListener2(NULL); 2285 v8::Debug::SetDebugEventListener2(NULL);
2282 CheckDebuggerUnloaded(); 2286 CheckDebuggerUnloaded();
(...skipping 3952 matching lines...) Expand 10 before | Expand all | Expand 10 after
6235 v8::ScriptOrigin origin2 = 6239 v8::ScriptOrigin origin2 =
6236 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name")); 6240 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name"));
6237 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); 6241 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2);
6238 script2->Run(); 6242 script2->Run();
6239 f = v8::Local<v8::Function>::Cast( 6243 f = v8::Local<v8::Function>::Cast(
6240 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 6244 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
6241 f->Call(env->Global(), 0, NULL); 6245 f->Call(env->Global(), 0, NULL);
6242 CHECK_EQ(3, break_point_hit_count); 6246 CHECK_EQ(3, break_point_hit_count);
6243 CHECK_EQ("new name", last_script_name_hit); 6247 CHECK_EQ("new name", last_script_name_hit);
6244 6248
6245 v8::Handle<v8::Script> script3 = v8::Script::Compile(script, &origin2); 6249 v8::Handle<v8::Script> script3 = v8::Script::Compile(
6250 script, &origin2, NULL);
6246 script3->Run(); 6251 script3->Run();
6247 f = v8::Local<v8::Function>::Cast( 6252 f = v8::Local<v8::Function>::Cast(
6248 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 6253 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
6249 f->Call(env->Global(), 0, NULL); 6254 f->Call(env->Global(), 0, NULL);
6250 CHECK_EQ(4, break_point_hit_count); 6255 CHECK_EQ(4, break_point_hit_count);
6251 } 6256 }
6252 6257
6253 6258
6254 static v8::Handle<v8::Context> expected_context; 6259 static v8::Handle<v8::Context> expected_context;
6255 static v8::Handle<v8::Value> expected_context_data; 6260 static v8::Handle<v8::Value> expected_context_data;
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
6976 v8::Debug::SendCommand( 6981 v8::Debug::SendCommand(
6977 isolate, 6982 isolate,
6978 buffer, 6983 buffer,
6979 AsciiToUtf16(scripts_command, buffer), 6984 AsciiToUtf16(scripts_command, buffer),
6980 NULL); 6985 NULL);
6981 v8::Debug::ProcessDebugMessages(); 6986 v8::Debug::ProcessDebugMessages();
6982 CHECK_EQ(BacktraceData::frame_counter, 0); 6987 CHECK_EQ(BacktraceData::frame_counter, 0);
6983 6988
6984 v8::Handle<v8::String> void0 = 6989 v8::Handle<v8::String> void0 =
6985 v8::String::NewFromUtf8(env->GetIsolate(), "void(0)"); 6990 v8::String::NewFromUtf8(env->GetIsolate(), "void(0)");
6986 v8::Handle<v8::Script> script = CompileWithOrigin(void0, void0); 6991 v8::Handle<v8::Script> script = v8::Script::Compile(void0, void0);
6987 6992
6988 // Check backtrace from "void(0)" script. 6993 // Check backtrace from "void(0)" script.
6989 BacktraceData::frame_counter = -10; 6994 BacktraceData::frame_counter = -10;
6990 v8::Debug::SendCommand( 6995 v8::Debug::SendCommand(
6991 isolate, 6996 isolate,
6992 buffer, 6997 buffer,
6993 AsciiToUtf16(scripts_command, buffer), 6998 AsciiToUtf16(scripts_command, buffer),
6994 NULL); 6999 NULL);
6995 script->Run(); 7000 script->Run();
6996 CHECK_EQ(BacktraceData::frame_counter, 1); 7001 CHECK_EQ(BacktraceData::frame_counter, 1);
6997 7002
6998 // Get rid of the debug message handler. 7003 // Get rid of the debug message handler.
6999 v8::Debug::SetMessageHandler2(NULL); 7004 v8::Debug::SetMessageHandler2(NULL);
7000 CheckDebuggerUnloaded(); 7005 CheckDebuggerUnloaded();
7001 } 7006 }
7002 7007
7003 7008
7004 TEST(GetMirror) { 7009 TEST(GetMirror) {
7005 DebugLocalContext env; 7010 DebugLocalContext env;
7006 v8::Isolate* isolate = env->GetIsolate(); 7011 v8::HandleScope scope(env->GetIsolate());
7007 v8::HandleScope scope(isolate);
7008 v8::Handle<v8::Value> obj = 7012 v8::Handle<v8::Value> obj =
7009 v8::Debug::GetMirror(v8::String::NewFromUtf8(isolate, "hodja")); 7013 v8::Debug::GetMirror(v8::String::NewFromUtf8(env->GetIsolate(), "hodja"));
7010 v8::Handle<v8::Function> run_test = 7014 v8::Handle<v8::Function> run_test =
7011 v8::Handle<v8::Function>::Cast( 7015 v8::Handle<v8::Function>::Cast(v8::Script::New(
7012 v8::ScriptCompiler::CompileUnbound( 7016 v8::String::NewFromUtf8(
7013 isolate, 7017 env->GetIsolate(),
7014 v8::ScriptCompiler::Source(v8_str( 7018 "function runTest(mirror) {"
7015 "function runTest(mirror) {" 7019 " return mirror.isString() && (mirror.length() == 5);"
7016 " return mirror.isString() && (mirror.length() == 5);" 7020 "}"
7017 "}" 7021 ""
7018 "" 7022 "runTest;"))->Run());
7019 "runTest;")))->BindToCurrentContext()->Run());
7020 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); 7023 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj);
7021 CHECK(result->IsTrue()); 7024 CHECK(result->IsTrue());
7022 } 7025 }
7023 7026
7024 7027
7025 // Test that the debug break flag works with function.apply. 7028 // Test that the debug break flag works with function.apply.
7026 TEST(DebugBreakFunctionApply) { 7029 TEST(DebugBreakFunctionApply) {
7027 DebugLocalContext env; 7030 DebugLocalContext env;
7028 v8::HandleScope scope(env->GetIsolate()); 7031 v8::HandleScope scope(env->GetIsolate());
7029 7032
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
7662 CHECK(result->IsString()); 7665 CHECK(result->IsString());
7663 v8::String::Utf8Value utf8(result); 7666 v8::String::Utf8Value utf8(result);
7664 CHECK_EQ("bar", *utf8); 7667 CHECK_EQ("bar", *utf8);
7665 7668
7666 v8::Debug::SetDebugEventListener2(NULL); 7669 v8::Debug::SetDebugEventListener2(NULL);
7667 CheckDebuggerUnloaded(); 7670 CheckDebuggerUnloaded();
7668 } 7671 }
7669 7672
7670 7673
7671 #endif // ENABLE_DEBUGGER_SUPPORT 7674 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698