Reviewers: Christian Plesner Hansen, Description: Give an error when setting break points in functions either defined through the API or in functions which are part of the V8 builtins.
BUG=178 Please review this at http://codereview.chromium.org/13785 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/debug-delay.js M src/runtime.h M src/runtime.cc Index: src/debug-delay.js =================================================================== --- src/debug-delay.js (revision 969) +++ src/debug-delay.js (working copy) @@ -474,10 +474,18 @@ 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: src/runtime.cc =================================================================== --- src/runtime.cc (revision 969) +++ src/runtime.cc (working copy) @@ -919,6 +919,18 @@ } +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: src/runtime.h =================================================================== --- src/runtime.h (revision 969) +++ src/runtime.h (working copy) @@ -160,6 +160,7 @@ F(FunctionGetSourceCode, 1) \ F(FunctionGetScript, 1) \ F(FunctionGetScriptSourcePosition, 1) \ + F(FunctionIsAPIFunction, 1) \ F(GetScript, 1) \ \ F(ClassOf, 1) \ --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
