Bug 1449835 Do not compile Windows x64 Crash Test Assembly for MinGW r?ccorcoran
authorTom Ritter <tom@mozilla.com>
Wed, 28 Mar 2018 13:23:33 -0500
changeset 1470116 9e07b4f474ccfc6e6871c3b110382ffced2e3ca0
parent 1470115 b35f9f6f844bab5ca5be0420b3bacba6913cd6c5
child 1470117 411e715aaa020b56de1a801d06f7f6aef4e57c87
push id262111
push usertritter@mozilla.com
push dateSat, 31 Mar 2018 02:17:16 +0000
treeherdertry@ca4ea3a2b865 [default view] [failures only]
reviewersccorcoran
bugs1449835
milestone60.0a1
Bug 1449835 Do not compile Windows x64 Crash Test Assembly for MinGW r?ccorcoran 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.) MozReview-Commit-ID: 5mHPi8PVio3
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},
@@ -112,17 +113,17 @@ GetWin64CFITestMap() {
 
 void ReserveStack() {
   // This ensures our tests have enough reserved stack space.
   uint8_t* p = (uint8_t*)alloca(1024000);
   // This ensures we don't optimized away this meaningless code at build time.
   mozilla::Unused << (int)(uint64_t)p;
 }
 
-#endif // XP_WIN && HAVE_64BIT_BUILD
+#endif // XP_WIN && HAVE_64BIT_BUILD && !defined(__MINGW32__)
 
 extern "C" NS_EXPORT
 void Crash(int16_t how)
 {
   switch (how) {
   case CRASH_INVALID_POINTER_DEREF: {
     volatile int* foo = (int*)0x42;
     *foo = 0;
@@ -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,17 +207,17 @@ 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");