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

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

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