Fix mac build
Change-Id: Ib43573742e7217d6e2f2e6629cb0f24ec68dc432
diff --git a/BUILD.gn b/BUILD.gn
index 1d4b663..f5b3da4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -34,15 +34,19 @@
]
if (!build_with_chromium) {
deps += [
- ":perfetto",
- ":perfetto_benchmarks",
- ":perfetto_integrationtests",
- ":traced",
- ":traced_probes",
"protos/perfetto/config:merged_config", # For syntax-checking the proto.
"test/configs",
"tools:protoc_helper",
]
+ if (is_linux || is_android) {
+ deps += [
+ ":perfetto",
+ ":perfetto_benchmarks",
+ ":perfetto_integrationtests",
+ ":traced",
+ ":traced_probes",
+ ]
+ }
}
}
@@ -63,7 +67,7 @@
}
}
-if (!build_with_chromium) {
+if (!build_with_chromium && (is_linux || is_android)) {
executable("perfetto_benchmarks") {
testonly = true
deps = [
diff --git a/include/perfetto/base/task_runner.h b/include/perfetto/base/task_runner.h
index d7e1919..d8972e4 100644
--- a/include/perfetto/base/task_runner.h
+++ b/include/perfetto/base/task_runner.h
@@ -19,7 +19,10 @@
#include <functional>
#include "perfetto/base/build_config.h"
+
+#if BUILDFLAG(OS_LINUX) || BUILDFLAG(OS_ANDROID)
#include "perfetto/base/watchdog.h"
+#endif
namespace perfetto {
namespace base {
@@ -66,7 +69,8 @@
protected:
static void RunTask(const std::function<void()>& task) {
-#if !BUILDFLAG(PERFETTO_CHROMIUM_BUILD)
+#if !BUILDFLAG(PERFETTO_CHROMIUM_BUILD) && \
+ (BUILDFLAG(OS_LINUX) || BUILDFLAG(OS_ANDROID))
base::WatchDog w(kWatchdogMillis);
#endif
task();
diff --git a/src/base/BUILD.gn b/src/base/BUILD.gn
index 64fa733..c8d5f87 100644
--- a/src/base/BUILD.gn
+++ b/src/base/BUILD.gn
@@ -25,8 +25,10 @@
"page_allocator.cc",
"thread_checker.cc",
"unix_task_runner.cc",
- "watchdog.cc",
]
+ if (is_linux || is_android) {
+ sources += [ "watchdog.cc" ]
+ }
if (is_debug) {
deps += [ ":debug_crash_stack_trace" ]
}
@@ -99,7 +101,9 @@
"task_runner_unittest.cc",
"thread_checker_unittest.cc",
"utils_unittest.cc",
- "watchdog_unittest.cc",
"weak_ptr_unittest.cc",
]
+ if (is_linux || is_android) {
+ sources += [ "watchdog_unittest.cc" ]
+ }
}
diff --git a/src/base/debug_crash_stack_trace.cc b/src/base/debug_crash_stack_trace.cc
index fef2ae0..b27df94 100644
--- a/src/base/debug_crash_stack_trace.cc
+++ b/src/base/debug_crash_stack_trace.cc
@@ -26,6 +26,8 @@
#include <unistd.h>
#include <unwind.h>
+#include "perfetto/base/build_config.h"
+
#if defined(NDEBUG)
#error This translation unit should not be used in release builds
#endif
@@ -154,13 +156,18 @@
}
Print("------------------ END OF CRASH ------------------\n");
+
// info->si_code <= 0 iff SI_FROMUSER (SI_FROMKERNEL otherwise).
if (info->si_code <= 0 || sig_num == 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 BUILDFLAG(OS_MACOSX)
+ if (kill(getpid(), sig_num) < 0) {
+#else
if (syscall(__NR_tgkill, getpid(), syscall(__NR_gettid), sig_num) < 0) {
+#endif
// 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.