Expose function CheckDebugBreak in the debugger api
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 20 Aug 2014 11:04:05 +0000 (11:04 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 20 Aug 2014 11:04:05 +0000 (11:04 +0000)
API=v8::Debug::CheckDebugBreak
LOG=Y
R=aandrey@chromium.org, vsevik@chromium.org, yurys@chromium.org

Review URL: https://codereview.chromium.org/473913002

Patch from Sergei Vasilinetc <sergeyv@chromium.org>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23227 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

include/v8-debug.h
src/api.cc
test/cctest/test-debug.cc

index e724159..6abf4e0 100644 (file)
@@ -167,6 +167,9 @@ class V8_EXPORT Debug {
   // happened yet.
   static void CancelDebugBreak(Isolate* isolate);
 
+  // Check if a debugger break is scheduled in the given isolate.
+  static bool CheckDebugBreak(Isolate* isolate);
+
   // Break execution of JavaScript in the given isolate (this method
   // can be invoked from a non-VM thread) for further client command
   // execution on a VM thread. Client data is then passed in
index 8d1edbf..69a5062 100644 (file)
@@ -6911,6 +6911,12 @@ void Debug::CancelDebugBreak(Isolate* isolate) {
 }
 
 
+bool Debug::CheckDebugBreak(Isolate* isolate) {
+  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
+  return internal_isolate->stack_guard()->CheckDebugBreak();
+}
+
+
 void Debug::DebugBreakForCommand(Isolate* isolate, ClientData* data) {
   i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
   internal_isolate->debug()->EnqueueDebugCommand(data);
index 5c0b0f3..2680f4e 100644 (file)
@@ -4151,6 +4151,7 @@ TEST(DebugBreak) {
 
   // Set the debug break flag.
   v8::Debug::DebugBreak(env->GetIsolate());
+  CHECK(v8::Debug::CheckDebugBreak(env->GetIsolate()));
 
   // Call all functions with different argument count.
   break_point_hit_count = 0;
@@ -4183,6 +4184,12 @@ TEST(DisableBreak) {
   const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}";
   v8::Local<v8::Function> f = CompileFunction(&env, src, "f");
 
+  // Set, test and cancel debug break.
+  v8::Debug::DebugBreak(env->GetIsolate());
+  CHECK(v8::Debug::CheckDebugBreak(env->GetIsolate()));
+  v8::Debug::CancelDebugBreak(env->GetIsolate());
+  CHECK(!v8::Debug::CheckDebugBreak(env->GetIsolate()));
+
   // Set the debug break flag.
   v8::Debug::DebugBreak(env->GetIsolate());