26.08.10

For future reference when debugging inside JS modules (where no dump function is available)

Tags: , , , , , , , — Jeff @ 19:59
function dump(msg)
{
  var mod = {};
  Components.utils.import("resource://gre/modules/ctypes.jsm", mod);
  var ctypes = mod.ctypes;
  var libc = ctypes.open("libc.so.6");
  var puts =
    libc.declare("puts", ctypes.default_abi, ctypes.int, ctypes.char.ptr);
  puts("!!!!!!!!!!!!!!!!!!!\n" +
       "!!! " + msg + "\n" +
       "!!!!!!!!!!!!!!!!!!!");
  libc.close();
}