michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef PROFILER_FUNCS_H michael@0: #define PROFILER_FUNCS_H michael@0: michael@0: #include "mozilla/NullPtr.h" michael@0: #include "js/TypeDecls.h" michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: class TimeDuration; michael@0: class TimeStamp; michael@0: } michael@0: michael@0: using mozilla::TimeStamp; michael@0: using mozilla::TimeDuration; michael@0: michael@0: class ProfilerBacktrace; michael@0: class ProfilerMarkerPayload; michael@0: michael@0: // Returns a handle to pass on exit. This can check that we are popping the michael@0: // correct callstack. michael@0: inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress = nullptr, michael@0: bool aCopy = false, uint32_t line = 0); michael@0: inline void mozilla_sampler_call_exit(void* handle); michael@0: void mozilla_sampler_add_marker(const char *aInfo, michael@0: ProfilerMarkerPayload *aPayload = nullptr); michael@0: michael@0: void mozilla_sampler_start(int aEntries, double aInterval, michael@0: const char** aFeatures, uint32_t aFeatureCount, michael@0: const char** aThreadNameFilters, uint32_t aFilterCount); michael@0: michael@0: void mozilla_sampler_stop(); michael@0: michael@0: bool mozilla_sampler_is_paused(); michael@0: void mozilla_sampler_pause(); michael@0: void mozilla_sampler_resume(); michael@0: michael@0: ProfilerBacktrace* mozilla_sampler_get_backtrace(); michael@0: void mozilla_sampler_free_backtrace(ProfilerBacktrace* aBacktrace); michael@0: michael@0: bool mozilla_sampler_is_active(); michael@0: michael@0: void mozilla_sampler_responsiveness(const mozilla::TimeStamp& time); michael@0: michael@0: void mozilla_sampler_frame_number(int frameNumber); michael@0: michael@0: const double* mozilla_sampler_get_responsiveness(); michael@0: michael@0: void mozilla_sampler_save(); michael@0: michael@0: char* mozilla_sampler_get_profile(); michael@0: michael@0: JSObject *mozilla_sampler_get_profile_data(JSContext *aCx); michael@0: michael@0: void mozilla_sampler_save_profile_to_file(const char* aFilename); michael@0: michael@0: const char** mozilla_sampler_get_features(); michael@0: michael@0: void mozilla_sampler_init(void* stackTop); michael@0: michael@0: void mozilla_sampler_shutdown(); michael@0: michael@0: void mozilla_sampler_print_location1(); michael@0: void mozilla_sampler_print_location2(); michael@0: michael@0: // Lock the profiler. When locked the profiler is (1) stopped, michael@0: // (2) profile data is cleared, (3) profiler-locked is fired. michael@0: // This is used to lock down the profiler during private browsing michael@0: void mozilla_sampler_lock(); michael@0: michael@0: // Unlock the profiler, leaving it stopped and fires profiler-unlocked. michael@0: void mozilla_sampler_unlock(); michael@0: michael@0: // Register/unregister threads with the profiler michael@0: bool mozilla_sampler_register_thread(const char* name, void* stackTop); michael@0: void mozilla_sampler_unregister_thread(); michael@0: michael@0: void mozilla_sampler_sleep_start(); michael@0: void mozilla_sampler_sleep_end(); michael@0: michael@0: double mozilla_sampler_time(); michael@0: double mozilla_sampler_time(const mozilla::TimeStamp& aTime); michael@0: michael@0: /* Returns true if env var SPS_NEW is set to anything, else false. */ michael@0: extern bool sps_version2(); michael@0: michael@0: void mozilla_sampler_tracing(const char* aCategory, const char* aInfo, michael@0: TracingMetadata aMetaData); michael@0: michael@0: #endif michael@0: