Fix 'weak-vtables' warning in TrackEvent

warning: 'TrackEvent' has no out-of-line virtual method definitions;
its vtable will be emitted in every translation unit [-Wweak-vtables]

This warning can be reproduced by compiling example.cc using
clang compiler that supports `-Wweak-vtables` warning. It was
suppressed earlier by supplying
`configs -= [ "//gn/standalone:extra_warnings" ]` option in
`examples/sdk/BUILD.gn`.

The root cause of this warning is demonstrated in CL aosp/2019905

Note that this warning is NOT serious because linker will anyway merge
those vtable into a single vtable. i.e. duplicated vtable won't increase
the size of final executable.

The root cause is, `TrackEvent` don't have any non-inline virtual
function. So compiler cannot decide where to place vtable.

Itanium CXX ABI, section 5.2.3:

The virtual table for a class is emitted in the same object containing
the definition of its key function, i.e. the first non-pure virtual
function that is not inline at the point of class definition. If there
is no key function, it is emitted everywhere used. The emitted virtual
table includes the full virtual table group for the class, any new
construction virtual tables required for subobjects, and the VTT for
the class. They are emitted in a COMDAT group, with the virtual table
mangled name as the identifying symbol. Note that if the key function
is not declared inline in the class definition, but its definition later
is always declared inline, it will be emitted in every object containing
the definition.
NOTE: In the abstract, a pure virtual destructor could be used as the
key function, as it must be defined even though it is pure. However,
the ABI committee did not realize this fact until after the
specification of key function was complete; therefore a pure virtual
destructor cannot be the key function.

Ref: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable

Change-Id: I29f3308bdb91b135e3cc91c3a0a3d60dc3de4d86
3 files changed
tree: a0ffc347e02f784a0e047776c2e8a73b59940af4
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. python/
  13. src/
  14. test/
  15. tools/
  16. ui/
  17. .clang-format
  18. .clang-tidy
  19. .gitattributes
  20. .gitignore
  21. .gn
  22. .style.yapf
  23. Android.bp
  24. Android.bp.extras
  25. BUILD
  26. BUILD.extras
  27. BUILD.gn
  28. CHANGELOG
  29. codereview.settings
  30. DIR_METADATA
  31. heapprofd.rc
  32. LICENSE
  33. meson.build
  34. METADATA
  35. MODULE_LICENSE_APACHE2
  36. OWNERS
  37. perfetto.rc
  38. PerfettoIntegrationTests.xml
  39. PRESUBMIT.py
  40. README.chromium
  41. README.md
  42. TEST_MAPPING
  43. traced_perf.rc
  44. 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.