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

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

Issue 160001: Skip built-in and debugger functions when DebugBreak is forced (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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 | « src/ia32/regexp-macro-assembler-ia32.cc ('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 4857 matching lines...) Expand 10 before | Expand all | Expand 10 after
4868 4868
4869 4869
4870 // Test that a debug break can be scheduled while in a message handler. 4870 // Test that a debug break can be scheduled while in a message handler.
4871 TEST(DebugBreakInMessageHandler) { 4871 TEST(DebugBreakInMessageHandler) {
4872 v8::HandleScope scope; 4872 v8::HandleScope scope;
4873 DebugLocalContext env; 4873 DebugLocalContext env;
4874 4874
4875 v8::Debug::SetMessageHandler2(DebugBreakMessageHandler); 4875 v8::Debug::SetMessageHandler2(DebugBreakMessageHandler);
4876 4876
4877 // Test functions. 4877 // Test functions.
4878 const char* script = "function f() { debugger; } function g() { }"; 4878 const char* script = "function f() { debugger; g(); } function g() { }";
4879 CompileRun(script); 4879 CompileRun(script);
4880 v8::Local<v8::Function> f = 4880 v8::Local<v8::Function> f =
4881 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); 4881 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
4882 v8::Local<v8::Function> g = 4882 v8::Local<v8::Function> g =
4883 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g"))); 4883 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g")));
4884 4884
4885 // Call f then g. The debugger statement in f will casue a break which will 4885 // Call f then g. The debugger statement in f will casue a break which will
4886 // cause another break. 4886 // cause another break.
4887 f->Call(env->Global(), 0, NULL); 4887 f->Call(env->Global(), 0, NULL);
4888 CHECK_EQ(2, message_handler_break_hit_count); 4888 CHECK_EQ(2, message_handler_break_hit_count);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4947 v8::Local<v8::Function> f = CompileFunction(script, "f"); 4947 v8::Local<v8::Function> f = CompileFunction(script, "f");
4948 const int argc = 1; 4948 const int argc = 1;
4949 v8::Handle<v8::Value> argv[argc] = { v8::String::New(" /* xxx */ a=0;") }; 4949 v8::Handle<v8::Value> argv[argc] = { v8::String::New(" /* xxx */ a=0;") };
4950 v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv); 4950 v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv);
4951 CHECK_EQ(12, result->Int32Value()); 4951 CHECK_EQ(12, result->Int32Value());
4952 4952
4953 v8::Debug::SetDebugEventListener(DebugEventDebugBreak); 4953 v8::Debug::SetDebugEventListener(DebugEventDebugBreak);
4954 v8::Debug::DebugBreak(); 4954 v8::Debug::DebugBreak();
4955 result = f->Call(env->Global(), argc, argv); 4955 result = f->Call(env->Global(), argc, argv);
4956 4956
4957 CHECK_EQ(20, break_point_hit_count); 4957 // Check that there was only one break event. Matching RegExp should not
4958 CHECK_EQ("exec", last_function_hit); 4958 // cause Break events.
4959 CHECK_EQ(1, break_point_hit_count);
4960 CHECK_EQ("f", last_function_hit);
4959 } 4961 }
4960 #endif // V8_NATIVE_REGEXP 4962 #endif // V8_NATIVE_REGEXP
4961 4963
4962 4964
4963 // Common part of EvalContextData and NestedBreakEventContextData tests. 4965 // Common part of EvalContextData and NestedBreakEventContextData tests.
4964 static void ExecuteScriptForContextCheck() { 4966 static void ExecuteScriptForContextCheck() {
4965 // Create a context. 4967 // Create a context.
4966 v8::Persistent<v8::Context> context_1; 4968 v8::Persistent<v8::Context> context_1;
4967 v8::Handle<v8::ObjectTemplate> global_template = 4969 v8::Handle<v8::ObjectTemplate> global_template =
4968 v8::Handle<v8::ObjectTemplate>(); 4970 v8::Handle<v8::ObjectTemplate>();
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
5288 5290
5289 // If the script is compiled successfully there is exactly one after compile 5291 // If the script is compiled successfully there is exactly one after compile
5290 // event. In case of an exception in debugger code after compile event is not 5292 // event. In case of an exception in debugger code after compile event is not
5291 // sent. 5293 // sent.
5292 CHECK_EQ(1, after_compile_message_count); 5294 CHECK_EQ(1, after_compile_message_count);
5293 5295
5294 ClearBreakPointFromJS(sbp1); 5296 ClearBreakPointFromJS(sbp1);
5295 ClearBreakPointFromJS(sbp2); 5297 ClearBreakPointFromJS(sbp2);
5296 v8::Debug::SetMessageHandler2(NULL); 5298 v8::Debug::SetMessageHandler2(NULL);
5297 } 5299 }
5300
5301
5302 static void BreakMessageHandler(const v8::Debug::Message& message) {
5303 if (message.IsEvent() && message.GetEvent() == v8::Break) {
5304 // Count the number of breaks.
5305 break_point_hit_count++;
5306
5307 v8::HandleScope scope;
5308 v8::Handle<v8::String> json = message.GetJSON();
5309
5310 SendContinueCommand();
5311 } else if (message.IsEvent() && message.GetEvent() == v8::AfterCompile) {
5312 v8::HandleScope scope;
5313
5314 bool is_debug_break = i::StackGuard::IsDebugBreak();
5315 // Force DebugBreak flag while serializer is working.
5316 i::StackGuard::DebugBreak();
5317
5318 // Force serialization to trigger some internal JS execution.
5319 v8::Handle<v8::String> json = message.GetJSON();
5320
5321 // Restore previous state.
5322 if (is_debug_break) {
5323 i::StackGuard::DebugBreak();
5324 } else {
5325 i::StackGuard::Continue(i::DEBUGBREAK);
5326 }
5327 }
5328 }
5329
5330
5331 // Test that if DebugBreak is forced it is ignored when code from
5332 // debug-delay.js is executed.
5333 TEST(NoDebugBreakInAfterCompileMessageHandler) {
5334 v8::HandleScope scope;
5335 DebugLocalContext env;
5336
5337 // Register a debug event listener which sets the break flag and counts.
5338 v8::Debug::SetMessageHandler2(BreakMessageHandler);
5339
5340 // Set the debug break flag.
5341 v8::Debug::DebugBreak();
5342
5343 // Create a function for testing stepping.
5344 const char* src = "function f() { eval('var x = 10;'); } ";
5345 v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
5346
5347 // There should be only one break event.
5348 CHECK_EQ(1, break_point_hit_count);
5349
5350 // Set the debug break flag again.
5351 v8::Debug::DebugBreak();
5352 f->Call(env->Global(), 0, NULL);
5353 // There should be one more break event when the script is evaluated in 'f'.
5354 CHECK_EQ(2, break_point_hit_count);
5355
5356 // Get rid of the debug message handler.
5357 v8::Debug::SetMessageHandler2(NULL);
5358 CheckDebuggerUnloaded();
5359 }
OLDNEW
« no previous file with comments | « src/ia32/regexp-macro-assembler-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698