CrashReporterClient.cpp (2277B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "CrashReporterClient.h" 8 #include "nsISupportsImpl.h" 9 10 #if defined(XP_LINUX) && defined(MOZ_CRASHREPORTER) && \ 11 defined(MOZ_OXIDIZED_BREAKPAD) 12 # include "mozilla/toolkit/crashreporter/rust_minidump_writer_linux_ffi_generated.h" 13 #endif // defined(XP_LINUX) && defined(MOZ_CRASHREPORTER) && 14 // defined(MOZ_OXIDIZED_BREAKPAD) 15 16 namespace mozilla::ipc { 17 18 StaticMutex CrashReporterClient::sLock; 19 StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton; 20 21 CrashReporterClient::CrashReporterClient() { 22 MOZ_COUNT_CTOR(CrashReporterClient); 23 } 24 25 CrashReporterClient::~CrashReporterClient() { 26 MOZ_COUNT_DTOR(CrashReporterClient); 27 } 28 29 /* static */ 30 void CrashReporterClient::InitSingleton() { 31 { 32 StaticMutexAutoLock lock(sLock); 33 34 MOZ_ASSERT(!sClientSingleton); 35 sClientSingleton = new CrashReporterClient(); 36 } 37 } 38 39 /*static*/ 40 CrashReporter::CrashReporterInitArgs CrashReporterClient::CreateInitArgs() { 41 CrashReporter::CrashReporterInitArgs initArgs; 42 initArgs.threadId() = CrashReporter::CurrentThreadId(); 43 44 #if defined(XP_LINUX) && defined(MOZ_CRASHREPORTER) && \ 45 defined(MOZ_OXIDIZED_BREAKPAD) 46 DirectAuxvDumpInfo auxvInfo = {}; 47 CrashReporter::GetCurrentProcessAuxvInfo(&auxvInfo); 48 initArgs.auxvInfo().programHeaderCount() = auxvInfo.program_header_count; 49 initArgs.auxvInfo().programHeaderAddress() = auxvInfo.program_header_address; 50 initArgs.auxvInfo().linuxGateAddress() = auxvInfo.linux_gate_address; 51 initArgs.auxvInfo().entryAddress() = auxvInfo.entry_address; 52 #endif // defined(XP_LINUX) && defined(MOZ_CRASHREPORTER) && 53 // defined(MOZ_OXIDIZED_BREAKPAD) 54 55 return initArgs; 56 } 57 58 /* static */ 59 void CrashReporterClient::DestroySingleton() { 60 StaticMutexAutoLock lock(sLock); 61 sClientSingleton = nullptr; 62 } 63 64 /* static */ 65 RefPtr<CrashReporterClient> CrashReporterClient::GetSingleton() { 66 StaticMutexAutoLock lock(sLock); 67 return sClientSingleton; 68 } 69 70 } // namespace mozilla::ipc