summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h')
-rw-r--r--toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h b/toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h
new file mode 100644
index 0000000000..1306235cfd
--- /dev/null
+++ b/toolkit/crashreporter/breakpad-client/windows/common/minidump_callback.h
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef MINIDUMP_CALLBACK_H__
+#define MINIDUMP_CALLBACK_H__
+
+#include <windows.h>
+#include <dbghelp.h>
+
+#include <list>
+
+namespace google_breakpad {
+
+// These entries store a list of memory regions that the client wants included
+// in the minidump.
+struct AppMemory {
+ ULONG64 ptr;
+ ULONG length;
+ bool preallocated;
+
+ bool operator==(const struct AppMemory& other) const {
+ return ptr == other.ptr;
+ }
+
+ bool operator==(const void* other) const {
+ return ptr == reinterpret_cast<ULONG64>(other);
+ }
+
+ AppMemory()
+ : ptr(0)
+ , length(0)
+ , preallocated(false)
+ {}
+
+ AppMemory& operator=(const AppMemory& other) = default;
+};
+typedef std::list<AppMemory> AppMemoryList;
+
+// This is passed as the context to the MinidumpWriteDump callback.
+typedef struct {
+ AppMemoryList::const_iterator iter;
+ AppMemoryList::const_iterator end;
+} MinidumpCallbackContext;
+
+static const size_t kExceptionAppMemoryRegions = 33;
+
+#if defined(_M_IX86)
+using RegisterValueType = DWORD;
+#elif defined(_M_AMD64) || defined(_M_ARM64)
+using RegisterValueType = DWORD64;
+#else
+#error Unsupported platform
+#endif
+
+void IncludeAppMemoryFromExceptionContext(HANDLE aProcess,
+ DWORD aThreadId,
+ AppMemoryList& aList,
+ PCONTEXT aExceptionContext,
+ bool aInsttructionPointerOnly);
+
+// This function is used as a callback when calling MinidumpWriteDump,
+// in order to add additional memory regions to the dump.
+BOOL CALLBACK MinidumpWriteDumpCallback(
+ PVOID context,
+ const PMINIDUMP_CALLBACK_INPUT callback_input,
+ PMINIDUMP_CALLBACK_OUTPUT callback_output);
+
+// Called during startup to initialize system information used by
+// IncludeAppMemoryFromExceptionContext().
+void InitAppMemoryInternal();
+
+} // namespace google_breakpad
+
+#endif
+