Give an error when setting break points in functions either defined through the API...
authorsgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 15 Dec 2008 09:15:05 +0000 (09:15 +0000)
committersgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 15 Dec 2008 09:15:05 +0000 (09:15 +0000)
BUG=178
Review URL: http://codereview.chromium.org/13785

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

src/debug-delay.js
src/runtime.cc
src/runtime.h

index 6db054e..8e0c82c 100644 (file)
@@ -474,10 +474,18 @@ Debug.findBreakPoint = function(break_point_number, remove) {
 
 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
   if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.');
+  // Break points in API functions are not supported.
+  if (%FunctionIsAPIFunction(func)) {
+    throw new Error('Cannot set break point in native code.');
+  }
   var source_position = this.findFunctionSourcePosition(func, opt_line, opt_column) -
                         this.sourcePosition(func);
   // Find the script for the function.
   var script = %FunctionGetScript(func);
+  // Break in builtin JavaScript code is not supported.
+  if (script.type == Debug.ScriptType.Native) {
+    throw new Error('Cannot set break point in native code.');
+  }
   // If the script for the function has a name convert this to a script break
   // point.
   if (script && script.name) {
index b400390..24b1904 100644 (file)
@@ -919,6 +919,18 @@ static Object* Runtime_FunctionSetPrototype(Arguments args) {
 }
 
 
+static Object* Runtime_FunctionIsAPIFunction(Arguments args) {
+  NoHandleAllocation ha;
+  ASSERT(args.length() == 1);
+
+  CONVERT_CHECKED(JSFunction, f, args[0]);
+  // The function_data field of the shared function info is used exclusively by
+  // the API.
+  return !f->shared()->function_data()->IsUndefined() ? Heap::true_value()
+                                                      : Heap::false_value();
+}
+
+
 static Object* Runtime_SetCode(Arguments args) {
   HandleScope scope;
   ASSERT(args.length() == 2);
index 98559d4..328178f 100644 (file)
@@ -160,6 +160,7 @@ namespace v8 { namespace internal {
   F(FunctionGetSourceCode, 1) \
   F(FunctionGetScript, 1) \
   F(FunctionGetScriptSourcePosition, 1) \
+  F(FunctionIsAPIFunction, 1) \
   F(GetScript, 1) \
   \
   F(ClassOf, 1) \