mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
970468f937
Provide a custom no-op implementation of dlclose(), in order to prevent shared object data from disappearing from profiler view. The server makes queries for program executable code, which has to be always available, otherwise wrong data may be provided, or the program may crash, due to referencing no longer mapped memory. The dlclose() documentation states that the function internally decreases the reference count, and only does unload the shared object when the count reaches zero. There is no guarantee that the shared object data will be unloaded immediately after any dlclose call originating from the program. This function override exploits this fact.
27 lines
509 B
C++
27 lines
509 B
C++
#ifdef TRACY_ENABLE
|
|
# ifdef __linux__
|
|
# include "TracyDebug.hpp"
|
|
# ifdef TRACY_VERBOSE
|
|
# include <dlfcn.h>
|
|
# include <link.h>
|
|
# endif
|
|
|
|
extern "C" int dlclose( void* hnd )
|
|
{
|
|
#ifdef TRACY_VERBOSE
|
|
struct link_map* lm;
|
|
if( dlinfo( hnd, RTLD_DI_LINKMAP, &lm ) == 0 )
|
|
{
|
|
TracyDebug( "Overriding dlclose for %s\n", lm->l_name );
|
|
}
|
|
else
|
|
{
|
|
TracyDebug( "Overriding dlclose for unknown object (%s)\n", dlerror() );
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
# endif
|
|
#endif
|