tracing: Log more user-friendly warning when tracing is uninitialized

If tracing is uninitialized and the user tries to use it, log a more
helpful error message instead of crashing on a null pointer dereference
somewhere deep in the the codebase.

To avoid introducing null checks to hot code paths, we instead introduce
a fake tracing muxer/platform which will explicitly fail all operations.
These fake objects will be replaced with real ones at initialization
time.

We also add a perfetto::Tracing::IsInitialized query to check if tracing
was initialized or not.

Note that data sources and TRACE_EVENT trace points will still silently
act as if tracing is disabled if the client library hasn't been
initialized. This is by design to avoid races during initialization
where it can be hard to guarantee no TRACE_EVENT is encountered before
Perfetto is initialized.

Change-Id: Iba1424f7040dda4d04da7b84752b1f4ad3b4d3b2
14 files changed
tree: f0d259069212cffc6ab1cb30484616399c619682
  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. .gitignore
  19. .gn
  20. .style.yapf
  21. Android.bp
  22. Android.bp.extras
  23. BUILD
  24. BUILD.extras
  25. BUILD.gn
  26. CHANGELOG
  27. codereview.settings
  28. heapprofd.rc
  29. LICENSE
  30. METADATA
  31. MODULE_LICENSE_APACHE2
  32. OWNERS
  33. perfetto.rc
  34. PRESUBMIT.py
  35. README.chromium
  36. README.md
  37. TEST_MAPPING
  38. traced_perf.rc
  39. 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.