| 1 | #pragma once |
| 2 | |
| 3 | /// This code was based on the code by Fedor Korotkiy (prime@yandex-team.ru) for YT product in Yandex. |
| 4 | |
| 5 | /** Collects all dl_phdr_info items and caches them in a static array. |
| 6 | * Also rewrites dl_iterate_phdr with a lock-free version which consults the above cache |
| 7 | * thus eliminating scalability bottleneck in C++ exception unwinding. |
| 8 | * As a drawback, this only works if no dynamic object unloading happens after this point. |
| 9 | * This function is thread-safe. You should call it to update cache after loading new shared libraries. |
| 10 | * Otherwise exception handling from dlopened libraries won't work (will call std::terminate immediately). |
| 11 | * |
| 12 | * NOTE: It is disabled with Thread Sanitizer because TSan can only use original "dl_iterate_phdr" function. |
| 13 | */ |
| 14 | void updatePHDRCache(); |
| 15 | |
| 16 | /** Check if "dl_iterate_phdr" will be lock-free |
| 17 | * to determine if some features like Query Profiler can be used. |
| 18 | */ |
| 19 | bool hasPHDRCache(); |
| 20 | |