toolkit/crashreporter/test/CrashTestUtils.jsm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 this.EXPORTED_SYMBOLS = ["CrashTestUtils"];
     6 this.CrashTestUtils = {
     7   // These will be defined using ctypes APIs below.
     8   crash: null,
     9   lockDir: null,
    10   dumpHasStream: null,
    11   dumpHasInstructionPointerMemory: null,
    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,
    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 };
    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);
    43 CrashTestUtils.lockDir = lib.declare("LockDir",
    44                                      ctypes.default_abi,
    45                                      ctypes.voidptr_t,   // nsILocalFile*
    46                                      ctypes.voidptr_t);  // nsISupports*
    49 try {
    50   CrashTestUtils.TryOverrideExceptionHandler = lib.declare("TryOverrideExceptionHandler",
    51                                                            ctypes.default_abi,
    52                                                            ctypes.void_t);
    53 }
    54 catch(ex) {}
    56 CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream",
    57                                            ctypes.default_abi,
    58                                            ctypes.bool,
    59                                            ctypes.char.ptr,
    60                                            ctypes.uint32_t);
    62 CrashTestUtils.dumpHasInstructionPointerMemory =
    63   lib.declare("DumpHasInstructionPointerMemory",
    64               ctypes.default_abi,
    65               ctypes.bool,
    66               ctypes.char.ptr);
    68 CrashTestUtils.dumpCheckMemory = lib.declare("DumpCheckMemory",
    69                                              ctypes.default_abi,
    70                                              ctypes.bool,
    71                                              ctypes.char.ptr);

mercurial