tracing: Support multiple track event instances in one translation unit
This patch adds a set of macros for overriding the namespace in which
track event categories are defined:
PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE(
my_ns, perfetto::Category("my_cat"));
A second variant also allows specifying linkage attributes:
PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE_WITH_ATTRS(my_ns, attrs, ...);
This allows using the Perfetto SDK in an idempotent way, avoiding the
need to specify magic macros (e.g., PERFETTO_TRACK_EVENT_NAMESPACE)
before including the SDK headers. This is important for avoiding symbol
clashes in situations where two components of a single program are
independently using Perfetto, potentially in the same translation unit.
In most cases, TRACK_EVENT macros should automatically select the right
namespace for looking up categories. If needed, this can be overridden
in a global or namespace scope:
PERFETTO_USE_CATEGORIES_FROM_NAMESPACE(my_ns);
Or in a block-level scope:
PERFETTO_USE_CATEGORIES_FROM_NAMESPACE_SCOPED(my_ns);
TRACE_EVENT("my_cat", "...");
Design doc: https://docs.google.com/document/d/1SbrmKD0H7XEfdMiOIxYAU11couTACDXYvFtRUWNZSzY/edit#
Bug: b:234546493
Change-Id: Ib856d634f9dc1e233d0e710e3f5c500b0f2daf8b
diff --git a/Android.bp b/Android.bp
index 54ee44e..711595d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -10875,6 +10875,7 @@
"src/tracing/test/api_integrationtest_main.cc",
"src/tracing/test/tracing_module.cc",
"src/tracing/test/tracing_module2.cc",
+ "src/tracing/test/tracing_module3.cc",
],
}