diff --git a/extensions/venkman/resources/content/venkman-commands.js b/extensions/venkman/resources/content/venkman-commands.js index f2d6acc4a373..bd2afd02276f 100644 --- a/extensions/venkman/resources/content/venkman-commands.js +++ b/extensions/venkman/resources/content/venkman-commands.js @@ -53,6 +53,7 @@ function initCommands(commandObject) ["clear-script", cmdClearScript, 0], ["commands", cmdCommands, CMD_CONSOLE], ["cont", cmdCont, CMD_CONSOLE | CMD_NEED_STACK], + ["emode", cmdEMode, CMD_CONSOLE], ["eval", cmdEval, CMD_CONSOLE | CMD_NEED_STACK], ["evald", cmdEvald, CMD_CONSOLE], ["fbreak", cmdFBreak, CMD_CONSOLE], @@ -86,6 +87,10 @@ function initCommands(commandObject) /* aliases */ ["this", "props this", CMD_CONSOLE], ["toggle-ias", "startup-init toggle", 0], + ["em-cycle", "emode cycle", 0], + ["em-ignore", "emode ignore", 0], + ["em-trace", "emode trace", 0], + ["em-break", "emode break", 0], ["tm-cycle", "tmode cycle", 0], ["tm-ignore", "tmode ignore", 0], ["tm-trace", "tmode trace", 0], @@ -311,6 +316,62 @@ function cmdCont (e) console.jsds.exitNestedEventLoop(); } +function cmdEMode (e) +{ + if (e.mode != null) + { + e.mode = e.mode.toLowerCase(); + + if (e.mode == "cycle") + { + switch (console.errorMode) + { + case EMODE_IGNORE: + e.mode = "trace"; + break; + case EMODE_TRACE: + e.mode = "break"; + break; + case EMODE_BREAK: + e.mode = "ignore"; + break; + } + } + + switch (e.mode) + { + case "ignore": + console.errorMode = EMODE_IGNORE; + break; + case "trace": + console.errorMode = EMODE_TRACE; + break; + case "break": + console.errorMode = EMODE_BREAK; + break; + default: + display (getMsg(MSN_ERR_INVALID_PARAM, ["mode", e.mode]), + MT_ERROR); + return false; + } + } + + switch (console.errorMode) + { + case EMODE_IGNORE: + display (MSG_EMODE_IGNORE); + break; + case EMODE_TRACE: + display (MSG_EMODE_TRACE); + break; + case EMODE_BREAK: + display (MSG_EMODE_BREAK); + break; + } + + return true; +} + function cmdEval (e) { display (e.scriptText, MT_FEVAL_IN); @@ -733,34 +794,60 @@ function cmdStop (e) function cmdTMode (e) { - if (e.mode.search(/ignore/i) != -1) + if (e.mode != null) { - setThrowMode(TMODE_IGNORE); - return true; + e.mode = e.mode.toLowerCase(); + + if (e.mode == "cycle") + { + switch (console.throwMode) + { + case TMODE_IGNORE: + e.mode = "trace"; + break; + case TMODE_TRACE: + e.mode = "break"; + break; + case TMODE_BREAK: + e.mode = "ignore"; + break; + } + } + + switch (e.mode.toLowerCase()) + { + case "ignore": + console.jsds.throwHook = null; + console.throwMode = TMODE_IGNORE; + break; + case "trace": + console.jsds.throwHook = console._executionHook; + console.throwMode = TMODE_TRACE; + break; + case "break": + console.jsds.throwHook = console._executionHook; + console.throwMode = TMODE_BREAK; + break; + default: + display (getMsg(MSN_ERR_INVALID_PARAM, ["mode", e.mode]), + MT_ERROR); + return false; + } } - else if (e.mode.search(/trace/i) != -1) + + switch (console.throwMode) { - setThrowMode(TMODE_TRACE); - return true; - } - else if (e.mode.search(/breaK/i) != -1) - { - setThrowMode(TMODE_BREAK); - return true; - } - else if (e.mode.search(/cycle/i) != -1) - { - cycleThrowMode(); - return true; - } - else if (e.mode) - { - display (getMsg(MSN_ERR_INVALID_PARAM, ["mode", e.mode]), MT_ERROR); - return false; + case EMODE_IGNORE: + display (MSG_TMODE_IGNORE); + break; + case EMODE_TRACE: + display (MSG_TMODE_TRACE); + break; + case EMODE_BREAK: + display (MSG_TMODE_BREAK); + break; } - /* display the current throw mode */ - setThrowMode(getThrowMode()); return true; } diff --git a/extensions/venkman/resources/content/venkman-debugger.js b/extensions/venkman/resources/content/venkman-debugger.js index afe307ea2b89..b4c5e3ae26ed 100644 --- a/extensions/venkman/resources/content/venkman-debugger.js +++ b/extensions/venkman/resources/content/venkman-debugger.js @@ -36,6 +36,7 @@ const JSD_CTRID = "@mozilla.org/js/jsd/debugger-service;1"; const jsdIDebuggerService = Components.interfaces.jsdIDebuggerService; const jsdIExecutionHook = Components.interfaces.jsdIExecutionHook; +const jsdIErrorHook = Components.interfaces.jsdIErrorHook; const jsdICallHook = Components.interfaces.jsdICallHook; const jsdIValue = Components.interfaces.jsdIValue; const jsdIProperty = Components.interfaces.jsdIProperty; @@ -100,19 +101,28 @@ console._callHook = { } }; -console._debugHook = { - onExecute: function debughook (frame, type, rv) { - display ("debug hook"); - } -}; - console._errorHook = { onError: function errorhook (message, fileName, line, pos, flags, exception) { try { + var flagstr; + flagstr = + (flags && jsdIErrorHook.REPORT_EXCEPTION) ? "x" : "-"; + flagstr += + (flags && jsdIErrorHook.REPORT_STRICT) ? "s" : "-"; - dd ("===\n" + message + "\n" + fileName + "@" + line + ":" + - pos + "; " + flags); + //dd ("===\n" + message + "\n" + fileName + "@" + + // line + ":" + pos + "; " + flagstr); + var msn = (flags & jsdIErrorHook.REPORT_WARNING) ? + MSN_ERPT_WARN : MSN_ERPT_ERROR; + + if (console.errorMode != EMODE_IGNORE) + display (getMsg(msn, [message, flagstr, fileName, + line, pos]), MT_ETRACE); + + if (console.errorMode == EMODE_BREAK) + return false; + return true; } catch (ex) @@ -141,8 +151,8 @@ function initDebugger() console.jsds.on(); console.jsds.breakpointHook = console._executionHook; console.jsds.debuggerHook = console._executionHook; - //console.jsds.debugHook = console._debugHook; - //console.jsds.errorHook = console._errorHook; + console.jsds.debugHook = console._executionHook; + console.jsds.errorHook = console._errorHook; console.jsds.scriptHook = console._scriptHook; var venkmanFilter1 = { /* glob based filter goes first, because it's the */ @@ -163,7 +173,8 @@ function initDebugger() console.jsds.appendFilter (venkmanFilter1); console.jsds.appendFilter (venkmanFilter2); - setThrowMode(TMODE_IGNORE); + console.throwMode = TMODE_IGNORE; + console.errorMode = EMODE_IGNORE; var enumer = { enumerateScript: function _es (script) { @@ -291,57 +302,13 @@ function unrealizeScript(script) } } +const EMODE_IGNORE = 0; +const EMODE_TRACE = 1; +const EMODE_BREAK = 2; + const TMODE_IGNORE = 0; -const TMODE_TRACE = 1; -const TMODE_BREAK = 2; - -function getThrowMode (tmode) -{ - return console.throwMode; -} - -function cycleThrowMode () -{ - switch (console.throwMode) - { - case TMODE_IGNORE: - setThrowMode(TMODE_TRACE); - break; - - case TMODE_TRACE: - setThrowMode(TMODE_BREAK); - break; - - case TMODE_BREAK: - setThrowMode(TMODE_IGNORE); - break; - } -} - -function setThrowMode (tmode) -{ - switch (tmode) { - case TMODE_IGNORE: - console.jsds.throwHook = null; - display (MSG_TMODE_IGNORE); - break; - - case TMODE_TRACE: - console.jsds.throwHook = console._executionHook; - display (MSG_TMODE_TRACE); - break; - - case TMODE_BREAK: - console.jsds.throwHook = console._executionHook; - display (MSG_TMODE_BREAK); - break; - - default: - throw new BadMojo (ERR_INVALID_PARAM, "tmode"); - } - - console.throwMode = tmode; -} +const TMODE_TRACE = 1; +const TMODE_BREAK = 2; function debugTrap (frame, type, rv) { diff --git a/extensions/venkman/resources/content/venkman-menus.js b/extensions/venkman/resources/content/venkman-menus.js index e087175ef39b..ee04ae21417f 100644 --- a/extensions/venkman/resources/content/venkman-menus.js +++ b/extensions/venkman/resources/content/venkman-menus.js @@ -80,16 +80,45 @@ function initMenus() m("step"); m("finish"); m("-"); - m("tm-ignore", {type: "radio", + m("em-ignore", {type: "radio", name: "em", + checkedif: "console.errorMode == EMODE_IGNORE"}); + m("em-trace", {type: "radio", name: "em", + checkedif: "console.errorMode == EMODE_TRACE"}); + m("em-break", {type: "radio", name: "em", + checkedif: "console.errorMode == EMODE_BREAK"}); + m("-"); + m("tm-ignore", {type: "radio", name: "tm", checkedif: "console.throwMode == TMODE_IGNORE"}); - m("tm-trace", {type: "radio", + m("tm-trace", {type: "radio", name: "tm", checkedif: "console.throwMode == TMODE_TRACE"}); - m("tm-break", {type: "radio", + m("tm-break", {type: "radio", name: "tm", checkedif: "console.throwMode == TMODE_BREAK"}); m("-"); m("toggle-ias", {type: "checkbox", checkedif: "console.jsds.initAtStartup"}); + /* Context menu for console view */ + C("output-iframe", "console"); + m("stop"); + m("cont"); + m("next"); + m("step"); + m("finish"); + m("-"); + m("em-ignore", {type: "radio", name: "em", + checkedif: "console.errorMode == EMODE_IGNORE"}); + m("em-trace", {type: "radio", name: "em", + checkedif: "console.errorMode == EMODE_TRACE"}); + m("em-break", {type: "radio", name: "em", + checkedif: "console.errorMode == EMODE_BREAK"}); + m("-"); + m("tm-ignore", {type: "radio", name: "tm", + checkedif: "console.throwMode == TMODE_IGNORE"}); + m("tm-trace", {type: "radio", name: "tm", + checkedif: "console.throwMode == TMODE_TRACE"}); + m("tm-break", {type: "radio", name: "tm", + checkedif: "console.throwMode == TMODE_BREAK"}); + /* Context menu for project view */ C("project-outliner", "project"); m("clear-all", {enabledif: diff --git a/extensions/venkman/resources/content/venkman-msg.js b/extensions/venkman/resources/content/venkman-msg.js index 28a483dccdbf..0607b316fe16 100644 --- a/extensions/venkman/resources/content/venkman-msg.js +++ b/extensions/venkman/resources/content/venkman-msg.js @@ -158,6 +158,10 @@ const MSG_TIP_HELP = getMsg("msg.tip.help"); const MSG_NO_BREAKPOINTS_SET = getMsg("msg.no.breakpoints.set"); const MSG_NO_FBREAKS_SET = getMsg("msg.no.fbreaks.set"); +const MSG_EMODE_IGNORE = getMsg("msg.emode.ignore"); +const MSG_EMODE_TRACE = getMsg("msg.emode.trace"); +const MSG_EMODE_BREAK = getMsg("msg.emode.break"); + const MSG_TMODE_IGNORE = getMsg("msg.tmode.ignore"); const MSG_TMODE_TRACE = getMsg("msg.tmode.trace"); const MSG_TMODE_BREAK = getMsg("msg.tmode.break"); @@ -225,6 +229,8 @@ const MSN_FBP_DISABLED = "msg.fbp.disabled"; const MSN_FBP_EXISTS = "msg.fbp.exists"; const MSN_SOURCE_LINE = "msg.source.line"; const MSN_EXCP_TRACE = "msg.exception.trace"; +const MSN_ERPT_ERROR = "msg.erpt.error"; +const MSN_ERPT_WARN = "msg.erpt.warn"; const MSN_VERSION = "msg.version"; const MSN_DEFAULT_ALIAS_HELP = "msg.default.alias.help"; diff --git a/extensions/venkman/resources/content/venkman-static.js b/extensions/venkman/resources/content/venkman-static.js index 7ec2d2ec501e..41adfca31384 100644 --- a/extensions/venkman/resources/content/venkman-static.js +++ b/extensions/venkman/resources/content/venkman-static.js @@ -319,36 +319,17 @@ function evalInTargetScope (script) display (MSG_ERR_NO_STACK, MT_ERROR); return null; } - - try - { - return getCurrentFrame().eval (script, MSG_VAL_CONSOLE, 1); - } - catch (ex) - { - display (formatEvalException (ex), MT_ERROR); - return null; - } - - return null; - - /* - if (!console.frames) - { - display (MSG_ERR_NO_STACK, MT_ERROR); - return null; - } var rval = new Object(); if (!getCurrentFrame().eval (script, MSG_VAL_CONSOLE, 1, rval)) { - dd ("exception: " + dumpObjectTree(rval.value)); + //dd ("exception: " + dumpObjectTree(rval.value)); display (formatEvalException (rval.value), MT_ERROR); return null; } + return ("value" in rval) ? rval.value : null; - */ } function formatException (ex) diff --git a/extensions/venkman/resources/locale/en-US/venkman.properties b/extensions/venkman/resources/locale/en-US/venkman.properties index 87f6bf58c874..ade1c07d9552 100644 --- a/extensions/venkman/resources/locale/en-US/venkman.properties +++ b/extensions/venkman/resources/locale/en-US/venkman.properties @@ -137,12 +137,18 @@ msg.fbp.created = Future breakpoint at <%1$S> line %2$S created. msg.fbp.disabled = Future breakpoint at <%1$S> line %2$S deleted. msg.fbp.exists = Future breakpoint at <%1$S> line %2$S already set. msg.source.line = %1$S: %2$S +msg.emode.ignore = Errors will now be ignored. +msg.emode.trace = Errors will now be traced. +msg.emode.break = Errors will now stop the debug target. msg.tmode.ignore = Exceptions will now be ignored. msg.tmode.trace = Exceptions will now be traced. msg.tmode.break = Exceptions will now stop the debug target. msg.iasmode = Initialize at Startup is now %1$S. # 1 value, 2 frame msg.exception.trace = Exception %1$S thrown from %2$S. +# 1 message, 2 flags, 3 file, 4 line, 5 pos +msg.erpt.error = Error ``%1$S'' [%2$S] in file ``%3$S'', line %4$S, character %5$S. +msg.erpt.warn = Warning ``%1$S'' [%2$S] in file ``%3$S'', line %4$S, character %5$S. ## property value flags ## vf.enumerable = e @@ -193,6 +199,7 @@ popup.project = Project View Context Menu popup.source = Source View Context Menu popup.script = Script View Context Menu popup.stack = Stack View Context Menu +popup.console = Console View Context Menu msg.default.alias.help = This command is an alias for ``%1$S''. msg.help.title = -- Help -- @@ -244,12 +251,21 @@ cmd.cont.label = &Continue cmd.cont.key = VK_F5 cmd.cont.help = Continue execution of the debug target. +cmd.emode.params = [] +cmd.emode.help = Sets what action the debugger should take when an error occurs in the debug target. ``emode ignore'' ignores all errors, ``emode trace'' shows a log of the error in the console, and ``emode break'' stops excecution when an error is thrown. ``emode'' without any parameter will display the current error mode. Note that ``emode'' controls what happens whan an exception goes uncaught, to control what happens when an exception is *thrown*, use ``tmode''. + cmd.eval.params = cmd.eval.help = Evaluates in the scope of the debug target's current frame. See also: frame, where, props, and evald. cmd.evald.params = cmd.evald.help = Evaluates in the debugger's scope. See also: eval. +cmd.em-break.label = Stop for E&rrors +cmd.em-cycle.label = Cycle Error Mode +cmd.em-cycle.key = accel shift E +cmd.em-ignore.label = Ig&nore Errors +cmd.em-trace.label = Tr&ace Errors + cmd.fbreak.params = [ ] cmd.fbreak.help = Sets a ``future'' breakpoint. Any time a script whose file name matches is loaded, a breakpoint a is set. Setting a breakpoint at line 1 will cause the debugger to break when the script is loaded. fbreak with no parameters will list all future breakponts. See also: break @@ -323,7 +339,7 @@ cmd.reloadui.key = accel alt R cmd.scope.help = Lists the properties of the topmost object in the scope chain for the current frame. -cmd.startup-init.label = &Initialize at Startup +cmd.startup-init.label = Initialize at &Startup cmd.startup-init.params = [] cmd.startup-init.help = Sets the state of the "Initialize at Startup" feature. With this feature enabled, the debugger will begin tracking scripts when the browser is first started, instead of waiting until the user interface is launched. This will allow the script list to display files that were loaded before you started the debugger user interface. This feature incurrs a *slight* performance hit, and so it is off by default. The value of can be "true", "on", "yes", or "1" to turn the flag on; "false", "off", "no", or "0" to turn it off; or "toggle" to invert the current state. If is not provided, the current state will be displayed. @@ -341,16 +357,15 @@ cmd.testargs.help = Function for testing argument parsing. Pass it what it wa cmd.testargs1.params = [<...>] cmd.testargs1.help = Function for testing argument parsing. Pass it what it wants, and it'll spit out the event object to stdout. -cmd.tmode.params = -cmd.tmode.help = Sets what action the debugger should take when an exception is thrown from the debug target. ``tmode ignore'' ignores all exceptions, ``tmode trace'' shows a log of the exception to the console, and ``tmode break'' stops excecution when an exception is thrown. ``tmode'' without any parameter will display the current throw mode. The key combination Control + T can be used to cycle the throw mode. +cmd.tmode.params = [] +cmd.tmode.help = Sets what action the debugger should take when an exception is thrown from the debug target. ``tmode ignore'' ignores all exceptions, ``tmode trace'' shows a log of the exception to the console, and ``tmode break'' stops excecution when an exception is thrown. ``tmode'' without any parameter will display the current throw mode. Note that ``tmode'' controls what happens whan an exception is *thrown*, to control what happens when an exception reaches the top level and becomes an error, use ``emode''. The key combination Control + T can be used to cycle the throw mode. -cmd.tm-cycle.key = accel T +cmd.tm-break.label = Stop for &Exceptions +cmd.tm-cycle.label = Cycle Exception Mode +cmd.tm-cycle.key = accel T +cmd.tm-ignore.label = I&gnore Exceptions +cmd.tm-trace.label = T&race Exceptions -cmd.tm-ignore.label = I&gnore Exceptions - -cmd.tm-trace.label = T&race Exceptions - -cmd.tm-break.label = Stop for &Exceptions cmd.version.help = Display version information. cmd.where.help = Displays a summarized list of stack frames in the current call chain.