|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 this.EXPORTED_SYMBOLS = ["CrashTestUtils"]; |
|
5 |
|
6 this.CrashTestUtils = { |
|
7 // These will be defined using ctypes APIs below. |
|
8 crash: null, |
|
9 lockDir: null, |
|
10 dumpHasStream: null, |
|
11 dumpHasInstructionPointerMemory: null, |
|
12 |
|
13 // Constants for crash() |
|
14 // Keep these in sync with nsTestCrasher.cpp! |
|
15 CRASH_INVALID_POINTER_DEREF: 0, |
|
16 CRASH_PURE_VIRTUAL_CALL: 1, |
|
17 CRASH_RUNTIMEABORT: 2, |
|
18 CRASH_OOM: 3, |
|
19 CRASH_MOZ_CRASH: 4, |
|
20 CRASH_ABORT: 5, |
|
21 |
|
22 // Constants for dumpHasStream() |
|
23 // From google_breakpad/common/minidump_format.h |
|
24 MD_THREAD_LIST_STREAM: 3, |
|
25 MD_MEMORY_INFO_LIST_STREAM: 16 |
|
26 }; |
|
27 |
|
28 // Grab APIs from the testcrasher shared library |
|
29 Components.utils.import("resource://gre/modules/Services.jsm"); |
|
30 Components.utils.import("resource://gre/modules/ctypes.jsm"); |
|
31 let dir = Services.dirsvc.get("CurWorkD", Components.interfaces.nsILocalFile); |
|
32 let file = dir.clone(); |
|
33 file.append(ctypes.libraryName("testcrasher")); |
|
34 let lib = ctypes.open(file.path); |
|
35 CrashTestUtils.crash = lib.declare("Crash", |
|
36 ctypes.default_abi, |
|
37 ctypes.void_t, |
|
38 ctypes.int16_t); |
|
39 CrashTestUtils.saveAppMemory = lib.declare("SaveAppMemory", |
|
40 ctypes.default_abi, |
|
41 ctypes.uint64_t); |
|
42 |
|
43 CrashTestUtils.lockDir = lib.declare("LockDir", |
|
44 ctypes.default_abi, |
|
45 ctypes.voidptr_t, // nsILocalFile* |
|
46 ctypes.voidptr_t); // nsISupports* |
|
47 |
|
48 |
|
49 try { |
|
50 CrashTestUtils.TryOverrideExceptionHandler = lib.declare("TryOverrideExceptionHandler", |
|
51 ctypes.default_abi, |
|
52 ctypes.void_t); |
|
53 } |
|
54 catch(ex) {} |
|
55 |
|
56 CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream", |
|
57 ctypes.default_abi, |
|
58 ctypes.bool, |
|
59 ctypes.char.ptr, |
|
60 ctypes.uint32_t); |
|
61 |
|
62 CrashTestUtils.dumpHasInstructionPointerMemory = |
|
63 lib.declare("DumpHasInstructionPointerMemory", |
|
64 ctypes.default_abi, |
|
65 ctypes.bool, |
|
66 ctypes.char.ptr); |
|
67 |
|
68 CrashTestUtils.dumpCheckMemory = lib.declare("DumpCheckMemory", |
|
69 ctypes.default_abi, |
|
70 ctypes.bool, |
|
71 ctypes.char.ptr); |