welcome: please sign in
location: Debugging

1. Debugging with GDB

To debug things like segfaults, which arise from XULRunner, you can run Conkeror in GDB. To do this effectively, you should install a version of XULRunner that has debugging symbols built in. For example, on Debian, use the package 'xulrunner-8.0-dbg' (substituting 8.0 for whatever version). Launch gdb/Conkeror with a shell script like the following.

 #!/bin/sh
LD_LIBRARY_PATH=/path/to/xulrunner-dir \
    exec gdb --args /path/to/xulrunner-dir/xulrunner-bin \
            /path/to/conkeror/application.ini "$@"

At the gdb prompt, enter 'run':

(gdb) run

When the segfault occurs, get a backtrace with the bt command. Refer to gdb documentation for further information on how to use gdb.

2. Debugging with Firefox Remote Debugging

The remote debugger in Firefox can be used to set breakpoints and step through code either on a web page or in Conkeror itself. It can also be used to inspect page elements and view network traffic. It can serve as a replacement for Firebug and Firebug Lite. I did have trouble with the inspector in a version less than Firefox 29, so you might want to have the latest version of Firefox and Xulrunner.

The documentation for Firefox Remote Debugging is at https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging . Unfortunately there's not a page specifically for Xulrunner or Firefox instances, but the page for Thunderbird might be helpful.

First, enable remote debugging in Firefox: 'Open the Toolbox, click the "Settings" button in the toolbar, and check "Enable remote debugging" in the Settings tab.'

Next, enable remote debugging in Conkeror by adding this to your ConkerorRC file:

user_pref("devtools.debugger.remote-enabled", true);

var debugging_server_port = debugging_server_port || 6000;

function start_debugging_server () {
    Components.utils.import('resource://gre/modules/devtools/dbg-server.jsm');
                if (!DebuggerServer.initialized) {
                    DebuggerServer.init();
                    DebuggerServer.addBrowserActors();
                    DebuggerServer.allowChromeProcess = true;
                }
    if (version_compare(get_mozilla_version(), "37.0") >= 0) {
        let listener = DebuggerServer.createListener();
        listener.portOrPath = debugging_server_port;
        listener.open();
    }
    else {
        DebuggerServer.openListener(debugging_server_port);
    }
}

interactive("start-debugging-server",
            "Starts the debugging server that you can connect to with Firefox",
            start_debugging_server);

Next, restart Conkeror and start the debugging server with M-x start-debugging-server.

Finally, connect to Conkeror from Firefox. There are two ways to do this. One is to run "firefox -chrome chrome://browser/content/devtools/connect.xhtml". Another is to start Firefox, click Toolbox > Developer > Connect. You shouldn't need to change any of the settings, click "Connect". A popup should appear from the Conkeror window asking for permission, click "OK". Now a list of processes should appear in Firefox, click on "Main Process." Success, you're now remotely debugging Conkeror!

Conkeror.org: Debugging (last edited 2015-09-05 03:43:22 by scottjad)