diff --git a/js/public/OldDebugAPI.h b/js/public/OldDebugAPI.h index 1e510e5e3bac..f4d3afa4b478 100644 --- a/js/public/OldDebugAPI.h +++ b/js/public/OldDebugAPI.h @@ -59,10 +59,6 @@ typedef enum JSTrapStatus { JSTRAP_LIMIT } JSTrapStatus; -typedef JSTrapStatus -(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval, - void *closure); - typedef bool (* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, JS::Value old, JS::Value *newp, void *closure); @@ -319,25 +315,9 @@ class JS_PUBLIC_API(JSBrokenFrameIterator) bool isConstructing() const; }; -typedef bool -(* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report, - void *closure); - -typedef struct JSDebugHooks { - JSDebuggerHandler debuggerHandler; - void *debuggerHandlerData; -} JSDebugHooks; /************************************************************************/ -extern JS_PUBLIC_API(bool) -JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure); - -/************************************************************************/ - -extern JS_PUBLIC_API(const JSDebugHooks *) -JS_GetGlobalDebugHooks(JSRuntime *rt); - /** * Add various profiling-related functions as properties of the given object. */ @@ -354,13 +334,4 @@ JS_DumpPCCounts(JSContext *cx, JS::HandleScript script); extern JS_PUBLIC_API(void) JS_DumpCompartmentPCCounts(JSContext *cx); -namespace js { -extern JS_FRIEND_API(bool) -CanCallContextDebugHandler(JSContext *cx); -} - -/* Call the context debug handler on the topmost scripted frame. */ -extern JS_FRIEND_API(bool) -js_CallContextDebugHandler(JSContext *cx); - #endif /* js_OldDebugAPI_h */ diff --git a/js/src/jit-test/tests/jaeger/bug563000/test-debugger-1.js b/js/src/jit-test/tests/jaeger/bug563000/test-debugger-1.js deleted file mode 100644 index 5ba1bf681685..000000000000 --- a/js/src/jit-test/tests/jaeger/bug563000/test-debugger-1.js +++ /dev/null @@ -1,13 +0,0 @@ -// |jit-test| debug -var result = "unset"; -function main() { - result = "failure"; - debugger; -} -function nop() { } - -setDebuggerHandler("result = 'success'; nop()"); -setDebug(true); - -main(); -assertEq(result, "success"); diff --git a/js/src/jit-test/tests/jaeger/bug563000/test-debugger-2.js b/js/src/jit-test/tests/jaeger/bug563000/test-debugger-2.js deleted file mode 100644 index 291d1819da11..000000000000 --- a/js/src/jit-test/tests/jaeger/bug563000/test-debugger-2.js +++ /dev/null @@ -1,10 +0,0 @@ -// |jit-test| debug -function main() { - debugger; - return "failure"; -} - -setDebuggerHandler("'success'"); -setDebug(true); - -assertEq(main(), "success"); diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 33c9c90007b9..18cacf5e9a48 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -924,16 +924,9 @@ OnDebuggerStatement(JSContext *cx, BaselineFrame *frame, jsbytecode *pc, bool *m *mustReturn = false; RootedScript script(cx, frame->script()); - JSTrapStatus status = JSTRAP_CONTINUE; RootedValue rval(cx); - if (JSDebuggerHandler handler = cx->runtime()->debugHooks.debuggerHandler) - status = handler(cx, script, pc, rval.address(), cx->runtime()->debugHooks.debuggerHandlerData); - - if (status == JSTRAP_CONTINUE) - status = Debugger::onDebuggerStatement(cx, &rval); - - switch (status) { + switch (Debugger::onDebuggerStatement(cx, &rval)) { case JSTRAP_ERROR: return false; diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index e7670c1d7755..0f75a56e7af3 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -1781,65 +1781,6 @@ GetScriptAndPCArgs(JSContext *cx, unsigned argc, jsval *argv, MutableHandleScrip return true; } -static JSTrapStatus -TrapHandler(JSContext *cx, JSScript *, jsbytecode *pc, jsval *rvalArg, - jsval closure) -{ - RootedString str(cx, closure.toString()); - RootedValue rval(cx, *rvalArg); - - ScriptFrameIter iter(cx); - JS_ASSERT(!iter.done()); - - /* Debug-mode currently disables Ion compilation. */ - JSAbstractFramePtr frame(iter.abstractFramePtr().raw(), iter.pc()); - RootedScript script(cx, iter.script()); - - AutoStableStringChars stableChars(cx); - if (!stableChars.initTwoByte(cx, str)) - return JSTRAP_ERROR; - - mozilla::Range chars = stableChars.twoByteRange(); - if (!frame.evaluateUCInStackFrame(cx, chars.start().get(), chars.length(), - script->filename(), - script->lineno(), - &rval)) - { - *rvalArg = rval; - return JSTRAP_ERROR; - } - *rvalArg = rval; - if (!rval.isUndefined()) - return JSTRAP_RETURN; - return JSTRAP_CONTINUE; -} - -static JSTrapStatus -DebuggerAndThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, - void *closure) -{ - return TrapHandler(cx, script, pc, rval, STRING_TO_JSVAL((JSString *)closure)); -} - -static bool -SetDebuggerHandler(JSContext *cx, unsigned argc, jsval *vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - if (args.length() == 0) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - JSSMSG_NOT_ENOUGH_ARGS, "setDebuggerHandler"); - return false; - } - - JSString *str = JS::ToString(cx, args[0]); - if (!str) - return false; - - JS_SetDebuggerHandler(cx->runtime(), DebuggerAndThrowHandler, str); - args.rval().setUndefined(); - return true; -} - static bool LineToPC(JSContext *cx, unsigned argc, jsval *vp) { @@ -4496,10 +4437,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = { "setDebug(debug)", " Set debug mode."), - JS_FN_HELP("setDebuggerHandler", SetDebuggerHandler, 1, 0, -"setDebuggerHandler(f)", -" Set handler for debugger keyword to f."), - JS_FN_HELP("throwError", ThrowError, 0, 0, "throwError()", " Throw an error from JS_ReportError."), diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 210ddca5ac2e..71747c7f68da 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -3264,13 +3264,8 @@ END_CASE(JSOP_INSTANCEOF) CASE(JSOP_DEBUGGER) { - JSTrapStatus st = JSTRAP_CONTINUE; RootedValue rval(cx); - if (JSDebuggerHandler handler = cx->runtime()->debugHooks.debuggerHandler) - st = handler(cx, script, REGS.pc, rval.address(), cx->runtime()->debugHooks.debuggerHandlerData); - if (st == JSTRAP_CONTINUE) - st = Debugger::onDebuggerStatement(cx, &rval); - switch (st) { + switch (Debugger::onDebuggerStatement(cx, &rval)) { case JSTRAP_ERROR: goto error; case JSTRAP_CONTINUE: diff --git a/js/src/vm/OldDebugAPI.cpp b/js/src/vm/OldDebugAPI.cpp index 0a5e8b86043e..3bd15278dbab 100644 --- a/js/src/vm/OldDebugAPI.cpp +++ b/js/src/vm/OldDebugAPI.cpp @@ -608,23 +608,6 @@ JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda) pda->length = 0; } -/************************************************************************/ - -JS_PUBLIC_API(bool) -JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler handler, void *closure) -{ - rt->debugHooks.debuggerHandler = handler; - rt->debugHooks.debuggerHandlerData = closure; - return true; -} - -/************************************************************************/ - -JS_PUBLIC_API(const JSDebugHooks *) -JS_GetGlobalDebugHooks(JSRuntime *rt) -{ - return &rt->debugHooks; -} /************************************************************************/ @@ -684,53 +667,6 @@ JS_DumpCompartmentPCCounts(JSContext *cx) #endif } -JS_FRIEND_API(bool) -js::CanCallContextDebugHandler(JSContext *cx) -{ - return !!cx->runtime()->debugHooks.debuggerHandler; -} - -static JSTrapStatus -CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval) -{ - if (!cx->runtime()->debugHooks.debuggerHandler) - return JSTRAP_RETURN; - - return cx->runtime()->debugHooks.debuggerHandler(cx, script, bc, rval, - cx->runtime()->debugHooks.debuggerHandlerData); -} - -JS_FRIEND_API(bool) -js_CallContextDebugHandler(JSContext *cx) -{ - NonBuiltinFrameIter iter(cx); - - // If there is no script to debug, then abort execution even if the user - // clicks 'Debug' in the slow-script dialog. - if (!iter.hasScript()) - return false; - - // Even if script was running during the operation callback, it's possible - // it was a builtin which 'iter' will have skipped over. - if (iter.done()) - return false; - - RootedValue rval(cx); - RootedScript script(cx, iter.script()); - switch (CallContextDebugHandler(cx, script, iter.pc(), rval.address())) { - case JSTRAP_ERROR: - JS_ClearPendingException(cx); - return false; - case JSTRAP_THROW: - JS_SetPendingException(cx, rval); - return false; - case JSTRAP_RETURN: - case JSTRAP_CONTINUE: - default: - return true; - } -} - namespace { class AutoPropertyDescArray diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 41d9f7e942ed..a7f17011f657 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -232,7 +232,6 @@ JSRuntime::JSRuntime(JSRuntime *parentRuntime) /* Initialize infallibly first, so we can goto bad and JS_DestroyRuntime. */ JS_INIT_CLIST(&onNewGlobalObjectWatchers); - PodZero(&debugHooks); PodArrayZero(nativeStackQuota); PodZero(&asmJSCacheOps); } diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index a11a71761def..0d9a4a33dc52 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -1016,9 +1016,6 @@ struct JSRuntime : public JS::shadow::Runtime, js::AssertOnScriptEntryHook assertOnScriptEntryHook_; #endif - /* Per runtime debug hooks -- see js/OldDebugAPI.h. */ - JSDebugHooks debugHooks; - /* If true, new compartments are initially in debug mode. */ bool debugMode; diff --git a/js/xpconnect/src/XPCDebug.cpp b/js/xpconnect/src/XPCDebug.cpp index e15b12219dd3..278412d813e3 100644 --- a/js/xpconnect/src/XPCDebug.cpp +++ b/js/xpconnect/src/XPCDebug.cpp @@ -112,23 +112,3 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, uint32_t frameno, const char* text) exceptionState.restore(); return true; } - -/***************************************************************************/ - -JSTrapStatus -xpc_DebuggerKeywordHandler(JSContext *cx, JSScript *script, jsbytecode *pc, - jsval *rval, void *closure) -{ - static const char line[] = - "------------------------------------------------------------------------\n"; - DebugDump("%s", line); - DebugDump("%s", "Hit JavaScript \"debugger\" keyword. JS call stack...\n"); - xpc_DumpJSStack(cx, true, true, false); - DebugDump("%s", line); - return JSTRAP_CONTINUE; -} - -bool xpc_InstallJSDebuggerKeywordHandler(JSRuntime* rt) -{ - return JS_SetDebuggerHandler(rt, xpc_DebuggerKeywordHandler, nullptr); -} diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index dc780e04b3b7..e4d36ac9d814 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -3272,12 +3272,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) RegisterJSMainRuntimeCompartmentsUserDistinguishedAmount(JSMainRuntimeCompartmentsUserDistinguishedAmount); mozilla::RegisterJSSizeOfTab(JSSizeOfTab); - // Install a JavaScript 'debugger' keyword handler in debug builds only -#ifdef DEBUG - if (!JS_GetGlobalDebugHooks(runtime)->debuggerHandler) - xpc_InstallJSDebuggerKeywordHandler(runtime); -#endif - // Watch for the JS boolean options. ReloadPrefsCallback(nullptr, this); Preferences::RegisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this); diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index d07dc3d8d2b3..f8e1bfeff61c 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -2973,8 +2973,6 @@ xpc_PrintJSStack(JSContext* cx, bool showArgs, bool showLocals, extern bool xpc_DumpEvalInJSStackFrame(JSContext* cx, uint32_t frameno, const char* text); -extern bool -xpc_InstallJSDebuggerKeywordHandler(JSRuntime* rt); /***************************************************************************/