Skip to content
Browse files

Display stack trace for monitor logs

  • Loading branch information...
1 parent 2c5d575 commit 8191dd88e16cc008c4b83bb34bbd2c093d494aef @janodvarko janodvarko committed Mar 28, 2013
View
247 extension/content/firebug/chrome/reps.js
@@ -31,8 +31,8 @@ define([
"arch/compilationunit",
],
function(Obj, Arr, Firebug, Domplate, Firefox, Xpcom, Locale, HTMLLib, Events, Wrapper, Options,
- Url, SourceLink, SourceFile, StackFrame, StackTrace, Css, Dom, Win, System, Xpath, Str, Xml,
- ToggleBranch, EventMonitor, ClosureInspector, Menu, CompilationUnit) {
+ Url, SourceLink, SourceFile, StackFrame, StackTrace, Css, Dom, Win, System,
+ Xpath, Str, Xml, ToggleBranch, EventMonitor, ClosureInspector, Menu, CompilationUnit) {
with (Domplate) {
@@ -2093,242 +2093,6 @@ FirebugReps.CompilationUnit = domplate(FirebugReps.SourceLink,
// ********************************************************************************************* //
-// XXXjjb Since the repObject is fn the stack does not have correct line numbers
-FirebugReps.StackFrame = domplate(Firebug.Rep,
-{
- tag:
- OBJECTBLOCK({$hasTwisty: "$object|hasArguments", _repObject: "$object",
- onclick: "$onToggleArguments"},
- SPAN({"class":"stackFrameMarker"}, ""),
- A({"class": "objectLink a11yFocus", _repObject: "$object"}, "$object|getCallName"),
- SPAN("("),
- SPAN({"class": "arguments"},
- FOR("arg", "$object|argIterator",
- SPAN({"class": "argName"}, "$arg.name"),
- SPAN("="),
- TAG("$arg.tag", {object: "$arg.value"}),
- SPAN({"class": "arrayComma"}, "$arg.delim")
- )
- ),
- SPAN(")"),
- SPAN({"class": "objectLink-sourceLink objectLink a11yFocus",
- _repObject: "$object|getSourceLink",
- role: "link"},
- "$object|getSourceLinkTitle"),
- DIV({"class": "argList"})
- ),
-
- argList:
- DIV({"class": "argListBox", onclick: "$onSelectFrame"},
- FOR("arg", "$object|argIterator",
- DIV({"class": "argBox"},
- SPAN({"class": "argName"}, "$arg.name"),
- SPAN(" = "),
- TAG("$arg.tag", {object: "$arg.value"})
- )
- )
- ),
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
- getTitle: function(frame)
- {
- return frame.getFunctionName();
- },
-
- hasArguments: function(frame)
- {
- return frame.args.length;
- },
-
- getCallName: function(frame)
- {
- return frame.getFunctionName();
- },
-
- getSourceLinkTitle: function(frame)
- {
- var fileName = Url.getFileName(frame.href);
-
- var maxWidth = Firebug.sourceLinkLabelWidth;
- if (maxWidth > 0)
- var fileName = Str.cropString(fileName, maxWidth);
-
- return Locale.$STRF("Line", [fileName, frame.line]);
- },
-
- argIterator: function(frame)
- {
- if (!frame.args)
- return [];
-
- var items = [];
-
- for (var i = 0; i < frame.args.length; ++i)
- {
- var arg = frame.args[i];
-
- if (!arg)
- break;
-
- if (arg.hasOwnProperty('value')) // then we got these from jsd
- {
- var rep = Firebug.getRep(arg.value);
- var tag = rep.shortTag ? rep.shortTag : rep.tag;
-
- var delim = (i == frame.args.length-1 ? "" : ", ");
-
- items.push({name: arg.name, value: arg.value, tag: tag, delim: delim});
- }
- else if (arg.hasOwnProperty('name'))
- {
- items.push({name: arg.name, delim: delim});
- }
- else // eg from Error object
- {
- var delim = (i == frame.args.length-1 ? "" : ", ");
- var rep = Firebug.getRep(arg);
- var tag = rep.shortTag ? rep.shortTag : rep.tag;
-
- items.push({value: arg, tag: tag, delim: delim});
- }
-
- if (FBTrace.DBG_DOMPLATE)
- FBTrace.sysout("reps.stackframe args[" + i + "]: " + arg.name + " = " +
- arg.value, {arg: arg, item: items[items.length - 1]});
- }
-
- return items;
- },
-
- getSourceLink: function(stackFrame)
- {
- var sourceLink = new SourceLink(stackFrame.href, stackFrame.line, "js");
- return sourceLink;
- },
-
- onToggleArguments: function(event)
- {
- this.toggleArguments(event.originalTarget);
- },
-
- toggleArguments: function(target)
- {
- if (Css.hasClass(target, "objectBox-stackFrame"))
- {
- if (Css.hasClass(target, "opened"))
- this.collapseArguments(target);
- else
- this.expandArguments(target);
- }
- },
-
- collapseArguments: function(target)
- {
- if (!Css.hasClass(target, "opened"))
- return;
-
- Css.toggleClass(target, "opened");
-
- var argList = target.getElementsByClassName("argList").item(0);
- Dom.clearNode(argList);
- },
-
- expandArguments: function(target)
- {
- if (Css.hasClass(target, "opened"))
- return;
-
- var frame = target.repObject;
- if (!this.hasArguments(frame))
- return;
-
- Css.toggleClass(target, "opened");
-
- var argList = target.getElementsByClassName("argList").item(0);
- this.argList.replace({object: frame}, argList);
- },
-
- onSelectFrame: function(event)
- {
- var target = event.currentTarget;
- if (Css.hasClass(target, "argListBox"))
- {
- var stackFrame = Dom.getAncestorByClass(target, "objectBox-stackFrame");
- var panel = Firebug.getElementPanel(target);
- this.inspectObject(stackFrame.repObject, panel.context);
- Events.cancelEvent(event);
- }
- },
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- // Rep
-
- className: "stackFrame",
-
- supportsObject: function(object, type)
- {
- return object instanceof StackFrame;
- },
-
- inspectObject: function(stackFrame, context)
- {
- if (context.stopped)
- Firebug.chrome.select(stackFrame);
- else
- Firebug.chrome.select(this.getSourceLink(stackFrame));
- },
-
- getTooltip: function(stackFrame, context)
- {
- return Locale.$STRF("Line", [stackFrame.href, stackFrame.line]);
- }
-});
-
-// ********************************************************************************************* //
-
-FirebugReps.StackTrace = domplate(Firebug.Rep,
-{
- tag:
- DIV({role : "group", "aria-label" : Locale.$STR("aria.labels.stack trace")},
- FOR("frame", "$object.frames|frameIterator",
- TAG(FirebugReps.StackFrame.tag, {object: "$frame"})
- )
- ),
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
- className: "stackTrace",
-
- supportsObject: function(object, type)
- {
- return object instanceof StackTrace;
- },
-
- frameIterator: function(frames)
- {
- // Skip Firebug internal frames.
- // xxxHonza: this is another place where we peel off stack frames.
- var result = [];
- for (var i=0; frames && i<frames.length; i++)
- {
- var frame = frames[i];
- var sf = frame.sourceFile;
- if ((sf && sf.href && Str.hasPrefix(sf.href, "chrome")) ||
- (frame.fn == "_firebugRerun") ||
- (frame.fn == "jsdbug_NoScriptFunctionName"))
- {
- continue;
- }
-
- result.push(frames[i]);
- }
- return result;
- }
-});
-
-// ********************************************************************************************* //
-
FirebugReps.ErrorMessage = domplate(Firebug.Rep,
{
sourceLimit: 80,
@@ -2560,7 +2324,10 @@ FirebugReps.ErrorMessage = domplate(Firebug.Rep,
if (Css.hasClass(target, "opened"))
{
if (target.stackTrace)
- FirebugReps.StackTrace.tag.append({object: target.stackTrace}, traceBox);
+ {
+ var rep = Firebug.getRep(target.stackTrace);
+ rep.tag.append({object: target.stackTrace}, traceBox);
+ }
if (Firebug.A11yModel.enabled)
{
@@ -3370,8 +3137,6 @@ Firebug.registerRep(
FirebugReps.Event,
FirebugReps.SourceLink,
FirebugReps.CompilationUnit,
- FirebugReps.StackTrace,
- FirebugReps.StackFrame,
FirebugReps.NetFile,
FirebugReps.Property,
FirebugReps.Except,
View
11 extension/content/firebug/console/consolePanel.js
@@ -84,6 +84,10 @@ Firebug.ConsolePanel.prototype = Obj.extend(Firebug.ActivablePanel,
if (this.context.consoleReloadWarning) // we have not yet injected the console
this.insertReloadWarning();
}
+
+ // Update visibility of stack frame arguments.
+ var name = "showStackFrameArguments";
+ this.updateOption(name, Options.get(name));
},
destroy: function(state)
@@ -211,6 +215,13 @@ Firebug.ConsolePanel.prototype = Obj.extend(Firebug.ActivablePanel,
Firebug.Console.onToggleFilter(context, value);
});
}
+ else if (name == "showStackFrameArguments")
+ {
+ if (value)
+ Css.removeClass(this.panelNode, "hideArguments");
+ else
+ Css.setClass(this.panelNode, "hideArguments");
+ }
},
shouldBreakOnNext: function()
View
24 extension/content/firebug/console/functionMonitor.js
@@ -6,6 +6,7 @@ define([
"firebug/lib/domplate",
"firebug/chrome/reps",
"firebug/debugger/stack/stackFrame",
+ "firebug/debugger/stack/stackFrameRep",
"firebug/debugger/script/sourceFile",
"firebug/lib/events",
"firebug/lib/css",
@@ -14,9 +15,10 @@ define([
"firebug/lib/locale",
"firebug/debugger/debuggerLib",
"firebug/debugger/breakpoints/breakpointStore",
+ "firebug/debugger/stack/stackTrace",
],
-function(FBTrace, Obj, Domplate, Reps, StackFrame, SourceFile, Events, Css, Dom,
- Url, Locale, DebuggerLib, BreakpointStore) {
+function(FBTrace, Obj, Domplate, Reps, StackFrame, StackFrameRep, SourceFile, Events, Css, Dom,
+ Url, Locale, DebuggerLib, BreakpointStore, StackTrace) {
with (Domplate) {
@@ -98,10 +100,11 @@ var FunctionMonitor = Obj.extend(Firebug.Module,
onMonitorScript: function(context, frame)
{
- Trace.sysout("functionMonitor.onMonitorScript;", frame);
+ var frames = DebuggerLib.getCurrentFrames(context);
+ var stackTrace = StackTrace.buildStackTrace(context, frames);
+
+ Trace.sysout("functionMonitor.onMonitorScript; stackTrace:", stackTrace);
- // xxxHonza: how to get the current stack trace?
- var stackTrace = null;//StackFrame.buildStackTrace(frame);
Firebug.Console.log(new FunctionLog(frame, stackTrace), context);
},
@@ -230,6 +233,7 @@ var FunctionMonitorRep = domplate(Firebug.Rep,
{
className: "functionCall",
+ // xxxHonza: StackFrameRep duplication
tag:
Reps.OBJECTBLOCK({$hasTwisty: "$object|hasStackTrace", _repObject: "$object",
onclick: "$onToggleStackTrace"},
@@ -272,17 +276,17 @@ var FunctionMonitorRep = domplate(Firebug.Rep,
getSourceLink: function(object)
{
- return Reps.StackFrame.getSourceLink(object.frame);
+ return StackFrameRep.getSourceLink(object.frame);
},
getSourceLinkTitle: function(object)
{
- return Reps.StackFrame.getSourceLinkTitle(object.frame);
+ return StackFrameRep.getSourceLinkTitle(object.frame);
},
argIterator: function(object)
{
- return Reps.StackFrame.argIterator(object.frame);
+ return StackFrameRep.argIterator(object.frame);
},
onToggleStackTrace: function(event)
@@ -307,7 +311,9 @@ var FunctionMonitorRep = domplate(Firebug.Rep,
if (Css.hasClass(traceBox, "opened"))
{
var functionCall = objectBox.repObject;
- Reps.StackTrace.tag.append({object: functionCall.stackTrace}, traceBox);
+ var stackTrace = functionCall.stackTrace;
+ var rep = Firebug.getRep(stackTrace);
+ rep.tag.append({object: stackTrace}, traceBox);
}
else
{
View
11 extension/content/firebug/debugger/debuggerLib.js
@@ -136,6 +136,17 @@ DebuggerLib.getThreadActor = function(context)
}
// ********************************************************************************************* //
+// Stack Frames
+
+DebuggerLib.getCurrentFrames = function(context)
+{
+ var threadActor = this.getThreadActor(context);
+ var request = {};
+ var response = threadActor.onFrames(request);
+ return response.frames;
+}
+
+// ********************************************************************************************* //
// Executable Lines
DebuggerLib.getNextExecutableLine = function(context, aLocation)
View
6 extension/content/firebug/debugger/debuggerTool.js
@@ -404,12 +404,12 @@ var DebuggerTool = Obj.extend(Firebug.Module,
framesadded: function(context)
{
- Trace.sysout("debuggerTool.framesadded; ", arguments);
-
// Get frames from ThreadClient's stack-frame cache and build stack trace object,
// which is stored in the context.
var frames = context.activeThread.cachedFrames;
- context.currentTrace = StackTrace.buildStackTrace(frames, context);
+ Trace.sysout("debuggerTool.framesadded; frames: ", frames);
+
+ context.currentTrace = StackTrace.buildStackTrace(context, frames);
// Now notify all listeners, for example the {@CallstackPanel} panel to sync the UI.
this.dispatch("framesadded", [context.currentTrace]);
View
14 extension/content/firebug/debugger/stack/stackFrameRep.js
@@ -13,9 +13,11 @@ define([
"firebug/chrome/reps",
"firebug/debugger/script/sourceLink",
"firebug/lib/css",
+ "firebug/lib/options",
+ "firebug/lib/dom",
],
function(FBTrace, Obj, Arr, Url, Str, Locale, Firebug, Domplate, StackFrame, FirebugReps,
- SourceLink, Css) {
+ SourceLink, Css, Options, Dom) {
with (Domplate) {
@@ -30,6 +32,8 @@ const Ci = Components.interfaces;
var StackFrameRep = domplate(Firebug.Rep,
{
+ className: "stackFrame",
+
tag:
FirebugReps.OBJECTBLOCK({$hasTwisty: "$object|hasArguments", _repObject: "$object",
onclick: "$onToggleArguments"},
@@ -126,10 +130,6 @@ var StackFrameRep = domplate(Firebug.Rep,
items.push({value: arg, tag: tag, delim: delim});
}
-
- if (FBTrace.DBG_DOMPLATE)
- FBTrace.sysout("reps.stackframe args[" + i + "]: " + arg.name + " = " +
- arg.value, {arg: arg, item: items[items.length - 1]});
}
return items;
@@ -170,8 +170,6 @@ var StackFrameRep = domplate(Firebug.Rep,
expandArguments: function(target)
{
- FBTrace.sysout("expandArguments");
-
if (Css.hasClass(target, "opened"))
return;
@@ -201,8 +199,6 @@ var StackFrameRep = domplate(Firebug.Rep,
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Rep
- className: "stackFrame",
-
supportsObject: function(object, type)
{
return object instanceof StackFrame;
View
2 extension/content/firebug/debugger/stack/stackTrace.js
@@ -50,7 +50,7 @@ StackTrace.prototype =
// ********************************************************************************************* //
// Static Methods
-StackTrace.buildStackTrace = function(frames, context)
+StackTrace.buildStackTrace = function(context, frames)
{
var trace = new StackTrace();
for (var i=0; frames && i<frames.length; i++)
View
3 extension/skin/classic/callstack.css
@@ -68,6 +68,9 @@
* (see extensions.firebug.showStackFrameArguments).
*/
.objectBox-stackFrame.opened .arguments,
+.objectBox-stackFrame .arguments.hide,
+.panelNode-console.hideArguments .objectBox-stackFrame .arguments,
+.panelNode-console.hideArguments .objectBox-functionCall .arguments,
.panelNode-callstack.hideArguments .objectBox-stackFrame .arguments {
display: none;
}

0 comments on commit 8191dd8

Please sign in to comment.
Something went wrong with that request. Please try again.