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

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

Issue 364813002: Reland "Postpone termination exceptions in debug scope." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix test Created 6 years, 5 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/debug.cc ('k') | no next file » | 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 7356 matching lines...) Expand 10 before | Expand all | Expand 10 after
7367 bool terminate_already_fired = false; 7367 bool terminate_already_fired = false;
7368 7368
7369 7369
7370 static void DebugBreakTriggerTerminate( 7370 static void DebugBreakTriggerTerminate(
7371 const v8::Debug::EventDetails& event_details) { 7371 const v8::Debug::EventDetails& event_details) {
7372 if (event_details.GetEvent() != v8::Break || terminate_already_fired) return; 7372 if (event_details.GetEvent() != v8::Break || terminate_already_fired) return;
7373 terminate_requested_semaphore.Signal(); 7373 terminate_requested_semaphore.Signal();
7374 // Wait for at most 2 seconds for the terminate request. 7374 // Wait for at most 2 seconds for the terminate request.
7375 CHECK(terminate_fired_semaphore.WaitFor(v8::base::TimeDelta::FromSeconds(2))); 7375 CHECK(terminate_fired_semaphore.WaitFor(v8::base::TimeDelta::FromSeconds(2)));
7376 terminate_already_fired = true; 7376 terminate_already_fired = true;
7377 v8::internal::Isolate* isolate =
7378 v8::Utils::OpenHandle(*event_details.GetEventContext())->GetIsolate();
7379 CHECK(isolate->stack_guard()->CheckTerminateExecution());
7380 } 7377 }
7381 7378
7382 7379
7383 class TerminationThread : public v8::base::Thread { 7380 class TerminationThread : public v8::base::Thread {
7384 public: 7381 public:
7385 explicit TerminationThread(v8::Isolate* isolate) : Thread("terminator"), 7382 explicit TerminationThread(v8::Isolate* isolate) : Thread("terminator"),
7386 isolate_(isolate) { } 7383 isolate_(isolate) { }
7387 7384
7388 virtual void Run() { 7385 virtual void Run() {
7389 terminate_requested_semaphore.Wait(); 7386 terminate_requested_semaphore.Wait();
7390 v8::V8::TerminateExecution(isolate_); 7387 v8::V8::TerminateExecution(isolate_);
7391 terminate_fired_semaphore.Signal(); 7388 terminate_fired_semaphore.Signal();
7392 } 7389 }
7393 7390
7394 private: 7391 private:
7395 v8::Isolate* isolate_; 7392 v8::Isolate* isolate_;
7396 }; 7393 };
7397 7394
7398 7395
7399 TEST(DebugBreakOffThreadTerminate) { 7396 TEST(DebugBreakOffThreadTerminate) {
7400 DebugLocalContext env; 7397 DebugLocalContext env;
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();
7403 v8::TryCatch try_catch;
7406 v8::Debug::DebugBreak(isolate); 7404 v8::Debug::DebugBreak(isolate);
7407 CompileRun("while (true);"); 7405 CompileRun("while (true);");
7406 CHECK(try_catch.HasTerminated());
7408 } 7407 }
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698