Bug 1043578 - Remove JS_SetDebuggerHandler and friends. r=jimb

This commit is contained in:
Tom Schuster 2014-07-25 14:26:40 +02:00
Родитель caaba7d772
Коммит 1bc16cea39
12 изменённых файлов: 2 добавлений и 225 удалений

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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");

Просмотреть файл

@ -1,10 +0,0 @@
// |jit-test| debug
function main() {
debugger;
return "failure";
}
setDebuggerHandler("'success'");
setDebug(true);
assertEq(main(), "success");

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<const jschar> 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."),

Просмотреть файл

@ -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:

Просмотреть файл

@ -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

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);
/***************************************************************************/