Bug 1449835 - Do not compile Windows x64 Crash Test Assembly for MinGW. r=ccorcoran, r=froydnj, a=jcristau
authorTom Ritter <tom@mozilla.com>
Wed, 16 May 2018 13:03:48 -0500
changeset 802193 5dc9b3739510ed74b72c91c311f5647c41572fe1
parent 802192 3ac8f220f7e6524be3f8753544cd46bec50dd5a7
child 802194 f10bc261be65712b1d508bf7b7b0750f2c66d161
push id111850
push userbmo:tom@mozilla.com
push dateThu, 31 May 2018 16:41:37 +0000
reviewersccorcoran, froydnj, jcristau
bugs1449835
milestone60.0.2
Bug 1449835 - Do not compile Windows x64 Crash Test Assembly for MinGW. r=ccorcoran, r=froydnj, a=jcristau The assembly file uses the wrong syntax and MinGW cannot compile it. (Also, gcc doesn't recognize it, because it ends in .asm and not .s.)
toolkit/crashreporter/test/moz.build
toolkit/crashreporter/test/nsTestCrasher.cpp
old mode 100644
new mode 100755
--- a/toolkit/crashreporter/test/moz.build
+++ b/toolkit/crashreporter/test/moz.build
@@ -20,19 +20,20 @@ UNIFIED_SOURCES += [
     'nsTestCrasher.cpp',
 ]
 
 SOURCES += [
   'ExceptionThrower.cpp',
 ]
 
 if CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'x86_64':
-    SOURCES += [
-        'win64UnwindInfoTests.asm',
-    ]
+    if CONFIG['CC_TYPE'] != 'gcc':
+        SOURCES += [
+            'win64UnwindInfoTests.asm',
+        ]
 
 if CONFIG['CC_TYPE'] == 'clang-cl':
     SOURCES['ExceptionThrower.cpp'].flags += [
         '-Xclang',
         '-fcxx-exceptions',
     ]
 elif CONFIG['CC_TYPE'] not in ('msvc', 'clang-cl'):
     SOURCES['ExceptionThrower.cpp'].flags += [
old mode 100644
new mode 100755
--- a/toolkit/crashreporter/test/nsTestCrasher.cpp
+++ b/toolkit/crashreporter/test/nsTestCrasher.cpp
@@ -1,11 +1,12 @@
 #include "mozilla/Assertions.h"
 
 #include <stdio.h>
+#include <map>
 
 #include "nscore.h"
 #include "mozilla/Unused.h"
 #include "ExceptionThrower.h"
 
 #ifdef XP_WIN
 #include <malloc.h>
 #include <windows.h>
@@ -40,31 +41,31 @@ void fcn( A* p )
 void PureVirtualCall()
 {
   // generates a pure virtual function call
   B b;
   b.use(); // make sure b's actually used
 }
 
 extern "C" {
-#if XP_WIN && HAVE_64BIT_BUILD
+#if XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
   // Implementation in win64unwindInfoTests.asm
   uint64_t x64CrashCFITest_NO_MANS_LAND(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_Launcher(uint64_t returnpfn, void* testProc);
   uint64_t x64CrashCFITest_UnknownOpcode(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_PUSH_NONVOL(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_ALLOC_SMALL(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_ALLOC_LARGE(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_SAVE_NONVOL(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_SAVE_NONVOL_FAR(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_SAVE_XMM128(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_SAVE_XMM128_FAR(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_EPILOG(uint64_t returnpfn, void*);
   uint64_t x64CrashCFITest_EOF(uint64_t returnpfn, void*);
-#endif // XP_WIN && HAVE_64BIT_BUILD
+#endif // XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
 }
 
 // Keep these in sync with CrashTestUtils.jsm!
 const int16_t CRASH_INVALID_POINTER_DEREF = 0;
 const int16_t CRASH_PURE_VIRTUAL_CALL     = 1;
 const int16_t CRASH_OOM                   = 3;
 const int16_t CRASH_MOZ_CRASH             = 4;
 const int16_t CRASH_ABORT                 = 5;
@@ -77,17 +78,17 @@ const int16_t CRASH_X64CFI_ALLOC_SMALL  
 const int16_t CRASH_X64CFI_ALLOC_LARGE    = 12;
 const int16_t CRASH_X64CFI_SAVE_NONVOL    = 15;
 const int16_t CRASH_X64CFI_SAVE_NONVOL_FAR = 16;
 const int16_t CRASH_X64CFI_SAVE_XMM128    = 17;
 const int16_t CRASH_X64CFI_SAVE_XMM128_FAR = 18;
 const int16_t CRASH_X64CFI_EPILOG         = 19;
 const int16_t CRASH_X64CFI_EOF            = 20;
 
-#if XP_WIN && HAVE_64BIT_BUILD
+#if XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
 
 typedef decltype(&x64CrashCFITest_UnknownOpcode) win64CFITestFnPtr_t;
 
 static std::map<int16_t, win64CFITestFnPtr_t>
 GetWin64CFITestMap() {
   std::map<int16_t, win64CFITestFnPtr_t> ret = {
     { CRASH_X64CFI_NO_MANS_LAND, x64CrashCFITest_NO_MANS_LAND},
     { CRASH_X64CFI_LAUNCHER, x64CrashCFITest_Launcher},
@@ -147,17 +148,17 @@ void Crash(int16_t how)
   case CRASH_ABORT: {
     abort();
     break;
   }
   case CRASH_UNCAUGHT_EXCEPTION: {
     ThrowException();
     break;
   }
-#if XP_WIN && HAVE_64BIT_BUILD
+#if XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
   case CRASH_X64CFI_UNKNOWN_OPCODE:
   case CRASH_X64CFI_PUSH_NONVOL:
   case CRASH_X64CFI_ALLOC_SMALL:
   case CRASH_X64CFI_ALLOC_LARGE:
   case CRASH_X64CFI_SAVE_NONVOL:
   case CRASH_X64CFI_SAVE_NONVOL_FAR:
   case CRASH_X64CFI_SAVE_XMM128:
   case CRASH_X64CFI_SAVE_XMM128_FAR:
@@ -167,17 +168,17 @@ void Crash(int16_t how)
     if (m.find(how) == m.end()) {
       break;
     }
     auto pfnTest = m[how];
     auto pfnLauncher = m[CRASH_X64CFI_LAUNCHER];
     pfnLauncher(0, pfnTest);
     break;
   }
-#endif // XP_WIN && HAVE_64BIT_BUILD
+#endif // XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
   default:
     break;
   }
 }
 
 char testData[32];
 
 extern "C" NS_EXPORT
@@ -206,22 +207,22 @@ extern "C" NS_EXPORT
 void TryOverrideExceptionHandler()
 {
   SetUnhandledExceptionFilter(HandleException);
 }
 #endif
 
 extern "C" NS_EXPORT uint32_t
 GetWin64CFITestFnAddrOffset(int16_t fnid) {
-#if XP_WIN && HAVE_64BIT_BUILD
+#if XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
   // fnid uses the same constants as Crash().
   // Returns the RVA of the requested function.
   // Returns 0 on failure.
   auto m = GetWin64CFITestMap();
   if (m.find(fnid) == m.end()) {
     return 0;
   }
   uint64_t moduleBase = (uint64_t)GetModuleHandleW(L"testcrasher.dll");
   return ((uint64_t)m[fnid]) - moduleBase;
 #else
   return 0;
-#endif // XP_WIN && HAVE_64BIT_BUILD
+#endif // XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
 }