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 6606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6617 | 6617 |
6618 | 6618 |
6619 // Test that debug messages get processed when ProcessDebugMessages is called. | 6619 // Test that debug messages get processed when ProcessDebugMessages is called. |
6620 TEST(Backtrace) { | 6620 TEST(Backtrace) { |
6621 DebugLocalContext env; | 6621 DebugLocalContext env; |
6622 v8::Isolate* isolate = env->GetIsolate(); | 6622 v8::Isolate* isolate = env->GetIsolate(); |
6623 v8::HandleScope scope(isolate); | 6623 v8::HandleScope scope(isolate); |
6624 | 6624 |
6625 v8::Debug::SetMessageHandler(BacktraceData::MessageHandler); | 6625 v8::Debug::SetMessageHandler(BacktraceData::MessageHandler); |
6626 | 6626 |
| 6627 // TODO(mstarzinger): This doesn't work with --always-opt because we don't |
| 6628 // have correct source positions in optimized code. Enable once we have. |
| 6629 i::FLAG_always_opt = false; |
| 6630 |
6627 const int kBufferSize = 1000; | 6631 const int kBufferSize = 1000; |
6628 uint16_t buffer[kBufferSize]; | 6632 uint16_t buffer[kBufferSize]; |
6629 const char* scripts_command = | 6633 const char* scripts_command = |
6630 "{\"seq\":0," | 6634 "{\"seq\":0," |
6631 "\"type\":\"request\"," | 6635 "\"type\":\"request\"," |
6632 "\"command\":\"backtrace\"}"; | 6636 "\"command\":\"backtrace\"}"; |
6633 | 6637 |
6634 // Check backtrace from ProcessDebugMessages. | 6638 // Check backtrace from ProcessDebugMessages. |
6635 BacktraceData::frame_counter = -10; | 6639 BacktraceData::frame_counter = -10; |
6636 v8::Debug::SendCommand( | 6640 v8::Debug::SendCommand( |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6955 | 6959 |
6956 | 6960 |
6957 // Set a debug event listener which will keep interrupting execution until | 6961 // Set a debug event listener which will keep interrupting execution until |
6958 // debug break. When inside function bar it will deoptimize all functions. | 6962 // debug break. When inside function bar it will deoptimize all functions. |
6959 // This tests lazy deoptimization bailout for the stack check, as the first | 6963 // This tests lazy deoptimization bailout for the stack check, as the first |
6960 // time in function bar when using debug break and no break points will be at | 6964 // time in function bar when using debug break and no break points will be at |
6961 // the initial stack check. | 6965 // the initial stack check. |
6962 v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize); | 6966 v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize); |
6963 | 6967 |
6964 // Compile and run function bar which will optimize it for some flag settings. | 6968 // Compile and run function bar which will optimize it for some flag settings. |
6965 v8::Script::Compile(v8::String::NewFromUtf8( | 6969 v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar"); |
6966 env->GetIsolate(), "function bar(){}; bar()"))->Run(); | 6970 f->Call(v8::Undefined(env->GetIsolate()), 0, NULL); |
6967 | 6971 |
6968 // Set debug break and call bar again. | 6972 // Set debug break and call bar again. |
6969 v8::Debug::DebugBreak(env->GetIsolate()); | 6973 v8::Debug::DebugBreak(env->GetIsolate()); |
6970 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar()")) | 6974 f->Call(v8::Undefined(env->GetIsolate()), 0, NULL); |
6971 ->Run(); | |
6972 | 6975 |
6973 CHECK(debug_event_break_deoptimize_done); | 6976 CHECK(debug_event_break_deoptimize_done); |
6974 | 6977 |
6975 v8::Debug::SetDebugEventListener(NULL); | 6978 v8::Debug::SetDebugEventListener(NULL); |
6976 } | 6979 } |
6977 | 6980 |
6978 | 6981 |
6979 static void DebugEventBreakWithOptimizedStack( | 6982 static void DebugEventBreakWithOptimizedStack( |
6980 const v8::Debug::EventDetails& event_details) { | 6983 const v8::Debug::EventDetails& event_details) { |
6981 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); | 6984 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7398 v8::Isolate* isolate = env->GetIsolate(); | 7401 v8::Isolate* isolate = env->GetIsolate(); |
7399 v8::HandleScope scope(isolate); | 7402 v8::HandleScope scope(isolate); |
7400 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); | 7403 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); |
7401 TerminationThread terminator(isolate); | 7404 TerminationThread terminator(isolate); |
7402 terminator.Start(); | 7405 terminator.Start(); |
7403 v8::TryCatch try_catch; | 7406 v8::TryCatch try_catch; |
7404 v8::Debug::DebugBreak(isolate); | 7407 v8::Debug::DebugBreak(isolate); |
7405 CompileRun("while (true);"); | 7408 CompileRun("while (true);"); |
7406 CHECK(try_catch.HasTerminated()); | 7409 CHECK(try_catch.HasTerminated()); |
7407 } | 7410 } |
OLD | NEW |