OLD | NEW |
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 4874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
4889 // Calling g will not cause any additional breaks. | 4889 // Calling g will not cause any additional breaks. |
4890 g->Call(env->Global(), 0, NULL); | 4890 g->Call(env->Global(), 0, NULL); |
4891 CHECK_EQ(2, message_handler_break_hit_count); | 4891 CHECK_EQ(2, message_handler_break_hit_count); |
4892 } | 4892 } |
4893 | 4893 |
4894 | 4894 |
| 4895 #ifdef V8_NATIVE_REGEXP |
4895 // Debug event handler which gets the function on the top frame and schedules a | 4896 // Debug event handler which gets the function on the top frame and schedules a |
4896 // break a number of times. | 4897 // break a number of times. |
4897 static void DebugEventDebugBreak( | 4898 static void DebugEventDebugBreak( |
4898 v8::DebugEvent event, | 4899 v8::DebugEvent event, |
4899 v8::Handle<v8::Object> exec_state, | 4900 v8::Handle<v8::Object> exec_state, |
4900 v8::Handle<v8::Object> event_data, | 4901 v8::Handle<v8::Object> event_data, |
4901 v8::Handle<v8::Value> data) { | 4902 v8::Handle<v8::Value> data) { |
4902 | 4903 |
4903 if (event == v8::Break) { | 4904 if (event == v8::Break) { |
4904 break_point_hit_count++; | 4905 break_point_hit_count++; |
(...skipping 16 matching lines...) Expand all Loading... |
4921 | 4922 |
4922 // Keep forcing breaks. | 4923 // Keep forcing breaks. |
4923 if (break_point_hit_count < 20) { | 4924 if (break_point_hit_count < 20) { |
4924 v8::Debug::DebugBreak(); | 4925 v8::Debug::DebugBreak(); |
4925 } | 4926 } |
4926 } | 4927 } |
4927 } | 4928 } |
4928 | 4929 |
4929 | 4930 |
4930 TEST(RegExpDebugBreak) { | 4931 TEST(RegExpDebugBreak) { |
| 4932 // This test only applies to native regexps. |
4931 v8::HandleScope scope; | 4933 v8::HandleScope scope; |
4932 DebugLocalContext env; | 4934 DebugLocalContext env; |
4933 | 4935 |
4934 i::FLAG_regexp_native = true; | |
4935 | |
4936 // Create a function for checking the function when hitting a break point. | 4936 // Create a function for checking the function when hitting a break point. |
4937 frame_function_name = CompileFunction(&env, | 4937 frame_function_name = CompileFunction(&env, |
4938 frame_function_name_source, | 4938 frame_function_name_source, |
4939 "frame_function_name"); | 4939 "frame_function_name"); |
4940 | 4940 |
4941 // Test RegExp which matches white spaces and comments at the begining of a | 4941 // Test RegExp which matches white spaces and comments at the begining of a |
4942 // source line. | 4942 // source line. |
4943 const char* script = | 4943 const char* script = |
4944 "var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n" | 4944 "var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n" |
4945 "function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }"; | 4945 "function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }"; |
4946 | 4946 |
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_EQ(20, break_point_hit_count); |
4958 CHECK_EQ("exec", last_function_hit); | 4958 CHECK_EQ("exec", last_function_hit); |
4959 } | 4959 } |
| 4960 #endif // V8_NATIVE_REGEXP |
4960 | 4961 |
4961 | 4962 |
4962 // Common part of EvalContextData and NestedBreakEventContextData tests. | 4963 // Common part of EvalContextData and NestedBreakEventContextData tests. |
4963 static void ExecuteScriptForContextCheck() { | 4964 static void ExecuteScriptForContextCheck() { |
4964 // Create a context. | 4965 // Create a context. |
4965 v8::Persistent<v8::Context> context_1; | 4966 v8::Persistent<v8::Context> context_1; |
4966 v8::Handle<v8::ObjectTemplate> global_template = | 4967 v8::Handle<v8::ObjectTemplate> global_template = |
4967 v8::Handle<v8::ObjectTemplate>(); | 4968 v8::Handle<v8::ObjectTemplate>(); |
4968 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); | 4969 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); |
4969 context_1 = v8::Context::New(NULL, global_template, global_object); | 4970 context_1 = v8::Context::New(NULL, global_template, global_object); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5287 | 5288 |
5288 // If the script is compiled successfully there is exactly one after compile | 5289 // If the script is compiled successfully there is exactly one after compile |
5289 // event. In case of an exception in debugger code after compile event is not | 5290 // event. In case of an exception in debugger code after compile event is not |
5290 // sent. | 5291 // sent. |
5291 CHECK_EQ(1, after_compile_message_count); | 5292 CHECK_EQ(1, after_compile_message_count); |
5292 | 5293 |
5293 ClearBreakPointFromJS(sbp1); | 5294 ClearBreakPointFromJS(sbp1); |
5294 ClearBreakPointFromJS(sbp2); | 5295 ClearBreakPointFromJS(sbp2); |
5295 v8::Debug::SetMessageHandler2(NULL); | 5296 v8::Debug::SetMessageHandler2(NULL); |
5296 } | 5297 } |
OLD | NEW |