Revision: 5480
Author: [email protected]
Date: Thu Sep 16 14:40:42 2010
Log: Add breakOnCaughtException and breakOnUncaughtException flags

Review URL: http://codereview.chromium.org/3275011
http://code.google.com/p/v8/source/detail?r=5480

Modified:
 /branches/bleeding_edge/src/debug-debugger.js
 /branches/bleeding_edge/src/debug.cc
 /branches/bleeding_edge/src/debug.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/runtime.h

=======================================
--- /branches/bleeding_edge/src/debug-debugger.js       Fri Jul 30 04:58:43 2010
+++ /branches/bleeding_edge/src/debug-debugger.js       Thu Sep 16 14:40:42 2010
@@ -45,7 +45,7 @@
                      ScriptCollected: 6 };

 // Types of exceptions that can be broken upon.
-Debug.ExceptionBreak = { All : 0,
+Debug.ExceptionBreak = { Caught : 0,
                          Uncaught: 1 };

 // The different types of steps.
@@ -87,7 +87,27 @@
       this.value = !!value;
       %SetDisableBreak(!this.value);
     }
-  }
+  },
+  breakOnCaughtException: {
+    getValue: function() { return Debug.isBreakOnException(); },
+    setValue: function(value) {
+      if (value) {
+        Debug.setBreakOnException();
+      } else {
+        Debug.clearBreakOnException();
+      }
+    }
+  },
+  breakOnUncaughtException: {
+    getValue: function() { return Debug.isBreakOnUncaughtException(); },
+    setValue: function(value) {
+      if (value) {
+        Debug.setBreakOnUncaughtException();
+      } else {
+        Debug.clearBreakOnUncaughtException();
+      }
+    }
+  },
 };


@@ -781,13 +801,17 @@
 }

 Debug.setBreakOnException = function() {
-  return %ChangeBreakOnException(Debug.ExceptionBreak.All, true);
+  return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, true);
 };

 Debug.clearBreakOnException = function() {
-  return %ChangeBreakOnException(Debug.ExceptionBreak.All, false);
+  return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, false);
 };

+Debug.isBreakOnException = function() {
+  return !!%IsBreakOnException(Debug.ExceptionBreak.Caught);
+};
+
 Debug.setBreakOnUncaughtException = function() {
   return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, true);
 };
@@ -796,6 +820,10 @@
   return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false);
 };

+Debug.isBreakOnUncaughtException = function() {
+  return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
+};
+
 Debug.showBreakPoints = function(f, full) {
   if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.');
   var source = full ? this.scriptSource(f) : this.source(f);
=======================================
--- /branches/bleeding_edge/src/debug.cc        Tue Aug 31 01:05:42 2010
+++ /branches/bleeding_edge/src/debug.cc        Thu Sep 16 14:40:42 2010
@@ -1198,6 +1198,15 @@
     break_on_exception_ = enable;
   }
 }
+
+
+bool Debug::IsBreakOnException(ExceptionBreakType type) {
+  if (type == BreakUncaughtException) {
+    return break_on_uncaught_exception_;
+  } else {
+    return break_on_exception_;
+  }
+}


 void Debug::PrepareStep(StepAction step_action, int step_count) {
=======================================
--- /branches/bleeding_edge/src/debug.h Mon Aug 30 04:48:07 2010
+++ /branches/bleeding_edge/src/debug.h Thu Sep 16 14:40:42 2010
@@ -236,6 +236,7 @@
   static void FloodWithOneShot(Handle<SharedFunctionInfo> shared);
   static void FloodHandlerWithOneShot();
   static void ChangeBreakOnException(ExceptionBreakType type, bool enable);
+  static bool IsBreakOnException(ExceptionBreakType type);
   static void PrepareStep(StepAction step_action, int step_count);
   static void ClearStepping();
static bool StepNextContinue(BreakLocationIterator* break_location_iterator,
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Tue Sep 14 08:16:32 2010
+++ /branches/bleeding_edge/src/runtime.cc      Thu Sep 16 14:40:42 2010
@@ -8960,6 +8960,20 @@
   Debug::ChangeBreakOnException(type, enable);
   return Heap::undefined_value();
 }
+
+
+// Returns the state of break on exceptions
+// args[0]: boolean indicating uncaught exceptions
+static Object* Runtime_IsBreakOnException(Arguments args) {
+  HandleScope scope;
+  ASSERT(args.length() == 1);
+  ASSERT(args[0]->IsNumber());
+
+  ExceptionBreakType type =
+      static_cast<ExceptionBreakType>(NumberToUint32(args[0]));
+  bool result = Debug::IsBreakOnException(type);
+  return Smi::FromInt(result);
+}


 // Prepare for stepping
=======================================
--- /branches/bleeding_edge/src/runtime.h       Tue Sep 14 07:52:53 2010
+++ /branches/bleeding_edge/src/runtime.h       Thu Sep 16 14:40:42 2010
@@ -332,6 +332,7 @@
   F(SetScriptBreakPoint, 3, 1) \
   F(ClearBreakPoint, 1, 1) \
   F(ChangeBreakOnException, 2, 1) \
+  F(IsBreakOnException, 1, 1) \
   F(PrepareStep, 3, 1) \
   F(ClearStepping, 0, 1) \
   F(DebugEvaluate, 4, 1) \

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to