Grab perfetto heap dump on OOME

In order to make OutOfMemoryErrors actionable, enable collecting heap
dumps at the time of the error when there is a present tracing session.

For now userdebug-only

This change introduces a new hook which is used by the existing
perfetto plugin to collect the data.

Usage: Setup a perfetto tracing session using data source
android.java_hprof.oom, with a START_TRACING trigger activated by
"com.android.telemetry.art-outofmemory"

Important points:
- Unlike the current impl, we need to block the execution while we
  collect the data. This is because propagating the OOME will
  result in the process exiting (and cleanup will eliminate the entire
  cgroup, including the heap dump children)
- Processes do not know whether a START_TRACING session exists but
  nevertheless need to wait for the producer start signal (in case one
  exists). We wait up to 500ms which will delay all OOMing processes.

For more details see go/art-oom-heap-dump

Test: manual
      system_server OOME (collected heap dump, verified execution
      resumes without a tracing session)
Bug: 211178923
Change-Id: I90e260fbc6f113e77d00f0c958551fb561babb4e
5 files changed