| OLD | NEW |
| 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 6925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6936 v8::Context::Scope context_scope(expected_context); | 6936 v8::Context::Scope context_scope(expected_context); |
| 6937 v8::Script::Compile( | 6937 v8::Script::Compile( |
| 6938 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run(); | 6938 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run(); |
| 6939 expected_context.Clear(); | 6939 expected_context.Clear(); |
| 6940 v8::Debug::SetDebugEventListener(NULL); | 6940 v8::Debug::SetDebugEventListener(NULL); |
| 6941 expected_context_data = v8::Handle<v8::Value>(); | 6941 expected_context_data = v8::Handle<v8::Value>(); |
| 6942 CheckDebuggerUnloaded(); | 6942 CheckDebuggerUnloaded(); |
| 6943 } | 6943 } |
| 6944 | 6944 |
| 6945 | 6945 |
| 6946 static void* expected_break_data; | |
| 6947 static bool was_debug_break_called; | |
| 6948 static bool was_debug_event_called; | |
| 6949 static void DebugEventBreakDataChecker(const v8::Debug::EventDetails& details) { | |
| 6950 if (details.GetEvent() == v8::BreakForCommand) { | |
| 6951 CHECK_EQ(expected_break_data, details.GetClientData()); | |
| 6952 was_debug_event_called = true; | |
| 6953 } else if (details.GetEvent() == v8::Break) { | |
| 6954 was_debug_break_called = true; | |
| 6955 } | |
| 6956 } | |
| 6957 | |
| 6958 | |
| 6959 // Check that event details contain context where debug event occured. | |
| 6960 TEST(DebugEventBreakData) { | |
| 6961 DebugLocalContext env; | |
| 6962 v8::Isolate* isolate = env->GetIsolate(); | |
| 6963 v8::HandleScope scope(isolate); | |
| 6964 v8::Debug::SetDebugEventListener(DebugEventBreakDataChecker); | |
| 6965 | |
| 6966 TestClientData::constructor_call_counter = 0; | |
| 6967 TestClientData::destructor_call_counter = 0; | |
| 6968 | |
| 6969 expected_break_data = NULL; | |
| 6970 was_debug_event_called = false; | |
| 6971 was_debug_break_called = false; | |
| 6972 v8::Debug::DebugBreakForCommand(isolate, NULL); | |
| 6973 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | |
| 6974 "(function(x){return x;})(1);")) | |
| 6975 ->Run(); | |
| 6976 CHECK(was_debug_event_called); | |
| 6977 CHECK(!was_debug_break_called); | |
| 6978 | |
| 6979 TestClientData* data1 = new TestClientData(); | |
| 6980 expected_break_data = data1; | |
| 6981 was_debug_event_called = false; | |
| 6982 was_debug_break_called = false; | |
| 6983 v8::Debug::DebugBreakForCommand(isolate, data1); | |
| 6984 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | |
| 6985 "(function(x){return x+1;})(1);")) | |
| 6986 ->Run(); | |
| 6987 CHECK(was_debug_event_called); | |
| 6988 CHECK(!was_debug_break_called); | |
| 6989 | |
| 6990 expected_break_data = NULL; | |
| 6991 was_debug_event_called = false; | |
| 6992 was_debug_break_called = false; | |
| 6993 v8::Debug::DebugBreak(isolate); | |
| 6994 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | |
| 6995 "(function(x){return x+2;})(1);")) | |
| 6996 ->Run(); | |
| 6997 CHECK(!was_debug_event_called); | |
| 6998 CHECK(was_debug_break_called); | |
| 6999 | |
| 7000 TestClientData* data2 = new TestClientData(); | |
| 7001 expected_break_data = data2; | |
| 7002 was_debug_event_called = false; | |
| 7003 was_debug_break_called = false; | |
| 7004 v8::Debug::DebugBreak(isolate); | |
| 7005 v8::Debug::DebugBreakForCommand(isolate, data2); | |
| 7006 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), | |
| 7007 "(function(x){return x+3;})(1);")) | |
| 7008 ->Run(); | |
| 7009 CHECK(was_debug_event_called); | |
| 7010 CHECK(was_debug_break_called); | |
| 7011 | |
| 7012 CHECK_EQ(2, TestClientData::constructor_call_counter); | |
| 7013 CHECK_EQ(TestClientData::constructor_call_counter, | |
| 7014 TestClientData::destructor_call_counter); | |
| 7015 | |
| 7016 v8::Debug::SetDebugEventListener(NULL); | |
| 7017 CheckDebuggerUnloaded(); | |
| 7018 } | |
| 7019 | |
| 7020 static bool debug_event_break_deoptimize_done = false; | 6946 static bool debug_event_break_deoptimize_done = false; |
| 7021 | 6947 |
| 7022 static void DebugEventBreakDeoptimize( | 6948 static void DebugEventBreakDeoptimize( |
| 7023 const v8::Debug::EventDetails& event_details) { | 6949 const v8::Debug::EventDetails& event_details) { |
| 7024 v8::DebugEvent event = event_details.GetEvent(); | 6950 v8::DebugEvent event = event_details.GetEvent(); |
| 7025 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); | 6951 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); |
| 7026 if (event == v8::Break) { | 6952 if (event == v8::Break) { |
| 7027 if (!frame_function_name.IsEmpty()) { | 6953 if (!frame_function_name.IsEmpty()) { |
| 7028 // Get the name of the function. | 6954 // Get the name of the function. |
| 7029 const int argc = 2; | 6955 const int argc = 2; |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7662 "let y = 2; \n" | 7588 "let y = 2; \n" |
| 7663 "debugger; \n" | 7589 "debugger; \n" |
| 7664 "x * y", | 7590 "x * y", |
| 7665 30); | 7591 30); |
| 7666 ExpectInt32( | 7592 ExpectInt32( |
| 7667 "x = 1; y = 2; \n" | 7593 "x = 1; y = 2; \n" |
| 7668 "debugger;" | 7594 "debugger;" |
| 7669 "x * y", | 7595 "x * y", |
| 7670 30); | 7596 30); |
| 7671 } | 7597 } |
| OLD | NEW |