summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/test/CrashTestUtils.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/crashreporter/test/CrashTestUtils.sys.mjs
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/crashreporter/test/CrashTestUtils.sys.mjs')
-rw-r--r--toolkit/crashreporter/test/CrashTestUtils.sys.mjs106
1 files changed, 106 insertions, 0 deletions
diff --git a/toolkit/crashreporter/test/CrashTestUtils.sys.mjs b/toolkit/crashreporter/test/CrashTestUtils.sys.mjs
new file mode 100644
index 0000000000..13cf1fec49
--- /dev/null
+++ b/toolkit/crashreporter/test/CrashTestUtils.sys.mjs
@@ -0,0 +1,106 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+export var CrashTestUtils = {
+ // These will be defined using ctypes APIs below.
+ crash: null,
+ dumpHasStream: null,
+ dumpHasInstructionPointerMemory: null,
+ dumpWin64CFITestSymbols: null,
+ enablePHC: 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,
+ CRASH_MOZ_CRASH: 4,
+ CRASH_ABORT: 5,
+ CRASH_UNCAUGHT_EXCEPTION: 6,
+ CRASH_X64CFI_NO_MANS_LAND: 7,
+ CRASH_X64CFI_LAUNCHER: 8,
+ CRASH_X64CFI_UNKNOWN_OPCODE: 9,
+ CRASH_X64CFI_PUSH_NONVOL: 10,
+ CRASH_X64CFI_ALLOC_SMALL: 11,
+ CRASH_X64CFI_ALLOC_LARGE: 12,
+ CRASH_X64CFI_SAVE_NONVOL: 15,
+ CRASH_X64CFI_SAVE_NONVOL_FAR: 16,
+ CRASH_X64CFI_SAVE_XMM128: 17,
+ CRASH_X64CFI_SAVE_XMM128_FAR: 18,
+ CRASH_X64CFI_EPILOG: 19,
+ CRASH_X64CFI_EOF: 20,
+ CRASH_PHC_USE_AFTER_FREE: 21,
+ CRASH_PHC_DOUBLE_FREE: 22,
+ CRASH_PHC_BOUNDS_VIOLATION: 23,
+ CRASH_HEAP_CORRUPTION: 24,
+ CRASH_EXC_GUARD: 25,
+ CRASH_STACK_OVERFLOW: 26,
+
+ // 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
+import { ctypes } from "resource://gre/modules/ctypes.sys.mjs";
+
+var dir = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
+var file = dir.clone();
+file = file.parent;
+file.append(ctypes.libraryName("testcrasher"));
+var 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.enablePHC = lib.declare(
+ "EnablePHC",
+ ctypes.default_abi,
+ ctypes.void_t
+);
+
+try {
+ CrashTestUtils.TryOverrideExceptionHandler = lib.declare(
+ "TryOverrideExceptionHandler",
+ ctypes.default_abi,
+ ctypes.void_t
+ );
+} catch (ex) {}
+
+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
+);
+
+CrashTestUtils.getWin64CFITestFnAddrOffset = lib.declare(
+ "GetWin64CFITestFnAddrOffset",
+ ctypes.default_abi,
+ ctypes.int32_t,
+ ctypes.int16_t
+);