michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: this.EXPORTED_SYMBOLS = ["CrashTestUtils"]; michael@0: michael@0: this.CrashTestUtils = { michael@0: // These will be defined using ctypes APIs below. michael@0: crash: null, michael@0: lockDir: null, michael@0: dumpHasStream: null, michael@0: dumpHasInstructionPointerMemory: null, michael@0: michael@0: // Constants for crash() michael@0: // Keep these in sync with nsTestCrasher.cpp! michael@0: CRASH_INVALID_POINTER_DEREF: 0, michael@0: CRASH_PURE_VIRTUAL_CALL: 1, michael@0: CRASH_RUNTIMEABORT: 2, michael@0: CRASH_OOM: 3, michael@0: CRASH_MOZ_CRASH: 4, michael@0: CRASH_ABORT: 5, michael@0: michael@0: // Constants for dumpHasStream() michael@0: // From google_breakpad/common/minidump_format.h michael@0: MD_THREAD_LIST_STREAM: 3, michael@0: MD_MEMORY_INFO_LIST_STREAM: 16 michael@0: }; michael@0: michael@0: // Grab APIs from the testcrasher shared library michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: Components.utils.import("resource://gre/modules/ctypes.jsm"); michael@0: let dir = Services.dirsvc.get("CurWorkD", Components.interfaces.nsILocalFile); michael@0: let file = dir.clone(); michael@0: file.append(ctypes.libraryName("testcrasher")); michael@0: let lib = ctypes.open(file.path); michael@0: CrashTestUtils.crash = lib.declare("Crash", michael@0: ctypes.default_abi, michael@0: ctypes.void_t, michael@0: ctypes.int16_t); michael@0: CrashTestUtils.saveAppMemory = lib.declare("SaveAppMemory", michael@0: ctypes.default_abi, michael@0: ctypes.uint64_t); michael@0: michael@0: CrashTestUtils.lockDir = lib.declare("LockDir", michael@0: ctypes.default_abi, michael@0: ctypes.voidptr_t, // nsILocalFile* michael@0: ctypes.voidptr_t); // nsISupports* michael@0: michael@0: michael@0: try { michael@0: CrashTestUtils.TryOverrideExceptionHandler = lib.declare("TryOverrideExceptionHandler", michael@0: ctypes.default_abi, michael@0: ctypes.void_t); michael@0: } michael@0: catch(ex) {} michael@0: michael@0: CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream", michael@0: ctypes.default_abi, michael@0: ctypes.bool, michael@0: ctypes.char.ptr, michael@0: ctypes.uint32_t); michael@0: michael@0: CrashTestUtils.dumpHasInstructionPointerMemory = michael@0: lib.declare("DumpHasInstructionPointerMemory", michael@0: ctypes.default_abi, michael@0: ctypes.bool, michael@0: ctypes.char.ptr); michael@0: michael@0: CrashTestUtils.dumpCheckMemory = lib.declare("DumpCheckMemory", michael@0: ctypes.default_abi, michael@0: ctypes.bool, michael@0: ctypes.char.ptr);