From 1cf3b81e8dfd38d0a88d43f57e773fd8d5d2a4a7 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Mon, 27 May 2024 09:32:11 +0000 Subject: [PATCH] Bug 1898180 - Use proper process ID for all the crash reporter functions r=KrisWright Differential Revision: https://phabricator.services.mozilla.com/D211166 --- .../crashreporter/nsDummyExceptionHandler.cpp | 6 +-- toolkit/crashreporter/nsExceptionHandler.cpp | 6 +-- toolkit/crashreporter/nsExceptionHandler.h | 46 +++++++++---------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/toolkit/crashreporter/nsDummyExceptionHandler.cpp b/toolkit/crashreporter/nsDummyExceptionHandler.cpp index fb7a6005c8a0..bf85bc22769b 100644 --- a/toolkit/crashreporter/nsDummyExceptionHandler.cpp +++ b/toolkit/crashreporter/nsDummyExceptionHandler.cpp @@ -118,7 +118,7 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data) { bool GetAnnotation(const nsACString& key, nsACString& data) { return false; } -void GetAnnotation(uint32_t childPid, Annotation annotation, +void GetAnnotation(ProcessId childPid, Annotation annotation, nsACString& outStr) { return; } @@ -221,12 +221,12 @@ bool CreateNotificationPipeForChild(int* childCrashFd, int* childCrashRemapFd) { bool SetRemoteExceptionHandler(const char* aCrashPipe) { return false; } -bool TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, +bool TakeMinidumpForChild(ProcessId childPid, nsIFile** dump, AnnotationTable& aAnnotations) { return false; } -bool FinalizeOrphanedMinidump(uint32_t aChildPid, GeckoProcessType aType, +bool FinalizeOrphanedMinidump(ProcessId aChildPid, GeckoProcessType aType, nsString* aDumpId) { return false; } diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 03398a9b01f5..28b416ce0d27 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -3560,7 +3560,7 @@ bool SetRemoteExceptionHandler(const char* aCrashPipe) { return gExceptionHandler->IsOutOfProcess(); } -void GetAnnotation(uint32_t childPid, Annotation annotation, +void GetAnnotation(ProcessId childPid, Annotation annotation, nsACString& outStr) { if (!GetEnabled()) { return; @@ -3576,7 +3576,7 @@ void GetAnnotation(uint32_t childPid, Annotation annotation, outStr = (*pd->annotations)[annotation]; } -bool TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, +bool TakeMinidumpForChild(ProcessId childPid, nsIFile** dump, AnnotationTable& aAnnotations) { if (!GetEnabled()) return false; @@ -3593,7 +3593,7 @@ bool TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, return !!*dump; } -bool FinalizeOrphanedMinidump(uint32_t aChildPid, GeckoProcessType aType, +bool FinalizeOrphanedMinidump(ProcessId aChildPid, GeckoProcessType aType, nsString* aDumpId) { AnnotationTable annotations; nsCOMPtr minidump; diff --git a/toolkit/crashreporter/nsExceptionHandler.h b/toolkit/crashreporter/nsExceptionHandler.h index 7a6bae5ac668..faf921a34917 100644 --- a/toolkit/crashreporter/nsExceptionHandler.h +++ b/toolkit/crashreporter/nsExceptionHandler.h @@ -47,6 +47,26 @@ namespace CrashReporter { using mozilla::Maybe; using mozilla::Nothing; +#if defined(XP_WIN) +typedef HANDLE ProcessHandle; +typedef DWORD ProcessId; +typedef DWORD ThreadId; +typedef HANDLE FileHandle; +const FileHandle kInvalidFileHandle = INVALID_HANDLE_VALUE; +#elif defined(XP_MACOSX) +typedef task_t ProcessHandle; +typedef pid_t ProcessId; +typedef mach_port_t ThreadId; +typedef int FileHandle; +const FileHandle kInvalidFileHandle = -1; +#else +typedef int ProcessHandle; +typedef pid_t ProcessId; +typedef int ThreadId; +typedef int FileHandle; +const FileHandle kInvalidFileHandle = -1; +#endif + /** * Returns true if the crash reporter is using the dummy implementation. */ @@ -151,7 +171,7 @@ nsresult UnregisterAppMemory(void* ptr); // Include heap regions of the crash context. void SetIncludeContextHeap(bool aValue); -void GetAnnotation(uint32_t childPid, Annotation annotation, +void GetAnnotation(ProcessId childPid, Annotation annotation, nsACString& outStr); // Functions for working with minidumps and .extras @@ -210,7 +230,7 @@ void OOPInit(); // path in |dump|. The caller owns the last reference to |dump| if it // is non-nullptr. The annotations for the crash will be stored in // |aAnnotations|. -bool TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, +bool TakeMinidumpForChild(ProcessId childPid, nsIFile** dump, AnnotationTable& aAnnotations); /** @@ -224,30 +244,10 @@ bool TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, * @param aType The type of the crashed process * @param aDumpId A string that will be filled with the dump ID */ -[[nodiscard]] bool FinalizeOrphanedMinidump(uint32_t aChildPid, +[[nodiscard]] bool FinalizeOrphanedMinidump(ProcessId aChildPid, GeckoProcessType aType, nsString* aDumpId = nullptr); -#if defined(XP_WIN) -typedef HANDLE ProcessHandle; -typedef DWORD ProcessId; -typedef DWORD ThreadId; -typedef HANDLE FileHandle; -const FileHandle kInvalidFileHandle = INVALID_HANDLE_VALUE; -#elif defined(XP_MACOSX) -typedef task_t ProcessHandle; -typedef pid_t ProcessId; -typedef mach_port_t ThreadId; -typedef int FileHandle; -const FileHandle kInvalidFileHandle = -1; -#else -typedef int ProcessHandle; -typedef pid_t ProcessId; -typedef int ThreadId; -typedef int FileHandle; -const FileHandle kInvalidFileHandle = -1; -#endif - // Return the current thread's ID. // // XXX: this is a somewhat out-of-place interface to expose through