gecko/toolkit/crashreporter/test/CrashTestUtils.jsm
Benjamin Smedberg 3c82e7f486 Bug 716638 - Annotate the size of a failed allocation due to OOM and submit it with the crash report, r=ted
--HG--
extra : rebase_source : 5b7d10cb2e117deabb89b75ec3f3b1a221b3c80b
2012-01-24 11:08:51 -05:00

59 lines
2.2 KiB
JavaScript

var EXPORTED_SYMBOLS = ["CrashTestUtils"];
let CrashTestUtils = {
// These will be defined using ctypes APIs below.
crash: null,
lockDir: null,
dumpHasStream: null,
dumpHasInstructionPointerMemory: null,
// Constants for crash()
// Keep these in sync with nsTestCrasher.cpp!
CRASH_INVALID_POINTER_DEREF: 0,
CRASH_PURE_VIRTUAL_CALL: 1,
CRASH_RUNTIMEABORT: 2,
CRASH_OOM: 3,
// Constants for dumpHasStream()
// From google_breakpad/common/minidump_format.h
MD_THREAD_LIST_STREAM: 3,
MD_MEMORY_INFO_LIST_STREAM: 16
};
// Grab APIs from the testcrasher shared library
Components.utils.import("resource://gre/modules/ctypes.jsm");
let dir = __LOCATION__.parent;
let file = dir.clone();
file.append(ctypes.libraryName("testcrasher"));
let lib = ctypes.open(file.path);
CrashTestUtils.crash = lib.declare("Crash",
ctypes.default_abi,
ctypes.void_t,
ctypes.int16_t);
CrashTestUtils.saveAppMemory = lib.declare("SaveAppMemory",
ctypes.default_abi,
ctypes.uint64_t);
CrashTestUtils.lockDir = lib.declare("LockDir",
ctypes.default_abi,
ctypes.voidptr_t, // nsILocalFile*
ctypes.voidptr_t); // nsISupports*
CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream",
ctypes.default_abi,
ctypes.bool,
ctypes.char.ptr,
ctypes.uint32_t);
CrashTestUtils.dumpHasInstructionPointerMemory =
lib.declare("DumpHasInstructionPointerMemory",
ctypes.default_abi,
ctypes.bool,
ctypes.char.ptr);
CrashTestUtils.dumpCheckMemory = lib.declare("DumpCheckMemory",
ctypes.default_abi,
ctypes.bool,
ctypes.char.ptr);