base: ensure crash reporter works on monlithic binaries

The crash reporter that we use in standalone debug builds
was broken for the traced and traced_probes processes when
using monolithic_binaries=true, for the following reason:
- In order to save binary size on Android, traced{,_probes}
  are tiny wrappers around entrypoints defined in libperfetto
  (which is a .so in Android).
- On monolithic standalone builds libperfetto is built as a
  static library (libperfetto.a).
- The build system rules today do not use -Wl,whole-archive
  when linking .a files.
- As such the link() step was omitting the whole
  debug_crash_stack_trace.o because no file had any dependency
  to that.

The proposed fix is: make sure there is an edge between
base/logging.o and debug_crash_stack_trace.o. This is obtained
simply moving the global constructor used to initialize the
crash reporter in logging.o, which is included by virtually
every target in perfetto.

This does not affect production builds of Android because they
don't use GN. Also non-debug builds don't use this
in-house crash reporter even on standalone builds.

Test: manual: link on linux, killall -ABRT traced, see crash reporter.
Bug: 202283508
Change-Id: I0409758f30f4ba56b53a124b333ac0a530a0a65a
4 files changed
tree: 9ab43c102656b97aa816591c4c9146774ea0a202
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. src/
  13. test/
  14. tools/
  15. ui/
  16. .clang-format
  17. .clang-tidy
  18. .gitattributes
  19. .gitignore
  20. .gn
  21. .style.yapf
  22. Android.bp
  23. Android.bp.extras
  24. BUILD
  25. BUILD.extras
  26. BUILD.gn
  27. CHANGELOG
  28. codereview.settings
  29. DIR_METADATA
  30. heapprofd.rc
  31. LICENSE
  32. meson.build
  33. METADATA
  34. MODULE_LICENSE_APACHE2
  35. OWNERS
  36. perfetto.rc
  37. PerfettoIntegrationTests.xml
  38. PRESUBMIT.py
  39. README.chromium
  40. README.md
  41. TEST_MAPPING
  42. traced_perf.rc
  43. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.