1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/test/CrashTestUtils.jsm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +this.EXPORTED_SYMBOLS = ["CrashTestUtils"]; 1.8 + 1.9 +this.CrashTestUtils = { 1.10 + // These will be defined using ctypes APIs below. 1.11 + crash: null, 1.12 + lockDir: null, 1.13 + dumpHasStream: null, 1.14 + dumpHasInstructionPointerMemory: null, 1.15 + 1.16 + // Constants for crash() 1.17 + // Keep these in sync with nsTestCrasher.cpp! 1.18 + CRASH_INVALID_POINTER_DEREF: 0, 1.19 + CRASH_PURE_VIRTUAL_CALL: 1, 1.20 + CRASH_RUNTIMEABORT: 2, 1.21 + CRASH_OOM: 3, 1.22 + CRASH_MOZ_CRASH: 4, 1.23 + CRASH_ABORT: 5, 1.24 + 1.25 + // Constants for dumpHasStream() 1.26 + // From google_breakpad/common/minidump_format.h 1.27 + MD_THREAD_LIST_STREAM: 3, 1.28 + MD_MEMORY_INFO_LIST_STREAM: 16 1.29 +}; 1.30 + 1.31 +// Grab APIs from the testcrasher shared library 1.32 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.33 +Components.utils.import("resource://gre/modules/ctypes.jsm"); 1.34 +let dir = Services.dirsvc.get("CurWorkD", Components.interfaces.nsILocalFile); 1.35 +let file = dir.clone(); 1.36 +file.append(ctypes.libraryName("testcrasher")); 1.37 +let lib = ctypes.open(file.path); 1.38 +CrashTestUtils.crash = lib.declare("Crash", 1.39 + ctypes.default_abi, 1.40 + ctypes.void_t, 1.41 + ctypes.int16_t); 1.42 +CrashTestUtils.saveAppMemory = lib.declare("SaveAppMemory", 1.43 + ctypes.default_abi, 1.44 + ctypes.uint64_t); 1.45 + 1.46 +CrashTestUtils.lockDir = lib.declare("LockDir", 1.47 + ctypes.default_abi, 1.48 + ctypes.voidptr_t, // nsILocalFile* 1.49 + ctypes.voidptr_t); // nsISupports* 1.50 + 1.51 + 1.52 +try { 1.53 + CrashTestUtils.TryOverrideExceptionHandler = lib.declare("TryOverrideExceptionHandler", 1.54 + ctypes.default_abi, 1.55 + ctypes.void_t); 1.56 +} 1.57 +catch(ex) {} 1.58 + 1.59 +CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream", 1.60 + ctypes.default_abi, 1.61 + ctypes.bool, 1.62 + ctypes.char.ptr, 1.63 + ctypes.uint32_t); 1.64 + 1.65 +CrashTestUtils.dumpHasInstructionPointerMemory = 1.66 + lib.declare("DumpHasInstructionPointerMemory", 1.67 + ctypes.default_abi, 1.68 + ctypes.bool, 1.69 + ctypes.char.ptr); 1.70 + 1.71 +CrashTestUtils.dumpCheckMemory = lib.declare("DumpCheckMemory", 1.72 + ctypes.default_abi, 1.73 + ctypes.bool, 1.74 + ctypes.char.ptr);