diff --git a/mozglue/misc/interceptor/PatcherNopSpace.h b/mozglue/misc/interceptor/PatcherNopSpace.h index 3382e7dabdd550737e93478d2f406f6f37c85464..6ebf9a0b59fe77b5d02c5d190a04895f4776aabc 100644 --- a/mozglue/misc/interceptor/PatcherNopSpace.h +++ b/mozglue/misc/interceptor/PatcherNopSpace.h @@ -152,8 +152,8 @@ public: return false; } - return mPatchedFns.append( - reinterpret_cast<void*>(readOnlyTargetFn.GetBaseAddress())); + mPatchedFns.append(reinterpret_cast<void*>(readOnlyTargetFn.GetBaseAddress())); + return true; } bool WriteHook(const ReadOnlyTargetFunction<MMPolicyT>& aFn, @@ -169,7 +169,7 @@ public: // Check that the 5 bytes before the function are NOP's or INT 3's, const uint8_t nopOrBp[] = { 0x90, 0xCC }; - if (!writableFn.template VerifyValuesAreOneOf<uint8_t, 5>(nopOrBp)) { + if (!writableFn.VerifyValuesAreOneOf<uint8_t, 5>(nopOrBp)) { return false; } @@ -184,8 +184,7 @@ public: // (These look backwards because little-endian) const uint16_t possibleEncodings[] = { 0xFF8B, 0xFF89 }; - if (!writableFn.template VerifyValuesAreOneOf<uint16_t, 1>( - possibleEncodings, 5)) { + if (!writableFn.VerifyValuesAreOneOf<uint16_t, 1>(possibleEncodings, 5)) { return false; } diff --git a/mozglue/misc/interceptor/TargetFunction.h b/mozglue/misc/interceptor/TargetFunction.h index 2a0e63f0f4823d4bfa3e50eadab6b81eee0d3f89..2d7202df6d5eae6a2db649ca2a667a0f11b2e40f 100644 --- a/mozglue/misc/interceptor/TargetFunction.h +++ b/mozglue/misc/interceptor/TargetFunction.h @@ -595,81 +595,82 @@ private: uint8_t const * const mBase; }; -template <typename TargetMMPolicy> class TargetBytesPtr; - -template<> -class TargetBytesPtr<MMPolicyInProcess> +template <typename MMPolicy> +class MOZ_STACK_CLASS ReadOnlyTargetFunction final { -public: - typedef TargetBytesPtr<MMPolicyInProcess> Type; + template <typename TargetMMPolicy> + class TargetBytesPtr; - static Type Make(const MMPolicyInProcess& aMMPolicy, const void* aFunc) + template<> + class TargetBytesPtr<MMPolicyInProcess> { - return TargetBytesPtr(aMMPolicy, aFunc); - } + public: + typedef TargetBytesPtr<MMPolicyInProcess> Type; - static Type CopyFromOffset(const TargetBytesPtr& aOther, - const uint32_t aOffsetFromOther) - { - return TargetBytesPtr(aOther, aOffsetFromOther); - } + static Type Make(const MMPolicyInProcess& aMMPolicy, const void* aFunc) + { + return std::move(TargetBytesPtr(aMMPolicy, aFunc)); + } - ReadOnlyTargetBytes<MMPolicyInProcess>* operator->() - { - return &mTargetBytes; - } + static Type CopyFromOffset(const TargetBytesPtr& aOther, + const uint32_t aOffsetFromOther) + { + return std::move(TargetBytesPtr(aOther, aOffsetFromOther)); + } - TargetBytesPtr(TargetBytesPtr&& aOther) - : mTargetBytes(std::move(aOther.mTargetBytes)) - { - } + ReadOnlyTargetBytes<MMPolicyInProcess>* operator->() + { + return &mTargetBytes; + } - TargetBytesPtr(const TargetBytesPtr& aOther) - : mTargetBytes(aOther.mTargetBytes) - { - } + TargetBytesPtr(TargetBytesPtr&& aOther) + : mTargetBytes(std::move(aOther.mTargetBytes)) + { + } - TargetBytesPtr& operator=(const TargetBytesPtr&) = delete; - TargetBytesPtr& operator=(TargetBytesPtr&&) = delete; + TargetBytesPtr(const TargetBytesPtr& aOther) + : mTargetBytes(aOther.mTargetBytes) + { + } -private: - TargetBytesPtr(const MMPolicyInProcess& aMMPolicy, const void* aFunc) - : mTargetBytes(aMMPolicy, aFunc) - { - } + TargetBytesPtr& operator=(const TargetBytesPtr&) = delete; + TargetBytesPtr& operator=(TargetBytesPtr&&) = delete; - TargetBytesPtr(const TargetBytesPtr& aOther, - const uint32_t aOffsetFromOther) - : mTargetBytes(aOther.mTargetBytes, aOffsetFromOther) - { - } + private: + TargetBytesPtr(const MMPolicyInProcess& aMMPolicy, const void* aFunc) + : mTargetBytes(aMMPolicy, aFunc) + { + } - ReadOnlyTargetBytes<MMPolicyInProcess> mTargetBytes; -}; + TargetBytesPtr(const TargetBytesPtr& aOther, + const uint32_t aOffsetFromOther) + : mTargetBytes(aOther.mTargetBytes, aOffsetFromOther) + { + } -template <> -class TargetBytesPtr<MMPolicyOutOfProcess> -{ -public: - typedef std::shared_ptr<ReadOnlyTargetBytes<MMPolicyOutOfProcess>> Type; + ReadOnlyTargetBytes<MMPolicyInProcess> mTargetBytes; + }; - static Type Make(const MMPolicyOutOfProcess& aMMPolicy, const void* aFunc) + template <> + class TargetBytesPtr<MMPolicyOutOfProcess> { - return std::make_shared<ReadOnlyTargetBytes<MMPolicyOutOfProcess>>( - aMMPolicy, aFunc); - } + public: + typedef std::shared_ptr<ReadOnlyTargetBytes<MMPolicyOutOfProcess>> Type; - static Type CopyFromOffset(const Type& aOther, - const uint32_t aOffsetFromOther) - { - return std::make_shared<ReadOnlyTargetBytes<MMPolicyOutOfProcess>>( - *aOther, aOffsetFromOther); - } -}; + static Type Make(const MMPolicyOutOfProcess& aMMPolicy, const void* aFunc) + { + return std::move(std::make_shared<ReadOnlyTargetBytes<MMPolicyOutOfProcess>>( + aMMPolicy, aFunc)); + } + + static Type CopyFromOffset(const Type& aOther, + const uint32_t aOffsetFromOther) + { + return std::move(std::make_shared<ReadOnlyTargetBytes<MMPolicyOutOfProcess>>( + *aOther, aOffsetFromOther)); + } + }; -template <typename MMPolicy> -class MOZ_STACK_CLASS ReadOnlyTargetFunction final -{ public: ReadOnlyTargetFunction(const MMPolicy& aMMPolicy, const void* aFunc) : mTargetBytes(TargetBytesPtr<MMPolicy>::Make(aMMPolicy, aFunc)) diff --git a/toolkit/crashreporter/breakpad-client/linux/moz.build b/toolkit/crashreporter/breakpad-client/linux/moz.build index 047f78c6f3e6554c592ee36a11ba8ec141219a4d..c7aa654406ad5b21e1c3b207b56fd1b22f060374 100644 --- a/toolkit/crashreporter/breakpad-client/linux/moz.build +++ b/toolkit/crashreporter/breakpad-client/linux/moz.build @@ -30,6 +30,9 @@ if CONFIG['OS_TARGET'] == 'Android': '/toolkit/crashreporter/google-breakpad/src/common/android/include', ] +# We allow warnings for third-party code that can be updated from upstream. +AllowCompilerWarnings() + FINAL_LIBRARY = 'xul' include('/toolkit/crashreporter/crashreporter.mozbuild') diff --git a/toolkit/crashreporter/breakpad-client/mac/handler/moz.build b/toolkit/crashreporter/breakpad-client/mac/handler/moz.build index b0bac75a850416fbbb1b4887374d552face2ebd7..6c0cf495d08c849453c3f8fc7ad469d8975743b1 100644 --- a/toolkit/crashreporter/breakpad-client/mac/handler/moz.build +++ b/toolkit/crashreporter/breakpad-client/mac/handler/moz.build @@ -11,6 +11,9 @@ UNIFIED_SOURCES += [ 'minidump_generator.cc', ] +# We allow warnings for third-party code that can be updated from upstream. +AllowCompilerWarnings() + FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ diff --git a/toolkit/crashreporter/client/crashreporter_win.cpp b/toolkit/crashreporter/client/crashreporter_win.cpp index 873d25c82244c0181416c56933889cf2a3c3e0a4..c4b94a3fcfc17a8f84a5e16100eb89775a708804 100644 --- a/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/toolkit/crashreporter/client/crashreporter_win.cpp @@ -283,8 +283,7 @@ static string FormatLastError() } else { char buf[64]; - sprintf(buf, "Unknown error, error code: 0x%08x", - static_cast<unsigned int>(err)); + sprintf(buf, "Unknown error, error code: 0x%08x", err); message += buf; } return message; @@ -349,6 +348,18 @@ static void SetDlgItemVisible(HWND hwndDlg, UINT item, bool visible) ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE); } +static void SetDlgItemDisabled(HWND hwndDlg, UINT item, bool disabled) +{ + HWND hwnd = GetDlgItem(hwndDlg, item); + LONG style = GetWindowLong(hwnd, GWL_STYLE); + if (!disabled) + style |= WS_DISABLED; + else + style &= ~WS_DISABLED; + + SetWindowLong(hwnd, GWL_STYLE, style); +} + /* === Crash Reporting Dialog === */ static void StretchDialog(HWND hwndDlg, int ydiff) diff --git a/toolkit/crashreporter/client/moz.build b/toolkit/crashreporter/client/moz.build index dae264c177933c1600b61c0cb2797f52ae4f8037..99eb9b0cb02010f51d5793e7eb8d013ac1f15013 100644 --- a/toolkit/crashreporter/client/moz.build +++ b/toolkit/crashreporter/client/moz.build @@ -99,3 +99,6 @@ RCINCLUDE = 'crashreporter.rc' DisableStlWrapping() include('/toolkit/crashreporter/crashreporter.mozbuild') + +if CONFIG['CC_TYPE'] == 'clang-cl': + AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build index 2a1e168fccd1f6a0b7c4c25edc14029caaef4f3a..4ace7bc6287efff14035836f119ab8f5960eff7f 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build @@ -42,6 +42,9 @@ SOURCES += [ Library('breakpad_mac_common_s') +# We allow warnings for third-party code that can be updated from upstream. +AllowCompilerWarnings() + FINAL_LIBRARY = 'xul' CMFLAGS += ['-std=c99'] diff --git a/toolkit/crashreporter/google-breakpad/src/common/moz.build b/toolkit/crashreporter/google-breakpad/src/common/moz.build index 725ff06cc18a665ec1698552f64eb764b12ae5c1..8bbd071666ae58403d66bb580f774e9fa6e3e60f 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/moz.build @@ -70,6 +70,9 @@ if CONFIG['OS_TARGET'] == 'Android': Library('breakpad_common_s') +# We allow warnings for third-party code that can be updated from upstream. +AllowCompilerWarnings() + FINAL_LIBRARY = 'xul' include('/toolkit/crashreporter/crashreporter.mozbuild') diff --git a/toolkit/crashreporter/moz.build b/toolkit/crashreporter/moz.build index dba5bffe82d4d6dfe801061a5335de5aee93f9ed..0b710b8348ef1bc796722e9dd86f42d7b0f2d6d2 100644 --- a/toolkit/crashreporter/moz.build +++ b/toolkit/crashreporter/moz.build @@ -141,3 +141,6 @@ crash_annotations.inputs = [ with Files('**'): BUG_COMPONENT = ('Toolkit', 'Crash Reporting') + +if CONFIG['CC_TYPE'] == 'clang-cl': + AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 2fce7b27876e7a92d0b13005a96ccc3787881944..21227ec7238492b1f042b73ec441fb6c9bf77c22 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -12,7 +12,6 @@ #include "nsDirectoryService.h" #include "nsDataHashtable.h" #include "mozilla/ArrayUtils.h" -#include "mozilla/DebugOnly.h" #include "mozilla/EnumeratedRange.h" #include "mozilla/Services.h" #include "nsIObserverService.h" @@ -1330,8 +1329,6 @@ FreeBreakpadVM() } } -#if defined(XP_WIN) - /** * Filters out floating point exceptions which are handled by nsSigHandlers.cpp * and should not be handled as crashes. @@ -1382,8 +1379,6 @@ ChildFPEFilter(void* context, EXCEPTION_POINTERS* exinfo, return result; } -#endif // defined(XP_WIN) - static MINIDUMP_TYPE GetMinidumpType() { @@ -1433,8 +1428,6 @@ static bool ShouldReport() return true; } -#if !defined(XP_WIN) - static bool Filter(void* context) { @@ -1455,8 +1448,6 @@ ChildFilter(void* context) return result; } -#endif // !defined(XP_WIN) - static void TerminateHandler() { @@ -1671,10 +1662,9 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory, // protect the crash reporter from being unloaded gBlockUnhandledExceptionFilter = true; gKernel32Intercept.Init("kernel32.dll"); - DebugOnly<bool> ok = - stub_SetUnhandledExceptionFilter.Set(gKernel32Intercept, - "SetUnhandledExceptionFilter", - &patched_SetUnhandledExceptionFilter); + bool ok = stub_SetUnhandledExceptionFilter.Set(gKernel32Intercept, + "SetUnhandledExceptionFilter", + &patched_SetUnhandledExceptionFilter); #ifdef DEBUG if (!ok) diff --git a/toolkit/crashreporter/test/moz.build b/toolkit/crashreporter/test/moz.build index abea73981f45cefb45bac6150c4372fab5fb2d64..c62600a00b0df1943b59dde937af18648a805216 100755 --- a/toolkit/crashreporter/test/moz.build +++ b/toolkit/crashreporter/test/moz.build @@ -59,3 +59,6 @@ NO_PGO = True # Temporary workaround for an issue in upstream breakpad if CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'): CXXFLAGS += ['-wd4334'] + +if CONFIG['CC_TYPE'] == 'clang-cl': + AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/toolkit/crashreporter/test/nsTestCrasher.cpp b/toolkit/crashreporter/test/nsTestCrasher.cpp index 7b63d2de045bbcd3da3fa4f7064890eab97e8742..ac763874233002ec2edc43c3d554c94fde1b0e16 100755 --- a/toolkit/crashreporter/test/nsTestCrasher.cpp +++ b/toolkit/crashreporter/test/nsTestCrasher.cpp @@ -176,7 +176,7 @@ void Crash(int16_t how) auto pfnTest = m[how]; auto pfnLauncher = m[CRASH_X64CFI_LAUNCHER]; ReserveStack(); - pfnLauncher(0, reinterpret_cast<void*>(pfnTest)); + pfnLauncher(0, pfnTest); break; } #endif // XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)