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 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "src/v8.h" | 30 #include "src/v8.h" |
31 | 31 |
32 #include "src/api.h" | 32 #include "src/api.h" |
33 #include "src/base/platform/condition-variable.h" | 33 #include "src/base/platform/condition-variable.h" |
34 #include "src/base/platform/platform.h" | 34 #include "src/base/platform/platform.h" |
35 #include "src/compilation-cache.h" | 35 #include "src/compilation-cache.h" |
| 36 #include "src/debug/debug-interface.h" |
36 #include "src/debug/debug.h" | 37 #include "src/debug/debug.h" |
37 #include "src/deoptimizer.h" | 38 #include "src/deoptimizer.h" |
38 #include "src/frames.h" | 39 #include "src/frames.h" |
39 #include "src/utils.h" | 40 #include "src/utils.h" |
40 #include "test/cctest/cctest.h" | 41 #include "test/cctest/cctest.h" |
41 | 42 |
42 | |
43 using ::v8::base::Mutex; | 43 using ::v8::base::Mutex; |
44 using ::v8::base::LockGuard; | 44 using ::v8::base::LockGuard; |
45 using ::v8::base::ConditionVariable; | 45 using ::v8::base::ConditionVariable; |
46 using ::v8::base::OS; | 46 using ::v8::base::OS; |
47 using ::v8::base::Semaphore; | 47 using ::v8::base::Semaphore; |
48 using ::v8::internal::EmbeddedVector; | 48 using ::v8::internal::EmbeddedVector; |
49 using ::v8::internal::Object; | 49 using ::v8::internal::Object; |
50 using ::v8::internal::Handle; | 50 using ::v8::internal::Handle; |
51 using ::v8::internal::Heap; | 51 using ::v8::internal::Heap; |
52 using ::v8::internal::JSGlobalProxy; | 52 using ::v8::internal::JSGlobalProxy; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } else { | 312 } else { |
313 CompileRunChecked(isolate, "debug.Debug.clearBreakOnException()"); | 313 CompileRunChecked(isolate, "debug.Debug.clearBreakOnException()"); |
314 } | 314 } |
315 if (uncaught) { | 315 if (uncaught) { |
316 CompileRunChecked(isolate, "debug.Debug.setBreakOnUncaughtException()"); | 316 CompileRunChecked(isolate, "debug.Debug.setBreakOnUncaughtException()"); |
317 } else { | 317 } else { |
318 CompileRunChecked(isolate, "debug.Debug.clearBreakOnUncaughtException()"); | 318 CompileRunChecked(isolate, "debug.Debug.clearBreakOnUncaughtException()"); |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
| 322 // Change break on exception using the native API call. |
| 323 static void ChangeBreakOnExceptionFromAPI( |
| 324 v8::Isolate* isolate, v8::DebugInterface::ExceptionBreakState state) { |
| 325 v8::DebugInterface::ChangeBreakOnException(isolate, state); |
| 326 } |
322 | 327 |
323 // Prepare to step to next break location. | 328 // Prepare to step to next break location. |
324 static void PrepareStep(StepAction step_action) { | 329 static void PrepareStep(StepAction step_action) { |
325 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 330 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
326 debug->PrepareStep(step_action); | 331 debug->PrepareStep(step_action); |
327 } | 332 } |
328 | 333 |
329 | 334 |
330 static void ClearStepping() { CcTest::i_isolate()->debug()->ClearStepping(); } | 335 static void ClearStepping() { CcTest::i_isolate()->debug()->ClearStepping(); } |
331 | 336 |
(...skipping 3647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3979 ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, false); | 3984 ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, false); |
3980 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3985 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
3981 DebugEventCounterCheck(1, 0, 0); | 3986 DebugEventCounterCheck(1, 0, 0); |
3982 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); | 3987 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); |
3983 DebugEventCounterCheck(2, 1, 1); | 3988 DebugEventCounterCheck(2, 1, 1); |
3984 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); | 3989 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); |
3985 DebugEventCounterCheck(3, 2, 2); | 3990 DebugEventCounterCheck(3, 2, 2); |
3986 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3991 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
3987 DebugEventCounterCheck(4, 3, 2); | 3992 DebugEventCounterCheck(4, 3, 2); |
3988 | 3993 |
| 3994 // No break on exception using native API |
| 3995 DebugEventCounterClear(); |
| 3996 MessageCallbackCountClear(); |
| 3997 ChangeBreakOnExceptionFromAPI(env->GetIsolate(), |
| 3998 v8::DebugInterface::NoBreakOnException); |
| 3999 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4000 DebugEventCounterCheck(0, 0, 0); |
| 4001 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); |
| 4002 DebugEventCounterCheck(0, 0, 1); |
| 4003 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); |
| 4004 DebugEventCounterCheck(0, 0, 2); |
| 4005 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4006 DebugEventCounterCheck(0, 0, 2); |
| 4007 |
| 4008 // // Break on uncaught exception using native API |
| 4009 DebugEventCounterClear(); |
| 4010 MessageCallbackCountClear(); |
| 4011 ChangeBreakOnExceptionFromAPI(env->GetIsolate(), |
| 4012 v8::DebugInterface::BreakOnUncaughtException); |
| 4013 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4014 DebugEventCounterCheck(0, 0, 0); |
| 4015 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); |
| 4016 DebugEventCounterCheck(1, 1, 1); |
| 4017 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); |
| 4018 DebugEventCounterCheck(2, 2, 2); |
| 4019 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4020 DebugEventCounterCheck(3, 3, 2); |
| 4021 |
| 4022 // // Break on exception and uncaught exception using native API |
| 4023 DebugEventCounterClear(); |
| 4024 MessageCallbackCountClear(); |
| 4025 ChangeBreakOnExceptionFromAPI(env->GetIsolate(), |
| 4026 v8::DebugInterface::BreakOnAnyException); |
| 4027 caught->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4028 DebugEventCounterCheck(1, 0, 0); |
| 4029 CHECK(notCaught->Call(context, env->Global(), 0, NULL).IsEmpty()); |
| 4030 DebugEventCounterCheck(2, 1, 1); |
| 4031 CHECK(notCaughtFinally->Call(context, env->Global(), 0, NULL).IsEmpty()); |
| 4032 DebugEventCounterCheck(3, 2, 2); |
| 4033 edgeCaseFinally->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 4034 DebugEventCounterCheck(4, 3, 2); |
| 4035 |
3989 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 4036 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
3990 CheckDebuggerUnloaded(env->GetIsolate()); | 4037 CheckDebuggerUnloaded(env->GetIsolate()); |
3991 env->GetIsolate()->RemoveMessageListeners(MessageCallbackCount); | 4038 env->GetIsolate()->RemoveMessageListeners(MessageCallbackCount); |
3992 } | 4039 } |
3993 | 4040 |
3994 | 4041 |
3995 static void try_finally_original_message(v8::Local<v8::Message> message, | 4042 static void try_finally_original_message(v8::Local<v8::Message> message, |
3996 v8::Local<v8::Value> data) { | 4043 v8::Local<v8::Value> data) { |
3997 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); | 4044 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); |
3998 CHECK_EQ(2, message->GetLineNumber(context).FromJust()); | 4045 CHECK_EQ(2, message->GetLineNumber(context).FromJust()); |
(...skipping 4184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8183 "function foo() {\n" | 8230 "function foo() {\n" |
8184 " try { throw new Error(); } catch (e) {}\n" | 8231 " try { throw new Error(); } catch (e) {}\n" |
8185 "}\n" | 8232 "}\n" |
8186 "debugger;\n" | 8233 "debugger;\n" |
8187 "foo();\n" | 8234 "foo();\n" |
8188 "foo();\n"); | 8235 "foo();\n"); |
8189 | 8236 |
8190 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 8237 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
8191 CHECK_EQ(break_point_hit_count, 4); | 8238 CHECK_EQ(break_point_hit_count, 4); |
8192 } | 8239 } |
OLD | NEW |