1

I am debugging a FF extension for a client (3500 lines). I have a separated development profile with just firebug && extension developer extensions to work.

1.- I had developed a couple of extensions for FF some time in the previous 2 years. I remember that I used Firebug's console.debug/trace for debugging. Now, with Firebug 1.6.2 console is not defined. Any advise to fix this?
2.- Last night I installed console2 (an upgrade for the normal error console) that can help pretty well with a custom function like:

function debug(aMsg) {
setTimeout(function() { throw new Error("[debug] " + aMsg); }, 0);
}

But Firebug.console.debug is superior. Please advise about alternative techniques for debugging FF extensions.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Igor Parra
  • 10,214
  • 10
  • 69
  • 101

1 Answers1

4

Recent Firebug releases include an excellent log/trace component to use when debugging an extension, use code like the following.

// When initialising extension
var myLogger = {}
try {
    Components.utils["import"]("resource://firebug/firebug-trace-service.js");
    myLogger = traceConsoleService.getTracer("extensions.myextension");
} catch (e) {
    // firebug not installed
}

// later on
if (myLogger.DBG_MINE) {
    myLogger.sysout("my message", obj); // intelligently handles obj exceptions too
}

To enable this logging, create a preference using about:config for extensions.myextension.DBG_MINE set to true. You can find more information, albeit slightly outdated at http://www.softwareishard.com/blog/firebug/tracing-console-for-firebug/ .

For more advanced debugging, it's worth checking out Chromebug, which lets you inspect XUL interfaces and debug extension code and Venkmann, which is just a debugger, but which I've found to be much faster than waiting for Chromebug to start up.

Damien Ayers
  • 1,551
  • 10
  • 17
  • Thanks... I have this error: _Error: Permission denied for to get property XPCComponents.utils_ Besides I am studying Venckman too... – Igor Parra Apr 16 '11 at 00:32
  • It sounds like you're trying to run it as unprivileged code. Components.utils.import will only work if run privileged, as part of an extension. How are you loading/running your code? – Damien Ayers Apr 16 '11 at 08:17