client: Add a tvOS version of CrashHandler, add tvOS support to tests

tvOS as a platform is very similar to iOS, but one of significant
difference is that Mach message passing (including mach_msg()) is not
allowed. This means that it is completely impossible to handle Mach
exceptions on tvOS.

Consequently, we need a CrashHandler implementation that is entirely
based on the POSIX signals API. Breakpad has had such an implementation
for years [1], so some of the code was based on Breakpad's.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/breakpad/breakpad/src/client/ios/exception_handler_no_mach.cc

In general terms:
- GN: Most of the code in util/mach/ is not built on tvOS, and the mig
  calls are skipped altogether. The only allowed files at the moment are
  util/mach/mach_extensions.{cc,h}, which contain some constants and
  functions that are useful and allowed outside the Mach exception
  context.
- CrashHandler: the code was split into multiple files for clarity. The
  user-visible API (i.e. the CrashpadClient calls) remains in
  crashpad_client_ios.cc, while the internal CrashHandler class was
  split into multiple files and classes.
  Namely, the common code handling NSExceptions and communication with
  InProcessHandler is part of CrashHandlerBase and the iOS and
  tvOS-specific implementations are in crash_handler_{ios,tvos}.{cc,h}.
  The tvOS CrashHandler code is basically a simplified version of the
  iOS one: we watch a lot of signals in Initialize() and call
  DumpExceptionFromSignal() when we get one (after which we call
  Signals::RestoreHandlerAndReraiseSignalOnReturn() and exit).
- Tests:
  - Tests that checked for specific Mach exceptions needed a new
    tvOS-specific code path. We need to check for specific signal values
    where possible instead.
  - testRecursion() had to be skipped altogether. We cannot monitor Mach
    exceptions, and sigaltstack() is also forbidden on tvOS. This means
    there is no reliable way of monitoring a stack overflow as explained
    in the comment in code.

Bug: 405140658, 351887716
Change-Id: I2f13a5788d8e5ac085b49716c43bb375d017ad35
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6421038
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Raphael Kubo da Costa <kubo@igalia.com>
12 files changed
tree: 643a19fc20c644eef9b43260992b82a7f557cce9
  1. build/
  2. client/
  3. compat/
  4. doc/
  5. handler/
  6. infra/
  7. minidump/
  8. snapshot/
  9. test/
  10. third_party/
  11. tools/
  12. util/
  13. .clang-format
  14. .gitattributes
  15. .gitignore
  16. .gn
  17. .style.yapf
  18. .vpython3
  19. AUTHORS
  20. BUILD.gn
  21. codereview.settings
  22. CONTRIBUTORS
  23. DEPS
  24. LICENSE
  25. navbar.md
  26. OWNERS
  27. package.h
  28. README.md
README.md

Crashpad

Crashpad is a crash-reporting system.

Documentation

Source Code

Crashpad’s source code is hosted in a Git repository at https://chromium.googlesource.com/crashpad/crashpad.

Other Links