gecko-dev/tools
Michael Layzell dd07e2a56b Bug 1357829 - Part 1: Expose profiler_suspend_and_sample_thread, r=njn
This patch performs a refactoring to the internals of the profiler in order to
expose a function, profiler_suspend_and_sample_thread, which can be called from a
background thread to suspend, sample the native stack, and then resume the
target passed-in thread.

The interface was designed to expose as few internals of the profiler as
possible, exposing only a single callback which accepts the list of program
counters and stack pointers collected during the backtrace.

A method `profiler_current_thread_id` was also added to get the thread_id of the
current thread, which can then be passed by another thread into
profiler_suspend_sample_thread to sample the stack of that thread.

This is implemented in two parts:

1) Splitting SamplerThread into two classes: Sampler, and SamplerThread.

Sampler was created to extract the core logic from SamplerThread which manages
unix signals on android and linux, as well as suspends the target thread on all
platforms. SamplerThread was then modified to subclass this type, adding the
extra methods and fields required for the creation and management of the actual
Sampler Thread.

Some work was done to ensure that the methods on Sampler would not require
ActivePS to be present, as we intend to sample threads when the profiler is not
active for the Background Hang Reporter.

2) Moving the Tick() logic into the TickController interface.

A TickController interface was added to platform which has 2 methods: Tick and
Backtrace. The Tick method replaces the previous Tick() static method, allowing
it to be overridden by a different consumer of SuspendAndSampleAndResumeThread,
while the Backtrace() method replaces the previous MergeStacksIntoProfile
method, allowing it to be overridden by different consumers of
DoNativeBacktrace.

This interface object is then used to wrap implementation specific data, such as
the ProfilerBuffer, and is threaded through the SuspendAndSampleAndResumeThread
and DoNativeBacktrace methods.

This change added 2 virtual calls to the SamplerThread's critical section, which
I believe should be a small enough overhead that it will not affect profiling
performance. These virtual calls could be avoided using templating, but I
decided that doing so would be unnecessary.

MozReview-Commit-ID: AT48xb2asgV
2017-05-18 13:56:20 -04:00
..
bloatview
coverity Bug 1359376 - Update Coverity modeling file to support NS_RUNTIMEABORT. r=sylvestre 2017-04-25 15:08:48 +03:00
docs Bug 1335309 - Change the default for find_executables to False. r=mshal 2017-01-31 14:06:15 +09:00
fuzzing Bug 1362215 - use MOZ_FORMAT_PRINTF in TestHarness.h; r=froydnj 2017-05-05 14:23:00 -06:00
git Bug 1360595 - Add a git pre-commit hook for running ESLint. r=mossop 2017-04-28 12:19:15 +01:00
jprof
leak-gauge Bug 1360293 - Enable the Mozilla ESlint recommended rules for tools/. r=jryans 2017-05-01 11:38:39 +01:00
lint Bug 1365412 - Clean up various ESLint global definitions in browser/. r=mossop 2017-05-16 22:22:42 +01:00
memory-profiler Bug 1358320 - Make TimeStamp::ProcessCreation()'s outparam optional. r=gsvelto. 2017-04-26 14:55:54 +10:00
mercurial Bug 1360595 - Add a git pre-commit hook for running ESLint. r=mossop 2017-04-28 12:19:15 +01:00
power Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in tools/ r=froydnj 2017-02-08 12:04:50 +01:00
profiler Bug 1357829 - Part 1: Expose profiler_suspend_and_sample_thread, r=njn 2017-05-18 13:56:20 -04:00
quitter Bug 1360293 - Enable the Mozilla ESlint recommended rules for tools/. r=jryans 2017-05-01 11:38:39 +01:00
rb Bug 1331310 - Remove unbufferedLineConverter in fix_linux_stacks.py. r=glandium. 2017-01-18 13:57:39 +11:00
rewriting Bug 1363992 - Remove jemalloc 4. r=njn 2017-05-11 13:23:07 +09:00
update-packaging Bug 1339182 - Remove OSX universal support in the build system; r=glandium 2017-02-10 16:52:17 -05:00
.eslintrc.js Bug 1360293 - Enable the Mozilla ESlint recommended rules for tools/. r=jryans 2017-05-01 11:38:39 +01:00
mach_commands.py Bug 1293493 - Remove mach rage since it was unused; r=ted 2017-04-24 16:33:51 -07:00
moz.build Bug 1341876 - annotate tools/* with BUG_COMPONENTS. r=gps 2017-04-05 08:31:05 -04:00