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

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

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

Powered by Google App Engine
This is Rietveld 408576698