StackWalk_windows.h (2033B)
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 #ifndef mozilla_StackWalk_windows_h 8 #define mozilla_StackWalk_windows_h 9 10 #include "mozilla/Array.h" 11 #include "mozilla/Types.h" 12 13 #if defined(_M_AMD64) || defined(_M_ARM64) 14 /** 15 * This function enables strategy (1) for avoiding deadlocks between the stack 16 * walking thread and the suspended thread. In aStackWalkLocks the caller must 17 * provide pointers to the two ntdll-internal SRW locks acquired by 18 * RtlLookupFunctionEntry. These locks are LdrpInvertedFunctionTableSRWLock and 19 * RtlpDynamicFunctionTableLock -- we don't need to know which one is which. 20 * Until InitializeStackWalkLocks function is called, strategy (2) is used. 21 * 22 * See comment in StackWalk.cpp 23 */ 24 MFBT_API 25 void InitializeStackWalkLocks(const mozilla::Array<void*, 2>& aStackWalkLocks); 26 27 /** 28 * As part of strategy (2) for avoiding deadlocks between the stack walking 29 * thread and the suspended thread, we mark stack walk suppression paths by 30 * putting them under the scope of a AutoSuppressStackWalking object. Any code 31 * path that may do an exclusive acquire of LdrpInvertedFunctionTableSRWLock or 32 * RtlpDynamicFunctionTableLock should be marked this way, to ensure that 33 * strategy (2) can properly mitigate all deadlock scenarios. 34 * 35 * See comment in StackWalk.cpp 36 */ 37 struct MOZ_RAII AutoSuppressStackWalking { 38 MFBT_API AutoSuppressStackWalking(); 39 MFBT_API ~AutoSuppressStackWalking(); 40 }; 41 42 # if defined(IMPL_MFBT) 43 void SuppressStackWalking(); 44 void DesuppressStackWalking(); 45 # endif // defined(IMPL_MFBT) 46 47 MFBT_API void RegisterJitCodeRegion(uint8_t* aStart, size_t size); 48 49 MFBT_API void UnregisterJitCodeRegion(uint8_t* aStart, size_t size); 50 #endif // _M_AMD64 || _M_ARM64 51 52 #endif // mozilla_StackWalk_windows_h