We now detect "SIGTRAP is blocked" case and handle it properly. This
enables us to run pthread_create. So there is no more need to disable
ManyThreads test.
Note, we're not propagating single-stepping mode into child threads,
so we're still only fork-testing main thread, but that should be
plenty good for now. I.e. merely not crashing on pthread_create
anymore when fork torturing is enabled.
I.e. by having TCM_DEBUG_BT_SYMBOLIZATION_TEST that disables death
test and just runs "death" actions directly. So that someone can gdb
symbolization part.
We do arguably a bit reckless thing with simply packaging entire
vendor/ subdirectory and that gives us some crap. But for now this is
what we'll do and we'll simply remove that "crap" as part of packaging
step.
This is how we need to deal with symbols without line numbers debug
info. It unbreaks for example _start symbolization.
We also refactor the code some and we run symbolization with
emergency malloc mode enabled.
This enables OSX to do usual malloc/free things in emergency malloc
mode. We update unit tests accordingly (i.e. call free instead of
tc_free when relevant).
This is part of effort to get rid of perl pprof dependency. We're
replacing forking to pprof --symbols with carefully crafted
libbacktrace integration which has enough support for symbolizing
backtraces.
This refactors API so that meta_data_arena isn't needed or used
anymore. We always used nullptr for this argument anyways.
We also change code so that PagesAllocator API is able to choose
rounding up of allocation requests. It now returns pointer to
allocated memory and it's rounded up size.
And most important part of this change is that Arena instance itself
is now allocated with provided allocator (when provided). This reduces
locking depencies.
We make sure to cover new logic by test.
Apparently, gcc 10 doesn't support trailing return types for lambdas with an attribute.
```
src/tests/sampling_test.cc: In lambda function:
src/tests/sampling_test.cc:70:56: error: expected '{' before '->' token
70 | auto local_noopt = [] (void* ptr) ATTRIBUTE_NOINLINE -> void* {
| ^~
src/tests/sampling_test.cc: In function 'void* AllocateAllocate()':
src/tests/sampling_test.cc:70:56: error: base operand of '->' has non-pointer type 'AllocateAllocate()::<lambda(void*)>'
src/tests/sampling_test.cc:70:59: error: expected unqualified-id before 'void'
70 | auto local_noopt = [] (void* ptr) ATTRIBUTE_NOINLINE -> void* {
| ^~~~
```
Remove the trailing return type as it is deduced from the `noopt` call anyway.
And unbreak on it FreeBSD.
Turns out not only they don't mount procfs by default, their
/proc/pid/map fails to supply mapping offsets. Without offsets all the
hope is lost.
I see rare occasional failures there, which look very odd. Typically
both sampling and sampling_debug tests fail at about the same time. So
hopefully we can diagnose them sometime.
We used GetCallerStackTrace thingy before, but it is not entirely
reliable in it's detection of malloc stack frames (i.e. on OSX). So
lets do full thing instead. Those stacktraces are to be printed to
users anyways.
When linking statically we may end up calling ProfilerGetCurrentState
earlier than profiler is initialized. And we segfaulted on that early
call. Lets make us handle this case gracefully.
Instead of MallocHook::GetCallerStackTrace.
Thing is, GetCallerStackTrace isn't reliable beyond ELF systems, like
OSX. And, yet, things just work without it for e.g. heap
sampling. Why? Because pprof already knows how to exclude
tcmalloc-internal stack frames (by looking at e.g. tcmalloc::
namespace). So we do the same for heap profiler.
This fixes heap profiling unit tests on OSX.