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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 inline v8::Local<v8::Context> context() { return context_; } | 92 inline v8::Local<v8::Context> context() { return context_; } |
93 inline v8::Context* operator->() { return *context_; } | 93 inline v8::Context* operator->() { return *context_; } |
94 inline v8::Context* operator*() { return *context_; } | 94 inline v8::Context* operator*() { return *context_; } |
95 inline v8::Isolate* GetIsolate() { return context_->GetIsolate(); } | 95 inline v8::Isolate* GetIsolate() { return context_->GetIsolate(); } |
96 inline bool IsReady() { return !context_.IsEmpty(); } | 96 inline bool IsReady() { return !context_.IsEmpty(); } |
97 void ExposeDebug() { | 97 void ExposeDebug() { |
98 v8::internal::Isolate* isolate = | 98 v8::internal::Isolate* isolate = |
99 reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); | 99 reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); |
100 v8::internal::Factory* factory = isolate->factory(); | 100 v8::internal::Factory* factory = isolate->factory(); |
101 v8::internal::Debug* debug = isolate->debug(); | |
102 // Expose the debug context global object in the global object for testing. | 101 // Expose the debug context global object in the global object for testing. |
103 debug->Load(); | 102 CHECK(isolate->debug()->Load()); |
104 debug->debug_context()->set_security_token( | 103 Handle<v8::internal::Context> debug_context = |
| 104 isolate->debug()->debug_context(); |
| 105 debug_context->set_security_token( |
105 v8::Utils::OpenHandle(*context_)->security_token()); | 106 v8::Utils::OpenHandle(*context_)->security_token()); |
106 | 107 |
107 Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( | 108 Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( |
108 v8::Utils::OpenHandle(*context_->Global()))); | 109 v8::Utils::OpenHandle(*context_->Global()))); |
109 Handle<v8::internal::String> debug_string = | 110 Handle<v8::internal::String> debug_string = |
110 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug")); | 111 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug")); |
111 v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string, | 112 v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string, |
112 Handle<Object>(debug->debug_context()->global_proxy(), isolate), | 113 Handle<Object>(debug_context->global_proxy(), isolate), |
113 DONT_ENUM, | 114 DONT_ENUM, |
114 ::v8::internal::SLOPPY).Check(); | 115 ::v8::internal::SLOPPY).Check(); |
115 } | 116 } |
116 | 117 |
117 private: | 118 private: |
118 v8::HandleScope scope_; | 119 v8::HandleScope scope_; |
119 v8::Local<v8::Context> context_; | 120 v8::Local<v8::Context> context_; |
120 }; | 121 }; |
121 | 122 |
122 | 123 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } else if (RelocInfo::IsJSReturn(rmode)) { | 415 } else if (RelocInfo::IsJSReturn(rmode)) { |
415 CHECK(!Debug::IsDebugBreakAtReturn(it.rinfo())); | 416 CHECK(!Debug::IsDebugBreakAtReturn(it.rinfo())); |
416 } | 417 } |
417 } | 418 } |
418 } | 419 } |
419 } | 420 } |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 | 424 |
424 void ForceUnloadDebugger() { | |
425 CcTest::i_isolate()->debugger()->never_unload_debugger_ = false; | |
426 CcTest::i_isolate()->debugger()->UnloadDebugger(); | |
427 } | |
428 | |
429 | |
430 } } // namespace v8::internal | 425 } } // namespace v8::internal |
431 | 426 |
432 | 427 |
433 // Check that the debugger has been fully unloaded. | 428 // Check that the debugger has been fully unloaded. |
434 static void CheckDebuggerUnloaded(bool check_functions = false) { | 429 static void CheckDebuggerUnloaded(bool check_functions = false) { |
435 // Let debugger to unload itself synchronously | 430 // Let debugger to unload itself synchronously |
436 v8::Debug::ProcessDebugMessages(); | 431 v8::Debug::ProcessDebugMessages(); |
437 | 432 |
438 v8::internal::CheckDebuggerUnloaded(check_functions); | 433 v8::internal::CheckDebuggerUnloaded(check_functions); |
439 } | 434 } |
(...skipping 5053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5493 | 5488 |
5494 // Function to test passing an additional parameter to a JavaScript function | 5489 // Function to test passing an additional parameter to a JavaScript function |
5495 // called in the debugger. It also tests that functions called in the debugger | 5490 // called in the debugger. It also tests that functions called in the debugger |
5496 // can throw exceptions. | 5491 // can throw exceptions. |
5497 static void CheckDataParameter( | 5492 static void CheckDataParameter( |
5498 const v8::FunctionCallbackInfo<v8::Value>& args) { | 5493 const v8::FunctionCallbackInfo<v8::Value>& args) { |
5499 v8::Handle<v8::String> data = | 5494 v8::Handle<v8::String> data = |
5500 v8::String::NewFromUtf8(args.GetIsolate(), "Test"); | 5495 v8::String::NewFromUtf8(args.GetIsolate(), "Test"); |
5501 CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString()); | 5496 CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString()); |
5502 | 5497 |
5503 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); | 5498 for (int i = 0; i < 3; i++) { |
5504 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); | 5499 v8::TryCatch catcher; |
5505 | 5500 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); |
5506 v8::TryCatch catcher; | 5501 CHECK(catcher.HasCaught()); |
5507 v8::Debug::Call(debugger_call_with_data); | 5502 CHECK(catcher.Exception()->IsString()); |
5508 CHECK(catcher.HasCaught()); | 5503 } |
5509 CHECK(catcher.Exception()->IsString()); | |
5510 } | 5504 } |
5511 | 5505 |
5512 | 5506 |
5513 // Function to test using a JavaScript with closure in the debugger. | 5507 // Function to test using a JavaScript with closure in the debugger. |
5514 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5508 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { |
5515 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); | 5509 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); |
5516 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); | 5510 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); |
5517 } | 5511 } |
5518 | 5512 |
5519 | 5513 |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6865 | 6859 |
6866 v8::Debug::SetDebugEventListener(NULL); | 6860 v8::Debug::SetDebugEventListener(NULL); |
6867 debugee_context = v8::Handle<v8::Context>(); | 6861 debugee_context = v8::Handle<v8::Context>(); |
6868 debugger_context = v8::Handle<v8::Context>(); | 6862 debugger_context = v8::Handle<v8::Context>(); |
6869 CheckDebuggerUnloaded(); | 6863 CheckDebuggerUnloaded(); |
6870 } | 6864 } |
6871 | 6865 |
6872 | 6866 |
6873 TEST(DebugContextIsPreservedBetweenAccesses) { | 6867 TEST(DebugContextIsPreservedBetweenAccesses) { |
6874 v8::HandleScope scope(CcTest::isolate()); | 6868 v8::HandleScope scope(CcTest::isolate()); |
| 6869 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); |
6875 v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext(); | 6870 v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext(); |
6876 v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext(); | 6871 v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext(); |
6877 CHECK_EQ(*context1, *context2); | 6872 CHECK(v8::Utils::OpenHandle(*context1).is_identical_to( |
| 6873 v8::Utils::OpenHandle(*context2))); |
| 6874 v8::Debug::SetDebugEventListener(NULL); |
6878 } | 6875 } |
6879 | 6876 |
6880 | 6877 |
6881 static v8::Handle<v8::Value> expected_callback_data; | 6878 static v8::Handle<v8::Value> expected_callback_data; |
6882 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { | 6879 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { |
6883 CHECK(details.GetEventContext() == expected_context); | 6880 CHECK(details.GetEventContext() == expected_context); |
6884 CHECK_EQ(expected_callback_data, details.GetCallbackData()); | 6881 CHECK_EQ(expected_callback_data, details.GetCallbackData()); |
6885 } | 6882 } |
6886 | 6883 |
6887 | 6884 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7421 env->Global()->Set(v8_str("add_debug_break"), add_debug_break); | 7418 env->Global()->Set(v8_str("add_debug_break"), add_debug_break); |
7422 | 7419 |
7423 CompileRun("(function loop() {" | 7420 CompileRun("(function loop() {" |
7424 " for (var j = 0; j < 1000; j++) {" | 7421 " for (var j = 0; j < 1000; j++) {" |
7425 " for (var i = 0; i < 1000; i++) {" | 7422 " for (var i = 0; i < 1000; i++) {" |
7426 " if (i == 999) add_debug_break();" | 7423 " if (i == 999) add_debug_break();" |
7427 " }" | 7424 " }" |
7428 " }" | 7425 " }" |
7429 "})()"); | 7426 "})()"); |
7430 } | 7427 } |
OLD | NEW |