From 5919d66cd1fc942e0ecf61fd6d9fbb26c1610b35 Mon Sep 17 00:00:00 2001 From: Gerald Squelart Date: Tue, 30 Apr 2019 01:41:19 +0000 Subject: [PATCH] Bug 1540114 - Select all defaults in MOZ_PROFILER_STARTUP_FEATURES with keyword "default" - r=mstange MOZ_PROFILER_FEATURES is mostly used to add features in addition to the defaults. This will now be easier, e.g.: `MOZ_PROFILER_STARTUP_FEATURES=default,screenshots` Differential Revision: https://phabricator.services.mozilla.com/D25532 --HG-- extra : moz-landing-system : lando --- tools/profiler/core/platform.cpp | 17 +++++++++++++---- tools/profiler/core/platform.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 48c9d1a26427..65e4fe6c1c50 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -2256,6 +2256,7 @@ static void PrintUsageThenExit(int aExitCode) { #undef PRINT_FEATURE printf( + " - \"default\" (All above D+S defaults)\n" "\n" " MOZ_PROFILER_STARTUP_FILTERS=\n" " If MOZ_PROFILER_STARTUP is set, specifies the thread filters, as a\n" @@ -2628,7 +2629,13 @@ GeckoProfilerReporter::CollectReports(nsIHandleReportCallback* aHandleReport, NS_IMPL_ISUPPORTS(GeckoProfilerReporter, nsIMemoryReporter) -static uint32_t ParseFeature(const char* aFeature) { +static uint32_t ParseFeature(const char* aFeature, bool aIsStartup) { + if (strcmp(aFeature, "default") == 0) { + return (aIsStartup ? (DefaultFeatures() | StartupExtraDefaultFeatures()) + : DefaultFeatures()) & + AvailableFeatures(); + } + #define PARSE_FEATURE_BIT(n_, str_, Name_, desc_) \ if (strcmp(aFeature, str_) == 0) { \ return ProfilerFeature::Name_; \ @@ -2644,10 +2651,11 @@ static uint32_t ParseFeature(const char* aFeature) { } uint32_t ParseFeaturesFromStringArray(const char** aFeatures, - uint32_t aFeatureCount) { + uint32_t aFeatureCount, + bool aIsStartup /* = false */) { uint32_t features = 0; for (size_t i = 0; i < aFeatureCount; i++) { - features |= ParseFeature(aFeatures[i]); + features |= ParseFeature(aFeatures[i], aIsStartup); } return features; } @@ -2927,7 +2935,8 @@ void profiler_init(void* aStackTop) { Vector featureStringArray = SplitAtCommas(startupFeatures, featureStringStorage); features = ParseFeaturesFromStringArray(featureStringArray.begin(), - featureStringArray.length()); + featureStringArray.length(), + /* aIsStartup */ true); LOG("- MOZ_PROFILER_STARTUP_FEATURES = %d", features); } } diff --git a/tools/profiler/core/platform.h b/tools/profiler/core/platform.h index 35d5f89d66cb..9c3d08eb3f58 100644 --- a/tools/profiler/core/platform.h +++ b/tools/profiler/core/platform.h @@ -111,7 +111,8 @@ void AppendSharedLibraries(mozilla::JSONWriter& aWriter); // Convert the array of strings to a bitfield. uint32_t ParseFeaturesFromStringArray(const char** aFeatures, - uint32_t aFeatureCount); + uint32_t aFeatureCount, + bool aIsStartup = false); void profiler_get_profile_json_into_lazily_allocated_buffer( const std::function& aAllocator, double aSinceTime,