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

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

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