|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Tracing Function InvocationsHi guys,
I'm trying to use the jsdIDebuggerService interface in a Firefox extension to trace function invocations. Specifically, I'm using the debugger service's functionHook. This hook takes two arguments: the current frame and the invocation type. However, I'm having trouble accessing the name of the function being invoked, as well as the names and values of the arguments being passed to the function. The problem is that frame.functionName and frame.script.functionObject refer to the function within which the invocation is made, not the function being invoked. Has anyone used the functionHook to trace and/or log JavaScript function calls? If not, has anyone used a different method to do achieve this? I'm attaching a snippet of code below so as to give a better idea of what I'm doing (wrong). Take care, Daniel var functionHook = function(frame, type) { if(type != jsdICallHook.TYPE_FUNCTION_CALL) return; // Start with indentation. var s = ""; var parent = frame.callingFrame; while(parent) { if(!parent.isDebugger && !parent.isNative) s += " "; parent = parent.callingFrame; } // Continue with argument info. var args = ""; var p = new Object(); frame.script.functionObject.getProperties(p, {}); p = p.value; for(var i = p.length - 1; i >= 0; i--) { if(p[i].flags & jsdIProperty.FLAG_ARGUMENT) { args += p[i].name.stringValue + ": " + formatValue(p[i].value) + ", "; } } if(args.lastIndexOf(", ") == args.length - 2) { args = args.substring(0, args.length - 2); } // Continue with other information. var line = frame.line; var funcName = frame.functionName; // Log the gathered information. s += funcName + "(" + args + ") @ line " + line + " of " + file; ftLog.push(s); } debuggerService.on(); debuggerService.functionHook = { onCall: functionHook }; -- Daniel Gredler http://daniel.gredler.net/ _______________________________________________ dev-apps-js-debugger mailing list dev-apps-js-debugger@... https://lists.mozilla.org/listinfo/dev-apps-js-debugger |
|
|
|
|
|
Re: Tracing Function InvocationsHi John,
Based on the Firebug code, it looks like I need to hook the function invocations, and when a function is called, hook execution (interrupts). I can then get all the info I need in the interrupt, and unhook interrupts until the next function call. I had hoped that there was a better way, but it seems to work. Thanks for your help! Regards, Daniel On Mon, Feb 18, 2008 at 9:35 PM, John J. Barton <johnjbarton@...> wrote: > Daniel Gredler wrote: > > Hi guys, > > > > I'm trying to use the jsdIDebuggerService interface in a Firefox > extension > > to trace function invocations. Specifically, I'm using the debugger > > service's functionHook. This hook takes two arguments: the current frame > and > > the invocation type. > > > > However, I'm having trouble accessing the name of the function being > > invoked, as well as the names and values of the arguments being passed > to > > the function. The problem is that frame.functionName and > > frame.script.functionObject refer to the function within which the > > invocation is made, not the function being invoked. > > > > Has anyone used the functionHook to trace and/or log JavaScript function > > calls? If not, has anyone used a different method to do achieve this? > I'm > > attaching a snippet of code below so as to give a better idea of what > I'm > > doing (wrong). > > > You can look at firebug-service.js in > > http://code.google.com/p/fbug/source/browse/branches/firebug1.2/components/firebug-service.js > to see how step-in, step-out etc are implemented. > > John. > _______________________________________________ > dev-apps-js-debugger mailing list > dev-apps-js-debugger@... > https://lists.mozilla.org/listinfo/dev-apps-js-debugger > -- Daniel Gredler http://daniel.gredler.net/ _______________________________________________ dev-apps-js-debugger mailing list dev-apps-js-debugger@... https://lists.mozilla.org/listinfo/dev-apps-js-debugger |
| Free Forum Powered by Nabble | Forum Help |