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 7960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7971 CompileRun("function foo() {}; foo();"); | 7971 CompileRun("function foo() {}; foo();"); |
7972 --after_compile_handler_depth; | 7972 --after_compile_handler_depth; |
7973 } | 7973 } |
7974 | 7974 |
7975 | 7975 |
7976 TEST(NoInterruptsInDebugListener) { | 7976 TEST(NoInterruptsInDebugListener) { |
7977 DebugLocalContext env; | 7977 DebugLocalContext env; |
7978 v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent); | 7978 v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent); |
7979 CompileRun("void(0);"); | 7979 CompileRun("void(0);"); |
7980 } | 7980 } |
| 7981 |
| 7982 class TestBreakLocation : public i::BreakLocation { |
| 7983 public: |
| 7984 using i::BreakLocation::GetIterator; |
| 7985 using i::BreakLocation::Iterator; |
| 7986 }; |
| 7987 |
| 7988 TEST(BreakLocationIterator) { |
| 7989 DebugLocalContext env; |
| 7990 v8::Isolate* isolate = env->GetIsolate(); |
| 7991 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7992 v8::HandleScope scope(isolate); |
| 7993 |
| 7994 v8::Local<v8::Value> result = CompileRun( |
| 7995 "function f() {\n" |
| 7996 " debugger; \n" |
| 7997 " f(); \n" |
| 7998 " debugger; \n" |
| 7999 "} \n" |
| 8000 "f"); |
| 8001 Handle<i::Object> function_obj = v8::Utils::OpenHandle(*result); |
| 8002 Handle<i::JSFunction> function = Handle<i::JSFunction>::cast(function_obj); |
| 8003 Handle<i::SharedFunctionInfo> shared(function->shared()); |
| 8004 |
| 8005 EnableDebugger(isolate); |
| 8006 CHECK(i_isolate->debug()->EnsureDebugInfo(shared, function)); |
| 8007 |
| 8008 Handle<i::DebugInfo> debug_info(shared->GetDebugInfo()); |
| 8009 int code_size = debug_info->abstract_code()->Size(); |
| 8010 |
| 8011 bool found_return = false; |
| 8012 bool found_call = false; |
| 8013 bool found_debugger = false; |
| 8014 |
| 8015 // Test public interface. |
| 8016 for (int i = 0; i < code_size; i++) { |
| 8017 i::BreakLocation location = i::BreakLocation::FromCodeOffset(debug_info, i); |
| 8018 if (location.IsCall()) found_call = true; |
| 8019 if (location.IsReturn()) found_return = true; |
| 8020 if (location.IsDebuggerStatement()) found_debugger = true; |
| 8021 } |
| 8022 CHECK(found_call); |
| 8023 CHECK(found_return); |
| 8024 CHECK(found_debugger); |
| 8025 |
| 8026 // Test underlying implementation. |
| 8027 TestBreakLocation::Iterator* iterator = |
| 8028 TestBreakLocation::GetIterator(debug_info, i::ALL_BREAK_LOCATIONS); |
| 8029 CHECK(iterator->GetBreakLocation().IsDebuggerStatement()); |
| 8030 CHECK_EQ(7, iterator->GetBreakLocation().position()); |
| 8031 iterator->Next(); |
| 8032 CHECK(iterator->GetBreakLocation().IsDebugBreakSlot()); |
| 8033 CHECK_EQ(22, iterator->GetBreakLocation().position()); |
| 8034 iterator->Next(); |
| 8035 CHECK(iterator->GetBreakLocation().IsCall()); |
| 8036 CHECK_EQ(22, iterator->GetBreakLocation().position()); |
| 8037 iterator->Next(); |
| 8038 CHECK(iterator->GetBreakLocation().IsDebuggerStatement()); |
| 8039 CHECK_EQ(37, iterator->GetBreakLocation().position()); |
| 8040 iterator->Next(); |
| 8041 CHECK(iterator->GetBreakLocation().IsReturn()); |
| 8042 CHECK_EQ(50, iterator->GetBreakLocation().position()); |
| 8043 iterator->Next(); |
| 8044 CHECK(iterator->Done()); |
| 8045 delete iterator; |
| 8046 |
| 8047 iterator = TestBreakLocation::GetIterator(debug_info, i::CALLS_AND_RETURNS); |
| 8048 CHECK(iterator->GetBreakLocation().IsCall()); |
| 8049 CHECK_EQ(22, iterator->GetBreakLocation().position()); |
| 8050 iterator->Next(); |
| 8051 CHECK(iterator->GetBreakLocation().IsReturn()); |
| 8052 CHECK_EQ(50, iterator->GetBreakLocation().position()); |
| 8053 iterator->Next(); |
| 8054 CHECK(iterator->Done()); |
| 8055 delete iterator; |
| 8056 |
| 8057 DisableDebugger(isolate); |
| 8058 } |
OLD | NEW |