From 6725e6df9af305609bf9b9ce614f0aa152e143d4 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 5 May 2020 21:44:11 +0000 Subject: [PATCH] Bug 1634784 - Remove MOZ_BASE_PROFILER and replace it with MOZ_GECKO_PROFILER everywhere. r=gerald Differential Revision: https://phabricator.services.mozilla.com/D73526 --- mozglue/android/APKOpen.cpp | 2 +- mozglue/baseprofiler/core/EHABIStackWalk.cpp | 4 +- mozglue/baseprofiler/core/PageInformation.cpp | 4 +- mozglue/baseprofiler/core/ProfileBuffer.cpp | 4 +- .../baseprofiler/core/ProfileBufferEntry.cpp | 4 +- .../baseprofiler/core/ProfileJSONWriter.cpp | 4 +- .../baseprofiler/core/ProfiledThreadData.cpp | 4 +- .../baseprofiler/core/ProfilerBacktrace.cpp | 4 +- .../core/ProfilerMarkerPayload.cpp | 4 +- .../baseprofiler/core/ProfilingCategory.cpp | 4 +- mozglue/baseprofiler/core/ProfilingStack.cpp | 4 +- .../baseprofiler/core/RegisteredThread.cpp | 4 +- mozglue/baseprofiler/core/VTuneProfiler.cpp | 4 +- mozglue/baseprofiler/core/platform.cpp | 4 +- .../core/shared-libraries-linux.cc | 4 +- .../core/shared-libraries-macos.cc | 4 +- .../core/shared-libraries-win32.cc | 4 +- mozglue/baseprofiler/lul/AutoObjectMapper.cpp | 4 +- mozglue/baseprofiler/lul/LulCommon.cpp | 4 +- mozglue/baseprofiler/lul/LulDwarf.cpp | 4 +- .../baseprofiler/lul/LulDwarfSummariser.cpp | 4 +- mozglue/baseprofiler/lul/LulElf.cpp | 4 +- mozglue/baseprofiler/lul/LulMain.cpp | 4 +- .../baseprofiler/lul/platform-linux-lul.cpp | 4 +- mozglue/baseprofiler/moz.build | 5 +- .../public/BaseProfileJSONWriter.h | 4 +- mozglue/baseprofiler/public/BaseProfiler.h | 21 +++----- .../baseprofiler/public/BaseProfilerCounts.h | 4 +- .../baseprofiler/public/BaseProfilerDetail.h | 6 +-- .../public/BaseProfilerMarkerPayload.h | 4 +- .../public/BaseProfilerSharedLibraries.h | 4 +- .../public/BaseProfilingCategory.h | 4 +- .../baseprofiler/public/BaseProfilingStack.h | 4 +- mozglue/dllservices/WindowsDllBlocklist.cpp | 2 +- mozglue/tests/TestBaseProfiler.cpp | 18 +++---- tools/profiler/core/platform-win32.cpp | 48 +------------------ tools/profiler/core/platform.cpp | 18 ------- tools/profiler/tests/gtest/GeckoProfiler.cpp | 2 - 38 files changed, 83 insertions(+), 155 deletions(-) diff --git a/mozglue/android/APKOpen.cpp b/mozglue/android/APKOpen.cpp index ffc90050e0f9..c009f2ff3855 100644 --- a/mozglue/android/APKOpen.cpp +++ b/mozglue/android/APKOpen.cpp @@ -202,7 +202,7 @@ static void EnsureBaseProfilerInitialized() { return; } -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER // The stack depth we observe here will be determined by the stack of // whichever caller enters this code first. In practice this means that we may // miss some root-most frames, which hopefully shouldn't ruin profiling. diff --git a/mozglue/baseprofiler/core/EHABIStackWalk.cpp b/mozglue/baseprofiler/core/EHABIStackWalk.cpp index 60873ee9f805..fbbc0299757c 100644 --- a/mozglue/baseprofiler/core/EHABIStackWalk.cpp +++ b/mozglue/baseprofiler/core/EHABIStackWalk.cpp @@ -24,7 +24,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "EHABIStackWalk.h" @@ -645,4 +645,4 @@ EHState::EHState(const mcontext_t& context) { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/PageInformation.cpp b/mozglue/baseprofiler/core/PageInformation.cpp index 8a028915dc5c..8f8a2aa7c6b1 100644 --- a/mozglue/baseprofiler/core/PageInformation.cpp +++ b/mozglue/baseprofiler/core/PageInformation.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "PageInformation.h" @@ -51,4 +51,4 @@ size_t PageInformation::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfileBuffer.cpp b/mozglue/baseprofiler/core/ProfileBuffer.cpp index 8303bc3cd131..affce3a8427a 100644 --- a/mozglue/baseprofiler/core/ProfileBuffer.cpp +++ b/mozglue/baseprofiler/core/ProfileBuffer.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "ProfileBuffer.h" @@ -208,4 +208,4 @@ void ProfileBufferCollector::CollectProfilingStackFrame( } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfileBufferEntry.cpp b/mozglue/baseprofiler/core/ProfileBufferEntry.cpp index 68d70412f0c2..0966f1b5a217 100644 --- a/mozglue/baseprofiler/core/ProfileBufferEntry.cpp +++ b/mozglue/baseprofiler/core/ProfileBufferEntry.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "ProfileBufferEntry.h" @@ -1377,4 +1377,4 @@ void ProfileBuffer::DiscardSamplesBeforeTime(double aTime) { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfileJSONWriter.cpp b/mozglue/baseprofiler/core/ProfileJSONWriter.cpp index d13f88deba89..da6b2dadf414 100644 --- a/mozglue/baseprofiler/core/ProfileJSONWriter.cpp +++ b/mozglue/baseprofiler/core/ProfileJSONWriter.cpp @@ -5,7 +5,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfileJSONWriter.h" @@ -129,4 +129,4 @@ void SpliceableChunkedJSONWriter::TakeAndSplice(ChunkedJSONWriteFunc* aFunc) { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfiledThreadData.cpp b/mozglue/baseprofiler/core/ProfiledThreadData.cpp index 964b1e2a2963..6cef72fb91f8 100644 --- a/mozglue/baseprofiler/core/ProfiledThreadData.cpp +++ b/mozglue/baseprofiler/core/ProfiledThreadData.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "ProfiledThreadData.h" @@ -171,4 +171,4 @@ void StreamSamplesAndMarkers(const char* aName, int aThreadId, } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfilerBacktrace.cpp b/mozglue/baseprofiler/core/ProfilerBacktrace.cpp index b86db702b81c..757340a5f509 100644 --- a/mozglue/baseprofiler/core/ProfilerBacktrace.cpp +++ b/mozglue/baseprofiler/core/ProfilerBacktrace.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "ProfilerBacktrace.h" @@ -80,4 +80,4 @@ ProfileBufferEntryReader:: } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfilerMarkerPayload.cpp b/mozglue/baseprofiler/core/ProfilerMarkerPayload.cpp index 679f9385ff13..af1c5116cf30 100644 --- a/mozglue/baseprofiler/core/ProfilerMarkerPayload.cpp +++ b/mozglue/baseprofiler/core/ProfilerMarkerPayload.cpp @@ -5,7 +5,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfilerMarkerPayload.h" @@ -543,4 +543,4 @@ void LongTaskMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter, } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfilingCategory.cpp b/mozglue/baseprofiler/core/ProfilingCategory.cpp index 7a79ed352a3d..c96ba2da73f9 100644 --- a/mozglue/baseprofiler/core/ProfilingCategory.cpp +++ b/mozglue/baseprofiler/core/ProfilingCategory.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfilingCategory.h" @@ -72,4 +72,4 @@ const ProfilingCategoryPairInfo& GetProfilingCategoryPairInfo( } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/ProfilingStack.cpp b/mozglue/baseprofiler/core/ProfilingStack.cpp index 154877c54abc..35aed26dfb9c 100644 --- a/mozglue/baseprofiler/core/ProfilingStack.cpp +++ b/mozglue/baseprofiler/core/ProfilingStack.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfilingStack.h" @@ -53,4 +53,4 @@ void ProfilingStack::ensureCapacitySlow() { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/RegisteredThread.cpp b/mozglue/baseprofiler/core/RegisteredThread.cpp index c3f9c46f84fe..92d750c97884 100644 --- a/mozglue/baseprofiler/core/RegisteredThread.cpp +++ b/mozglue/baseprofiler/core/RegisteredThread.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "RegisteredThread.h" @@ -44,4 +44,4 @@ size_t RegisteredThread::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/VTuneProfiler.cpp b/mozglue/baseprofiler/core/VTuneProfiler.cpp index 6c18d16efa6c..0c2891e97fc7 100644 --- a/mozglue/baseprofiler/core/VTuneProfiler.cpp +++ b/mozglue/baseprofiler/core/VTuneProfiler.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # ifdef XP_WIN # undef UNICODE @@ -93,4 +93,4 @@ void VTuneProfiler::RegisterThreadInternal(const char* aName) { } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/platform.cpp b/mozglue/baseprofiler/core/platform.cpp index f60585adeb25..23c226e43b9f 100644 --- a/mozglue/baseprofiler/core/platform.cpp +++ b/mozglue/baseprofiler/core/platform.cpp @@ -28,7 +28,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "platform.h" @@ -3584,4 +3584,4 @@ void profiler_suspend_and_sample_thread(int aThreadId, uint32_t aFeatures, } // namespace baseprofiler } // namespace mozilla -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/shared-libraries-linux.cc b/mozglue/baseprofiler/core/shared-libraries-linux.cc index 939a19dbd99b..008c166da7bf 100644 --- a/mozglue/baseprofiler/core/shared-libraries-linux.cc +++ b/mozglue/baseprofiler/core/shared-libraries-linux.cc @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfilerSharedLibraries.h" @@ -850,4 +850,4 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf() { void SharedLibraryInfo::Initialize() { /* do nothing */ } -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/shared-libraries-macos.cc b/mozglue/baseprofiler/core/shared-libraries-macos.cc index cb0041bf851c..c02291ce3c80 100644 --- a/mozglue/baseprofiler/core/shared-libraries-macos.cc +++ b/mozglue/baseprofiler/core/shared-libraries-macos.cc @@ -5,7 +5,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfilerSharedLibraries.h" @@ -185,4 +185,4 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf() { return sharedLibraryInfo; } -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/core/shared-libraries-win32.cc b/mozglue/baseprofiler/core/shared-libraries-win32.cc index 2758e3719f9d..fd9a2b9d9493 100644 --- a/mozglue/baseprofiler/core/shared-libraries-win32.cc +++ b/mozglue/baseprofiler/core/shared-libraries-win32.cc @@ -5,7 +5,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include # include @@ -238,4 +238,4 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf() { void SharedLibraryInfo::Initialize() { /* do nothing */ } -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/AutoObjectMapper.cpp b/mozglue/baseprofiler/lul/AutoObjectMapper.cpp index c9f164cec664..f8cf2f00145d 100644 --- a/mozglue/baseprofiler/lul/AutoObjectMapper.cpp +++ b/mozglue/baseprofiler/lul/AutoObjectMapper.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include # include @@ -153,4 +153,4 @@ bool AutoObjectMapperFaultyLib::Map(/*OUT*/ void** start, # endif // defined(MOZ_LINKER) -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/LulCommon.cpp b/mozglue/baseprofiler/lul/LulCommon.cpp index 824c7b040d98..bdb63786555f 100644 --- a/mozglue/baseprofiler/lul/LulCommon.cpp +++ b/mozglue/baseprofiler/lul/LulCommon.cpp @@ -39,7 +39,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER // There's no internal-only interface for LulCommon. Hence include // the external interface directly. @@ -103,4 +103,4 @@ const UniqueString* UniqueStringUniverse::ToUniqueString(string str) { } // namespace lul -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/LulDwarf.cpp b/mozglue/baseprofiler/lul/LulDwarf.cpp index cf048380f791..dfa7730fe180 100644 --- a/mozglue/baseprofiler/lul/LulDwarf.cpp +++ b/mozglue/baseprofiler/lul/LulDwarf.cpp @@ -43,7 +43,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include # include @@ -2255,4 +2255,4 @@ void DwarfCFIToModule::Reporter::ExpressionCouldNotBeSummarised( } // namespace lul -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/LulDwarfSummariser.cpp b/mozglue/baseprofiler/lul/LulDwarfSummariser.cpp index 3cdce50baadc..0ec2a9787d54 100644 --- a/mozglue/baseprofiler/lul/LulDwarfSummariser.cpp +++ b/mozglue/baseprofiler/lul/LulDwarfSummariser.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "LulDwarfSummariser.h" @@ -556,4 +556,4 @@ void Summariser::End() { } // namespace lul -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/LulElf.cpp b/mozglue/baseprofiler/lul/LulElf.cpp index 78a343c69f44..e8ac7db42b86 100644 --- a/mozglue/baseprofiler/lul/LulElf.cpp +++ b/mozglue/baseprofiler/lul/LulElf.cpp @@ -47,7 +47,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include # include @@ -875,4 +875,4 @@ void FileID::ConvertIdentifierToString(const uint8_t identifier[kMDGUIDSize], } // namespace lul -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/LulMain.cpp b/mozglue/baseprofiler/lul/LulMain.cpp index db8900087d43..a46d14e86759 100644 --- a/mozglue/baseprofiler/lul/LulMain.cpp +++ b/mozglue/baseprofiler/lul/LulMain.cpp @@ -6,7 +6,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "LulMain.h" @@ -1959,4 +1959,4 @@ void RunLulUnitTests(/*OUT*/ int* aNTests, /*OUT*/ int* aNTestsPassed, } // namespace lul -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/lul/platform-linux-lul.cpp b/mozglue/baseprofiler/lul/platform-linux-lul.cpp index f9b9f6b24d29..f131e4777bed 100644 --- a/mozglue/baseprofiler/lul/platform-linux-lul.cpp +++ b/mozglue/baseprofiler/lul/platform-linux-lul.cpp @@ -5,7 +5,7 @@ #include "BaseProfiler.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include # include @@ -83,4 +83,4 @@ void logging_sink_for_LUL(const char* str) { // VERBOSE_LOG("[%d] %s", profiler_current_process_id(), str); } -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER diff --git a/mozglue/baseprofiler/moz.build b/mozglue/baseprofiler/moz.build index ca38f17be4d1..358b2de34d35 100644 --- a/mozglue/baseprofiler/moz.build +++ b/mozglue/baseprofiler/moz.build @@ -74,8 +74,9 @@ if CONFIG['MOZ_GECKO_PROFILER']: FINAL_LIBRARY = 'mozglue' -# BaseProfiler.h and BaseProfilerCounts.h are the only headers that are usable -# in non-MOZ_GECKO_PROFILER builds, and they only contains no-op macros in that +# Many of the headers in this directory are usable in non-MOZ_GECKO_PROFILER +# builds. +# BaseProfiler.h and BaseProfilerCounts.h only contain no-op macros in that # case. EXPORTS += [ 'public/BaseProfiler.h', diff --git a/mozglue/baseprofiler/public/BaseProfileJSONWriter.h b/mozglue/baseprofiler/public/BaseProfileJSONWriter.h index fa1f0d40cb36..06f2ded8c14d 100644 --- a/mozglue/baseprofiler/public/BaseProfileJSONWriter.h +++ b/mozglue/baseprofiler/public/BaseProfileJSONWriter.h @@ -8,8 +8,8 @@ #include "BaseProfiler.h" -#ifndef MOZ_BASE_PROFILER -# error Do not #include this header when MOZ_BASE_PROFILER is not #defined. +#ifndef MOZ_GECKO_PROFILER +# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined. #endif #include "mozilla/JSONWriter.h" diff --git a/mozglue/baseprofiler/public/BaseProfiler.h b/mozglue/baseprofiler/public/BaseProfiler.h index 01e22b1f7483..fcca83f89b01 100644 --- a/mozglue/baseprofiler/public/BaseProfiler.h +++ b/mozglue/baseprofiler/public/BaseProfiler.h @@ -16,24 +16,17 @@ #ifndef BaseProfiler_h #define BaseProfiler_h -// Everything in here is also safe to include unconditionally, and only defines -// empty macros if MOZ_GECKO_PROFILER or MOZ_BASE_PROFILER is unset. - -// MOZ_BASE_PROFILER is #defined (or not) in this header, so it should be -// #included wherever Base Profiler may be used. - -#ifdef MOZ_GECKO_PROFILER -# define MOZ_BASE_PROFILER -#endif // MOZ_GECKO_PROFILER +// This file is safe to include unconditionally, and only defines +// empty macros if MOZ_GECKO_PROFILER is not set. // BaseProfilerCounts.h is also safe to include unconditionally, with empty -// macros if MOZ_BASE_PROFILER is unset. +// macros if MOZ_GECKO_PROFILER is not set. #include "mozilla/BaseProfilerCounts.h" -#ifndef MOZ_BASE_PROFILER +#ifndef MOZ_GECKO_PROFILER // This file can be #included unconditionally. However, everything within this -// file must be guarded by a #ifdef MOZ_BASE_PROFILER, *except* for the +// file must be guarded by a #ifdef MOZ_GECKO_PROFILER, *except* for the // following macros, which encapsulate the most common operations and thus // avoid the need for many #ifdefs. @@ -67,7 +60,7 @@ # define AUTO_PROFILER_STATS(name) -#else // !MOZ_BASE_PROFILER +#else // !MOZ_GECKO_PROFILER # include "BaseProfilingStack.h" @@ -1030,6 +1023,6 @@ MFBT_API void GetProfilerEnvVarsForChildProcess( } // namespace baseprofiler } // namespace mozilla -#endif // !MOZ_BASE_PROFILER +#endif // !MOZ_GECKO_PROFILER #endif // BaseProfiler_h diff --git a/mozglue/baseprofiler/public/BaseProfilerCounts.h b/mozglue/baseprofiler/public/BaseProfilerCounts.h index aa149727def3..fbcc713744a3 100644 --- a/mozglue/baseprofiler/public/BaseProfilerCounts.h +++ b/mozglue/baseprofiler/public/BaseProfilerCounts.h @@ -7,7 +7,7 @@ #ifndef BaseProfilerCounts_h #define BaseProfilerCounts_h -#ifndef MOZ_BASE_PROFILER +#ifndef MOZ_GECKO_PROFILER # define BASE_PROFILER_DEFINE_COUNT_TOTAL(label, category, description) # define BASE_PROFILER_DEFINE_COUNT(label, category, description) @@ -275,6 +275,6 @@ class ProfilerCounterTotal final : public BaseProfilerCount { } // namespace baseprofiler } // namespace mozilla -#endif // !MOZ_BASE_PROFILER +#endif // !MOZ_GECKO_PROFILER #endif // BaseProfilerCounts_h diff --git a/mozglue/baseprofiler/public/BaseProfilerDetail.h b/mozglue/baseprofiler/public/BaseProfilerDetail.h index 2f13ca31b73a..c914041d55f9 100644 --- a/mozglue/baseprofiler/public/BaseProfilerDetail.h +++ b/mozglue/baseprofiler/public/BaseProfilerDetail.h @@ -14,12 +14,12 @@ #ifdef DEBUG # include "BaseProfiler.h" -# ifdef MOZ_BASE_PROFILER +# ifdef MOZ_GECKO_PROFILER # include "mozilla/Atomics.h" // When #defined, safety-checking code is added. By default: DEBUG builds, -// and we need `MOZ_BASE_PROFILER` to use `profiler_current_thread_id()`. +// and we need `MOZ_GECKO_PROFILER` to use `profiler_current_thread_id()`. # define MOZ_BASE_PROFILER_DEBUG -# endif // MOZ_BASE_PROFILER +# endif // MOZ_GECKO_PROFILER #endif // DEBUG namespace mozilla { diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkerPayload.h b/mozglue/baseprofiler/public/BaseProfilerMarkerPayload.h index 57c4a8aaab55..81fea4546990 100644 --- a/mozglue/baseprofiler/public/BaseProfilerMarkerPayload.h +++ b/mozglue/baseprofiler/public/BaseProfilerMarkerPayload.h @@ -9,8 +9,8 @@ #include "BaseProfiler.h" -#ifndef MOZ_BASE_PROFILER -# error Do not #include this header when MOZ_BASE_PROFILER is not #defined. +#ifndef MOZ_GECKO_PROFILER +# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined. #endif #include "mozilla/Atomics.h" diff --git a/mozglue/baseprofiler/public/BaseProfilerSharedLibraries.h b/mozglue/baseprofiler/public/BaseProfilerSharedLibraries.h index d301b62431ff..0a104193c394 100644 --- a/mozglue/baseprofiler/public/BaseProfilerSharedLibraries.h +++ b/mozglue/baseprofiler/public/BaseProfilerSharedLibraries.h @@ -9,8 +9,8 @@ #include "BaseProfiler.h" -#ifndef MOZ_BASE_PROFILER -# error Do not #include this header when MOZ_BASE_PROFILER is not #defined. +#ifndef MOZ_GECKO_PROFILER +# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined. #endif #include diff --git a/mozglue/baseprofiler/public/BaseProfilingCategory.h b/mozglue/baseprofiler/public/BaseProfilingCategory.h index f7452c9ec154..41ea573f5e75 100644 --- a/mozglue/baseprofiler/public/BaseProfilingCategory.h +++ b/mozglue/baseprofiler/public/BaseProfilingCategory.h @@ -9,8 +9,8 @@ #include "BaseProfiler.h" -#ifndef MOZ_BASE_PROFILER -# error Do not #include this header when MOZ_BASE_PROFILER is not #defined. +#ifndef MOZ_GECKO_PROFILER +# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined. #endif #include "mozilla/Types.h" diff --git a/mozglue/baseprofiler/public/BaseProfilingStack.h b/mozglue/baseprofiler/public/BaseProfilingStack.h index 54ad5c03a0c2..f2738aa14c59 100644 --- a/mozglue/baseprofiler/public/BaseProfilingStack.h +++ b/mozglue/baseprofiler/public/BaseProfilingStack.h @@ -13,8 +13,8 @@ #include "BaseProfiler.h" -#ifndef MOZ_BASE_PROFILER -# error Do not #include this header when MOZ_BASE_PROFILER is not #defined. +#ifndef MOZ_GECKO_PROFILER +# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined. #endif #include diff --git a/mozglue/dllservices/WindowsDllBlocklist.cpp b/mozglue/dllservices/WindowsDllBlocklist.cpp index 30fd2294908a..96ddbb74fb34 100644 --- a/mozglue/dllservices/WindowsDllBlocklist.cpp +++ b/mozglue/dllservices/WindowsDllBlocklist.cpp @@ -638,7 +638,7 @@ MFBT_API void DllBlocklist_Initialize(uint32_t aInitFlags) { // cases, it's ok not to check user32.dll in this scenario. const bool skipUser32Check = (sInitFlags & eDllBlocklistInitFlagWasBootstrapped) -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER || (!IsWin10AnniversaryUpdateOrLater() && baseprofiler::profiler_is_active()) #endif diff --git a/mozglue/tests/TestBaseProfiler.cpp b/mozglue/tests/TestBaseProfiler.cpp index deb32053b6b7..e825848ea3fa 100644 --- a/mozglue/tests/TestBaseProfiler.cpp +++ b/mozglue/tests/TestBaseProfiler.cpp @@ -16,10 +16,10 @@ #include "mozilla/ProfileChunkedBuffer.h" #include "mozilla/Vector.h" -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER # include "BaseProfileJSONWriter.h" # include "BaseProfilerMarkerPayload.h" -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER #if defined(_MSC_VER) || defined(__MINGW32__) # include @@ -2530,7 +2530,7 @@ void TestProfilerDependencies() { TestBlocksRingBufferSerialization(); } -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER class BaseTestMarkerPayload : public baseprofiler::ProfilerMarkerPayload { public: @@ -2855,10 +2855,10 @@ void TestProfiler() { printf("TestProfiler done\n"); } -#else // MOZ_BASE_PROFILER +#else // MOZ_GECKO_PROFILER // Testing that macros are still #defined (but do nothing) when -// MOZ_BASE_PROFILER is disabled. +// MOZ_GECKO_PROFILER is disabled. void TestProfiler() { // These don't need to make sense, we just want to know that they're defined // and don't do anything. @@ -2872,7 +2872,7 @@ void TestProfiler() { AUTO_BASE_PROFILER_THREAD_SLEEP; } -#endif // MOZ_BASE_PROFILER else +#endif // MOZ_GECKO_PROFILER else #if defined(XP_WIN) int wmain() @@ -2880,18 +2880,18 @@ int wmain() int main() #endif // defined(XP_WIN) { -#ifdef MOZ_BASE_PROFILER +#ifdef MOZ_GECKO_PROFILER printf("BaseTestProfiler -- pid: %d, tid: %d\n", baseprofiler::profiler_current_process_id(), baseprofiler::profiler_current_thread_id()); // ::SleepMilli(10000); -#endif // MOZ_BASE_PROFILER +#endif // MOZ_GECKO_PROFILER // Always run tests that don't involve the profiler directly. TestProfilerDependencies(); // Note that there are two `TestProfiler` functions above, depending on - // whether MOZ_BASE_PROFILER is #defined. + // whether MOZ_GECKO_PROFILER is #defined. TestProfiler(); return 0; diff --git a/tools/profiler/core/platform-win32.cpp b/tools/profiler/core/platform-win32.cpp index 95d3fdc2f44f..698494836521 100644 --- a/tools/profiler/core/platform-win32.cpp +++ b/tools/profiler/core/platform-win32.cpp @@ -288,52 +288,7 @@ void Registers::SyncPopulate() { #if defined(GP_PLAT_amd64_windows) -# ifndef MOZ_BASE_PROFILER -// If MOZ_BASE_PROFILER is *not* #defined, we need to implement this here, as -// the one in mozglue/baseprofiler will not even be built. -static WindowsDllInterceptor NtDllIntercept; - -typedef NTSTATUS(NTAPI* LdrUnloadDll_func)(HMODULE module); -static WindowsDllInterceptor::FuncHookType stub_LdrUnloadDll; - -static NTSTATUS NTAPI patched_LdrUnloadDll(HMODULE module) { - // Prevent the stack walker from suspending this thread when LdrUnloadDll - // holds the RtlLookupFunctionEntry lock. - AutoSuppressStackWalking suppress; - return stub_LdrUnloadDll(module); -} - -// These pointers are disguised as PVOID to avoid pulling in obscure headers -typedef PVOID(WINAPI* LdrResolveDelayLoadedAPI_func)( - PVOID ParentModuleBase, PVOID DelayloadDescriptor, PVOID FailureDllHook, - PVOID FailureSystemHook, PVOID ThunkAddress, ULONG Flags); -static WindowsDllInterceptor::FuncHookType - stub_LdrResolveDelayLoadedAPI; - -static PVOID WINAPI patched_LdrResolveDelayLoadedAPI( - PVOID ParentModuleBase, PVOID DelayloadDescriptor, PVOID FailureDllHook, - PVOID FailureSystemHook, PVOID ThunkAddress, ULONG Flags) { - // Prevent the stack walker from suspending this thread when - // LdrResolveDelayLoadAPI holds the RtlLookupFunctionEntry lock. - AutoSuppressStackWalking suppress; - return stub_LdrResolveDelayLoadedAPI(ParentModuleBase, DelayloadDescriptor, - FailureDllHook, FailureSystemHook, - ThunkAddress, Flags); -} - -void InitializeWin64ProfilerHooks() { - NtDllIntercept.Init("ntdll.dll"); - stub_LdrUnloadDll.Set(NtDllIntercept, "LdrUnloadDll", &patched_LdrUnloadDll); - if (IsWin8OrLater()) { // LdrResolveDelayLoadedAPI was introduced in Win8 - stub_LdrResolveDelayLoadedAPI.Set(NtDllIntercept, - "LdrResolveDelayLoadedAPI", - &patched_LdrResolveDelayLoadedAPI); - } -} - -# else // ndef MOZ_BASE_PROFILER -// If MOZ_BASE_PROFILER is #defined, we just use InitializeWin64ProfilerHooks -// that it implements. +// Use InitializeWin64ProfilerHooks from the base profiler. namespace mozilla { namespace baseprofiler { @@ -343,5 +298,4 @@ MFBT_API void InitializeWin64ProfilerHooks(); using mozilla::baseprofiler::InitializeWin64ProfilerHooks; -# endif // ndef MOZ_BASE_PROFILER else #endif // defined(GP_PLAT_amd64_windows) diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 7ff344147186..40bb1bc20772 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -1132,7 +1132,6 @@ class ActivePS { MOZ_ASSERT(sInstance); uint64_t bufferRangeStart = sInstance->mProfileBuffer.BufferRangeStart(); // Discard exit profiles that were gathered before our buffer RangeStart. -#ifdef MOZ_BASE_PROFILER // If we have started to overwrite our data from when the Base profile was // added, we should get rid of that Base profile because it's now older than // our oldest Gecko profile data. @@ -1159,14 +1158,12 @@ class ActivePS { sInstance->mBaseProfileThreads.get()); sInstance->mBaseProfileThreads.reset(); } -#endif sInstance->mExitProfiles.eraseIf( [bufferRangeStart](const ExitProfile& aExitProfile) { return aExitProfile.mBufferPositionAtGatherTime < bufferRangeStart; }); } -#ifdef MOZ_BASE_PROFILER static void AddBaseProfileThreads(PSLockRef aLock, UniquePtr aBaseProfileThreads) { MOZ_ASSERT(sInstance); @@ -1186,7 +1183,6 @@ class ActivePS { sInstance->mBaseProfileThreads.get()); return std::move(sInstance->mBaseProfileThreads); } -#endif static void AddExitProfile(PSLockRef aLock, const nsCString& aExitProfile) { MOZ_ASSERT(sInstance); @@ -1293,11 +1289,9 @@ class ActivePS { bool mWasPaused; #endif -#ifdef MOZ_BASE_PROFILER // Optional startup profile thread array from BaseProfiler. UniquePtr mBaseProfileThreads; ProfileBufferBlockIndex mGeckoIndexWhenBaseProfileAdded; -#endif struct ExitProfile { nsCString mJSON; @@ -2570,13 +2564,11 @@ static void locked_profiler_stream_json_for_this_process( } #endif -#ifdef MOZ_BASE_PROFILER UniquePtr baseProfileThreads = ActivePS::MoveBaseProfileThreads(aLock); if (baseProfileThreads) { aWriter.Splice(baseProfileThreads.get()); } -#endif } aWriter.EndArray(); @@ -2660,9 +2652,7 @@ static void PrintUsageThenExit(int aExitCode) { "\n" " MOZ_PROFILER_HELP\n" " If set to any value, prints this message.\n" -#ifdef MOZ_BASE_PROFILER " Use MOZ_BASE_PROFILER_HELP for BaseProfiler help.\n" -#endif "\n" " MOZ_LOG\n" " Enables logging. The levels of logging available are\n" @@ -4001,7 +3991,6 @@ void GetProfilerEnvVarsForChildProcess( } aSetEnv("MOZ_PROFILER_STARTUP_FILTERS", filtersString.c_str()); -#ifdef MOZ_BASE_PROFILER // Blindly copy MOZ_BASE_PROFILER_STARTUP* env-vars. auto copyEnv = [&](const char* aName) { const char* env = getenv(aName); @@ -4017,7 +4006,6 @@ void GetProfilerEnvVarsForChildProcess( copyEnv("MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD"); copyEnv("MOZ_BASE_PROFILER_STARTUP_FEATURES"); copyEnv("MOZ_BASE_PROFILER_STARTUP_FILTERS"); -#endif } } // namespace mozilla @@ -4139,7 +4127,6 @@ static void TriggerPollJSSamplingOnMainThread() { } } -#ifdef MOZ_BASE_PROFILER static bool HasMinimumLength(const char* aString, size_t aMinimumLength) { if (!aString) { return false; @@ -4151,7 +4138,6 @@ static bool HasMinimumLength(const char* aString, size_t aMinimumLength) { } return true; } -#endif // MOZ_BASE_PROFILER static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, double aInterval, uint32_t aFeatures, @@ -4181,7 +4167,6 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, MOZ_RELEASE_ASSERT(CorePS::Exists() && !ActivePS::Exists(aLock)); -#ifdef MOZ_BASE_PROFILER UniquePtr baseprofile; if (baseprofiler::profiler_is_active()) { // Note that we still hold the lock, so the sampler cannot run yet and @@ -4206,7 +4191,6 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, // TODO: Re-start BP after GP shutdown, to capture post-XPCOM shutdown. baseprofiler::profiler_stop(); } -#endif #if defined(GP_PLAT_amd64_windows) InitializeWin64ProfilerHooks(); @@ -4232,7 +4216,6 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, // ActivePS::Create can only succeed or crash. MOZ_ASSERT(ActivePS::Exists(aLock)); -#ifdef MOZ_BASE_PROFILER // An "empty" profile string may in fact contain 1 character (a newline), so // we want at least 2 characters to register a profile. if (HasMinimumLength(baseprofile.get(), 2)) { @@ -4241,7 +4224,6 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity, // corresponding Gecko Profiler thread. ActivePS::AddBaseProfileThreads(aLock, std::move(baseprofile)); } -#endif // Set up profiling for each registered thread, if appropriate. Maybe mainThreadId; diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index f1c8cb44d924..231248a80c65 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -1793,7 +1793,6 @@ TEST(GeckoProfiler, PostSamplingCallback) [&](SamplingState) { ASSERT_TRUE(false); })); } -#ifdef MOZ_BASE_PROFILER TEST(GeckoProfiler, BaseProfilerHandOff) { const char* filters[] = {"GeckoMain"}; @@ -1840,4 +1839,3 @@ TEST(GeckoProfiler, BaseProfilerHandOff) profiler_stop(); ASSERT_TRUE(!profiler_is_active()); } -#endif // MOZ_BASE_PROFILER