Improve sample collection in multi-threaded apps when using "--pid" option
See oprofile bug # 260 (https://sourceforge.net/p/oprofile/bugs/260/) for reference.
operf may fail to collect samples for new threads or forked
processes in a multi-threaded app under certain conditions:
- If operf is started on a multi-threaded app (i.e., one that uses
pthreads) with the "--pid" option
- If said app has already started at least one thread
- If the app either creates new threads or forks new processes
after operf has started
then no samples are collected for those new threads/processes.
This patch fixes that problem (mostly) and documents the limitations and
issues when using the "--pid" option. The limitations and issues are:
1. When using "--pid" to profile a multi-threaded application that also forks
new processes, samples for processes that are forked before profiling is
started may not be recorded (depending on timing of thread creation and
when operf is started)
2. The "--lazy-conversion" option is not recommended to be used in conjunction
with the --pid option for profiling multi-threaded processes. Depending on
the order of thread creation (or forking of new processes), you may not get
any samples for the new threads/processes.
Signed-off-by: Maynard Johnson <email@example.com>