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: I0409758f30f4ba56b53a124b333ac0a530a0a65aPerfetto 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.