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

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

Issue 553043002: Fix crash in ScriptDebugServer::wrapCallFrames (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 3 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/debug.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 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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 662 }
663 } 663 }
664 } 664 }
665 665
666 666
667 // Debug event handler which counts a number of events and collects the stack 667 // Debug event handler which counts a number of events and collects the stack
668 // height if there is a function compiled for that. 668 // height if there is a function compiled for that.
669 int exception_hit_count = 0; 669 int exception_hit_count = 0;
670 int uncaught_exception_hit_count = 0; 670 int uncaught_exception_hit_count = 0;
671 int last_js_stack_height = -1; 671 int last_js_stack_height = -1;
672 v8::Handle<v8::Function> debug_event_listener_callback;
673 int debug_event_listener_callback_result;
672 674
673 static void DebugEventCounterClear() { 675 static void DebugEventCounterClear() {
674 break_point_hit_count = 0; 676 break_point_hit_count = 0;
675 exception_hit_count = 0; 677 exception_hit_count = 0;
676 uncaught_exception_hit_count = 0; 678 uncaught_exception_hit_count = 0;
677 } 679 }
678 680
679 static void DebugEventCounter( 681 static void DebugEventCounter(
680 const v8::Debug::EventDetails& event_details) { 682 const v8::Debug::EventDetails& event_details) {
681 v8::DebugEvent event = event_details.GetEvent(); 683 v8::DebugEvent event = event_details.GetEvent();
(...skipping 20 matching lines...) Expand all
702 uncaught_exception_hit_count++; 704 uncaught_exception_hit_count++;
703 } 705 }
704 } 706 }
705 707
706 // Collect the JavsScript stack height if the function frame_count is 708 // Collect the JavsScript stack height if the function frame_count is
707 // compiled. 709 // compiled.
708 if (!frame_count.IsEmpty()) { 710 if (!frame_count.IsEmpty()) {
709 static const int kArgc = 1; 711 static const int kArgc = 1;
710 v8::Handle<v8::Value> argv[kArgc] = { exec_state }; 712 v8::Handle<v8::Value> argv[kArgc] = { exec_state };
711 // Using exec_state as receiver is just to have a receiver. 713 // Using exec_state as receiver is just to have a receiver.
712 v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv); 714 v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv);
713 last_js_stack_height = result->Int32Value(); 715 last_js_stack_height = result->Int32Value();
714 } 716 }
717
718 // Run callback from DebugEventListener and check the result.
719 if (!debug_event_listener_callback.IsEmpty()) {
720 v8::Handle<v8::Value> result =
721 debug_event_listener_callback->Call(event_data, 0, NULL);
722 CHECK(!result.IsEmpty());
723 CHECK_EQ(debug_event_listener_callback_result, result->Int32Value());
724 }
715 } 725 }
716 726
717 727
718 // Debug event handler which evaluates a number of expressions when a break 728 // Debug event handler which evaluates a number of expressions when a break
719 // point is hit. Each evaluated expression is compared with an expected value. 729 // point is hit. Each evaluated expression is compared with an expected value.
720 // For this debug event handler to work the following two global varaibles 730 // For this debug event handler to work the following two global varaibles
721 // must be initialized. 731 // must be initialized.
722 // checks: An array of expressions and expected results 732 // checks: An array of expressions and expected results
723 // evaluate_check_function: A JavaScript function (see below) 733 // evaluate_check_function: A JavaScript function (see below)
724 734
(...skipping 3235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3960 CHECK_EQ(2, exception_hit_count); 3970 CHECK_EQ(2, exception_hit_count);
3961 CHECK_EQ(1, uncaught_exception_hit_count); 3971 CHECK_EQ(1, uncaught_exception_hit_count);
3962 CHECK_EQ(1, message_callback_count); 3972 CHECK_EQ(1, message_callback_count);
3963 3973
3964 v8::Debug::SetDebugEventListener(NULL); 3974 v8::Debug::SetDebugEventListener(NULL);
3965 CheckDebuggerUnloaded(); 3975 CheckDebuggerUnloaded();
3966 v8::V8::RemoveMessageListeners(MessageCallbackCount); 3976 v8::V8::RemoveMessageListeners(MessageCallbackCount);
3967 } 3977 }
3968 3978
3969 3979
3980 TEST(EvalJSInDebugEventListenerOnNativeReThrownException) {
3981 DebugLocalContext env;
3982 v8::HandleScope scope(env->GetIsolate());
3983 env.ExposeDebug();
3984
3985 // Create functions for testing break on exception.
3986 v8::Local<v8::Function> noThrowJS = CompileFunction(
3987 &env, "function noThrowJS(){var a=[1]; a.push(2); return a.length;}",
3988 "noThrowJS");
3989
3990 debug_event_listener_callback = noThrowJS;
3991 debug_event_listener_callback_result = 2;
3992
3993 v8::V8::AddMessageListener(MessageCallbackCount);
3994 v8::Debug::SetDebugEventListener(DebugEventCounter);
3995 // Break on uncaught exception
3996 ChangeBreakOnException(false, true);
3997 DebugEventCounterClear();
3998 MessageCallbackCountClear();
3999
4000 // ReThrow native error
4001 {
4002 v8::TryCatch tryCatch;
4003 env->GetIsolate()->ThrowException(v8::Exception::TypeError(
4004 v8::String::NewFromUtf8(env->GetIsolate(), "Type error")));
4005 CHECK(tryCatch.HasCaught());
4006 tryCatch.ReThrow();
4007 }
4008 CHECK_EQ(1, exception_hit_count);
4009 CHECK_EQ(1, uncaught_exception_hit_count);
4010 CHECK_EQ(0, message_callback_count); // FIXME: Should it be 1 ?
4011 CHECK(!debug_event_listener_callback.IsEmpty());
4012
4013 debug_event_listener_callback.Clear();
4014 }
4015
4016
3970 // Test break on exception from compiler errors. When compiling using 4017 // Test break on exception from compiler errors. When compiling using
3971 // v8::Script::Compile there is no JavaScript stack whereas when compiling using 4018 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
3972 // eval there are JavaScript frames. 4019 // eval there are JavaScript frames.
3973 TEST(BreakOnCompileException) { 4020 TEST(BreakOnCompileException) {
3974 DebugLocalContext env; 4021 DebugLocalContext env;
3975 v8::HandleScope scope(env->GetIsolate()); 4022 v8::HandleScope scope(env->GetIsolate());
3976 4023
3977 // For this test, we want to break on uncaught exceptions: 4024 // For this test, we want to break on uncaught exceptions:
3978 ChangeBreakOnException(false, true); 4025 ChangeBreakOnException(false, true);
3979 4026
(...skipping 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after
7415 v8::Isolate* isolate = env->GetIsolate(); 7462 v8::Isolate* isolate = env->GetIsolate();
7416 v8::HandleScope scope(isolate); 7463 v8::HandleScope scope(isolate);
7417 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); 7464 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
7418 TerminationThread terminator(isolate); 7465 TerminationThread terminator(isolate);
7419 terminator.Start(); 7466 terminator.Start();
7420 v8::TryCatch try_catch; 7467 v8::TryCatch try_catch;
7421 v8::Debug::DebugBreak(isolate); 7468 v8::Debug::DebugBreak(isolate);
7422 CompileRun("while (true);"); 7469 CompileRun("while (true);");
7423 CHECK(try_catch.HasTerminated()); 7470 CHECK(try_catch.HasTerminated());
7424 } 7471 }
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698