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