From 481c549b29bab2e5314204884a117c9669846111 Mon Sep 17 00:00:00 2001 From: ehmaldonado Date: Thu, 17 Aug 2017 07:59:54 -0700 Subject: [PATCH] Reland of Make it possible for tests to set up trace event handlers. (patchset #1 id:1 of https://codereview.webrtc.org/2997963002/ ) Reason for revert: This should fix it Original issue's description: > Revert of Make it possible for tests to set up trace event handlers. (patchset #4 id:60001 of https://codereview.webrtc.org/3002663002/ ) > > Reason for revert: > Breaks Chromium bots. > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/27340/steps/generate_build_files/logs/stdio > > Original issue's description: > > Make it possible for tests to set up trace event handlers. > > > > As it is now, the first time a TRACE_EVENT... is called, the result from > > the current handler is stored in a static const variable, and subsequent > > calls will use that value regardless of changes to the handler. > > > > This is a problem if a test wants to use another handler. > > > > BUG=None > > > > Review-Url: https://codereview.webrtc.org/3002663002 > > Cr-Commit-Position: refs/heads/master@{#19382} > > Committed: https://chromium.googlesource.com/external/webrtc/+/a9732656221e0033ab93ecf01cf07f71817da1e8 > > TBR=hbos@webrtc.org,kwiberg@webrtc.org,mbonadei@webrtc.org,kjellander@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=None > > Review-Url: https://codereview.webrtc.org/2997963002 > Cr-Commit-Position: refs/heads/master@{#19383} > Committed: https://chromium.googlesource.com/external/webrtc/+/db758c2589a983a7dd94dfdd9272892e28251fe4 TBR=hbos@webrtc.org,kwiberg@webrtc.org,mbonadei@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=None Review-Url: https://codereview.webrtc.org/2995123002 Cr-Commit-Position: refs/heads/master@{#19386} --- webrtc/BUILD.gn | 13 ++++++++++++- webrtc/rtc_base/trace_event.h | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index 58b5f5e740..6d2c0e426c 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -26,8 +26,19 @@ config("common_inherited_config") { if (build_with_mozilla) { defines += [ "WEBRTC_MOZILLA_BUILD" ] } + # Some tests need to declare their own trace event handlers. If this define is + # not set, the first time TRACE_EVENT_* is called it will store the return + # value for the current handler in an static variable, so that subsequent + # changes to the handler for that TRACE_EVENT_* will be ignored. + # So when tests are included, we set this define, making it possible to use + # different event handlers in different tests. + if (rtc_include_tests) { + defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ] + } else { + defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ] + } if (build_with_chromium) { - defines = [ + defines += [ # TODO(kjellander): Cleanup unused ones and move defines closer to # the source when webrtc:4256 is completed. "FEATURE_ENABLE_VOICEMAIL", diff --git a/webrtc/rtc_base/trace_event.h b/webrtc/rtc_base/trace_event.h index 98f6afae94..6a1476d917 100644 --- a/webrtc/rtc_base/trace_event.h +++ b/webrtc/rtc_base/trace_event.h @@ -575,9 +575,15 @@ #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) +#if WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS +#define INTERNAL_TRACE_EVENT_INFO_TYPE const unsigned char* +#else +#define INTERNAL_TRACE_EVENT_INFO_TYPE static const unsigned char* +#endif // WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS + // Implementation detail: internal macro to create static category. #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ - static const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = \ + INTERNAL_TRACE_EVENT_INFO_TYPE INTERNAL_TRACE_EVENT_UID(catstatic) = \ TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); // Implementation detail: internal macro to create static category and add