BaseAndGeckoProfilerDetail.h (2581B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 // Internal Base and Gecko Profiler utilities. 8 // It should declare or define things that are used in both profilers, but not 9 // needed outside of the profilers. 10 // In particular, it is *not* included in popular headers like BaseProfiler.h 11 // and GeckoProfiler.h, to avoid rebuilding the world when this is modified. 12 13 #ifndef BaseAndGeckoProfilerDetail_h 14 #define BaseAndGeckoProfilerDetail_h 15 16 #include "mozilla/BaseProfilerUtils.h" 17 #include "mozilla/Span.h" 18 #include "mozilla/TimeStamp.h" 19 #include "mozilla/Types.h" 20 #include "mozilla/UniquePtr.h" 21 22 namespace mozilla { 23 24 class ProfileBufferChunkManagerWithLocalLimit; 25 26 // Centrally defines the version of the gecko profiler JSON format. 27 const int GECKO_PROFILER_FORMAT_VERSION = 32; 28 29 namespace baseprofiler::detail { 30 31 [[nodiscard]] MFBT_API TimeStamp GetProfilingStartTime(); 32 33 [[nodiscard]] MFBT_API UniquePtr<ProfileBufferChunkManagerWithLocalLimit> 34 ExtractBaseProfilerChunkManager(); 35 36 // If the current thread is registered, returns its registration time, otherwise 37 // a null timestamp. 38 [[nodiscard]] MFBT_API TimeStamp GetThreadRegistrationTime(); 39 40 } // namespace baseprofiler::detail 41 42 namespace profiler::detail { 43 44 // True if the filter is exactly "pid:<aPid>". 45 [[nodiscard]] MFBT_API bool FilterHasPid( 46 const char* aFilter, baseprofiler::BaseProfilerProcessId aPid = 47 baseprofiler::profiler_current_process_id()); 48 49 // Only true if the filters only contain "pid:..." strings, and *none* of them 50 // is exactly "pid:<aPid>". E.g.: 51 // - [], 123 -> false (no pids) 52 // - ["main"], 123 -> false (not all pids) 53 // - ["main", "pid:123"], 123 -> false (not all pids) 54 // - ["pid:123"], 123 -> false (all pids, including "pid:123") 55 // - ["pid:123", "pid:456"], 123 -> false (all pids, including "pid:123") 56 // - ["pid:456"], 123 -> true (all pids, but no "pid:123") 57 // - ["pid:456", "pid:789"], 123 -> true (all pids, but no "pid:123") 58 [[nodiscard]] MFBT_API bool FiltersExcludePid( 59 Span<const char* const> aFilters, 60 baseprofiler::BaseProfilerProcessId aPid = 61 baseprofiler::profiler_current_process_id()); 62 63 } // namespace profiler::detail 64 65 } // namespace mozilla 66 67 #endif // BaseAndGeckoProfilerDetail_h