Bug 1428182 - 6b. Support unified headers in Breakpad code; r=ted draft
authorJim Chen <nchen@mozilla.com>
Tue, 30 Jan 2018 14:08:23 -0500
changeset 748993 a3ecd37922d1719a6b5b2ec30e393bb3604e39c5
parent 748992 7816e69d49f09865f16f1e0769c6816c64e5ea95
child 748994 c17d030e0066286364f575671d5802b383af68a9
push id97287
push userbmo:nchen@mozilla.com
push dateTue, 30 Jan 2018 19:09:20 +0000
reviewersted
bugs1428182
milestone60.0a1
Bug 1428182 - 6b. Support unified headers in Breakpad code; r=ted Fix several problems when building Breakpad with new NDK unified headers. - Unified headers define its own tgkill wrapper, so rename our own wrapper to __tgkill. - Unified headers define user_fpxregs_struct for all API levels, so don't redefine it. - Only the target sources under google-breakpad/src/common/linux should use custom Android headers, so change the includes line in moz.build to use OS_INCLUDES. MozReview-Commit-ID: HGnUMu5vDUM
config/system-headers.mozbuild
toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc
toolkit/crashreporter/breakpad-client/linux/moz.build
toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -1045,16 +1045,17 @@ system_headers = [
     'xcb/shm.h',
     'xcb/xcb.h',
     'xlocale.h',
     'zmouse.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     system_headers += [
+        'android/api-level.h',
         'android/ashmem.h',
         'android_audio/AudioSystem.h',
         'android/log.h',
         'android/looper.h',
         'android/native_window.h',
         'android/native_window_jni.h',
         'audio_effects/effect_aec.h',
         'audio_effects/effect_ns.h',
--- a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc
+++ b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc
@@ -101,17 +101,17 @@
 #include "linux/sched.h"
 #endif
 
 #ifndef PR_SET_PTRACER
 #define PR_SET_PTRACER 0x59616d61
 #endif
 
 // A wrapper for the tgkill syscall: send a signal to a specific thread.
-static int tgkill(pid_t tgid, pid_t tid, int sig) {
+static int _tgkill(pid_t tgid, pid_t tid, int sig) {
   return syscall(__NR_tgkill, tgid, tid, sig);
   return 0;
 }
 
 namespace google_breakpad {
 
 namespace {
 // The list of signals which we consider to be crashes. The default action for
@@ -382,17 +382,17 @@ void ExceptionHandler::SignalHandler(int
   pthread_mutex_unlock(&g_handler_stack_mutex_);
 
   // info->si_code <= 0 iff SI_FROMUSER (SI_FROMKERNEL otherwise).
   if (info->si_code <= 0 || sig == SIGABRT) {
     // This signal was triggered by somebody sending us the signal with kill().
     // In order to retrigger it, we have to queue a new signal by calling
     // kill() ourselves.  The special case (si_pid == 0 && sig == SIGABRT) is
     // due to the kernel sending a SIGABRT from a user request via SysRQ.
-    if (tgkill(getpid(), syscall(__NR_gettid), sig) < 0) {
+    if (_tgkill(getpid(), syscall(__NR_gettid), sig) < 0) {
       // If we failed to kill ourselves (e.g. because a sandbox disallows us
       // to do so), we instead resort to terminating our process. This will
       // result in an incorrect exit code.
       _exit(1);
     }
   } else {
     // This was a synchronous signal triggered by a hard fault (e.g. SIGSEGV).
     // No need to reissue the signal. It will automatically trigger again,
--- a/toolkit/crashreporter/breakpad-client/linux/moz.build
+++ b/toolkit/crashreporter/breakpad-client/linux/moz.build
@@ -30,13 +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'
 
-if CONFIG['OS_TARGET'] == 'Android' and CONFIG['CPU_ARCH'] == 'x86':
-    # The NDK's user.h defines this struct with a different name.
-    DEFINES['user_fpxregs_struct'] = 'user_fxsr_struct'
-
 include('/toolkit/crashreporter/crashreporter.mozbuild')
--- a/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
@@ -35,18 +35,18 @@ HOST_SOURCES += [
 HOST_CXXFLAGS += [
     '-O2',
     '-g',
 ]
 
 if CONFIG['OS_TARGET'] == 'Android':
     DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION']
     DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION']
-    LOCAL_INCLUDES += [
-        '/toolkit/crashreporter/google-breakpad/src/common/android/include',
+    COMPILE_FLAGS['OS_INCLUDES'] += [
+        '-I%s/toolkit/crashreporter/google-breakpad/src/common/android/include' % TOPSRCDIR,
     ]
 
 Library('breakpad_linux_common_s')
 
 FINAL_LIBRARY = 'xul'
 
 HOST_DEFINES['NO_STABS_SUPPORT'] = True