commit | f43f2d5ddbb73f90fce16046fa19db4d122d7930 | [log] [tgz] |
---|---|---|
author | Daniele Di Proietto <ddiproietto@google.com> | Thu Mar 21 18:52:56 2024 +0000 |
committer | Daniele Di Proietto <ddiproietto@google.com> | Fri Mar 22 11:21:29 2024 +0000 |
tree | 502f12296163e59bbed440116035f53aaf53ace9 | |
parent | f51864ac82ce371f1c639f298452645e8cbd57e7 [diff] |
track_event: Refuse to compile with possibly dynamic strings https://perfetto.dev/docs/instrumentation/track-events#dynamic-event-names says: ``` Ideally all event name should be compile time string constants. [...] If we pass a dynamic string here, we will get compile time static_assert failure ``` This used to be true before 3a1ed6fb6ab8("Add TraceForCategory* methods for legacy macros"), but in that commit we broke the static_assert mechanism (2023-03-20). Inside PERFETTO_INTERNAL_TRACK_EVENT_WITH_METHOD, there's a ::perfetto::internal::ValidateEventNameType that's supposed to check if the event name makes sense (either compile time constant or dynamic string). The problem is that we call DecayEventNameType() before calling PERFETTO_INTERNAL_TRACK_EVENT_WITH_METHOD, so ::perfetto::internal::ValidateEventNameType only sees the decayed type. This commit restores the mechanism for non legacy macro. For legacy macros we have a test with: ``` TRACE_EVENT_BEGIN0("test", i % 2 ? "Odd" : "Even") ``` Which would break the static_assert. I guess legacy macros didn't have that protection. For legacy macro we end up calling DecayEventNameType twice, but that shouldn't be a problem. Change-Id: I4c43fcce5d154405ea60388a95a34b9fd9b0fb24
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.