michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: 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: /* michael@0: * Functions for controlling profilers from within JS: Valgrind, Perf, michael@0: * Shark, etc. michael@0: */ michael@0: #ifndef builtin_Profilers_h michael@0: #define builtin_Profilers_h michael@0: michael@0: #include "jstypes.h" michael@0: michael@0: #ifdef _MSC_VER michael@0: typedef int pid_t; michael@0: #else michael@0: #include michael@0: #endif michael@0: michael@0: /** michael@0: * Start any profilers that are available and have been configured on for this michael@0: * platform. This is NOT thread safe. michael@0: * michael@0: * The profileName is used by some profilers to describe the current profiling michael@0: * run. It may be used for part of the filename of the output, but the michael@0: * specifics depend on the profiler. Many profilers will ignore it. Passing in michael@0: * nullptr is legal; some profilers may use it to output to stdout or similar. michael@0: * michael@0: * Returns true if no profilers fail to start. michael@0: */ michael@0: extern JS_PUBLIC_API(bool) michael@0: JS_StartProfiling(const char *profileName, pid_t pid); michael@0: michael@0: /** michael@0: * Stop any profilers that were previously started with JS_StartProfiling. michael@0: * Returns true if no profilers fail to stop. michael@0: */ michael@0: extern JS_PUBLIC_API(bool) michael@0: JS_StopProfiling(const char *profileName); michael@0: michael@0: /** michael@0: * Write the current profile data to the given file, if applicable to whatever michael@0: * profiler is being used. michael@0: */ michael@0: extern JS_PUBLIC_API(bool) michael@0: JS_DumpProfile(const char *outfile, const char *profileName); michael@0: michael@0: /** michael@0: * Pause currently active profilers (only supported by some profilers). Returns michael@0: * whether any profilers failed to pause. (Profilers that do not support michael@0: * pause/resume do not count.) michael@0: */ michael@0: extern JS_PUBLIC_API(bool) michael@0: JS_PauseProfilers(const char *profileName); michael@0: michael@0: /** michael@0: * Resume suspended profilers michael@0: */ michael@0: extern JS_PUBLIC_API(bool) michael@0: JS_ResumeProfilers(const char *profileName); michael@0: michael@0: /** michael@0: * The profiling API calls are not able to report errors, so they use a michael@0: * thread-unsafe global memory buffer to hold the last error encountered. This michael@0: * should only be called after something returns false. michael@0: */ michael@0: JS_PUBLIC_API(const char *) michael@0: JS_UnsafeGetLastProfilingError(); michael@0: michael@0: #ifdef MOZ_CALLGRIND michael@0: michael@0: extern JS_FRIEND_API(bool) michael@0: js_StopCallgrind(); michael@0: michael@0: extern JS_FRIEND_API(bool) michael@0: js_StartCallgrind(); michael@0: michael@0: extern JS_FRIEND_API(bool) michael@0: js_DumpCallgrind(const char *outfile); michael@0: michael@0: #endif /* MOZ_CALLGRIND */ michael@0: michael@0: #ifdef __linux__ michael@0: michael@0: extern JS_FRIEND_API(bool) michael@0: js_StartPerf(); michael@0: michael@0: extern JS_FRIEND_API(bool) michael@0: js_StopPerf(); michael@0: michael@0: #endif /* __linux__ */ michael@0: michael@0: #endif /* builtin_Profilers_h */