@@ -430,20 +430,16 @@ bool OpSysTools::IsSafeToStartProfiler(double coresThreshold, double& cpuLimit)
430430 // For linux, we check that the wrapper library is loaded and the default `dl_iterate_phdr` is
431431 // the one provided by our library.
432432
433- std::string wrapperLibraryName = " Datadog.Linux.ApiWrapper.x64.so" ;
433+ const std::string wrapperLibraryName = " Datadog.Linux.ApiWrapper.x64.so" ;
434+ const std::string wrapperLibraryNamePyroscope = " Pyroscope.Linux.ApiWrapper.x64.so" ;
434435 const std::string customFnName = " dl_iterate_phdr" ;
435436 auto * dlIteratePhdr = reinterpret_cast <void *>(::dl_iterate_phdr);
436437
437438 Dl_info info;
438439 auto res = dladdr (dlIteratePhdr, &info);
439440 if (res == 0 || info.dli_fname == nullptr )
440441 {
441- wrapperLibraryName = " Pyroscope.Linux.ApiWrapper.x64.so" ;
442- res = dladdr (dlIteratePhdr, &info);
443- }
444- if (res == 0 || info.dli_fname == nullptr )
445- {
446- Log::Warn (" Profiling is disabled: Unable to check if the library '" , wrapperLibraryName, " '" ,
442+ Log::Warn (" Profiling is disabled: Unable to check if the library '" , wrapperLibraryNamePyroscope, " '" ,
447443 " is correctly loaded and/or the function '" , customFnName, " ' is correctly wrapped." ,
448444 " Please contact the support for help with the following details:\n " ,
449445 " Call to dladdr: " , res, " \n " ,
@@ -453,11 +449,12 @@ bool OpSysTools::IsSafeToStartProfiler(double coresThreshold, double& cpuLimit)
453449
454450 auto sharedObjectPath = fs::path (info.dli_fname );
455451
456- if (sharedObjectPath.filename () != wrapperLibraryName)
452+ if (sharedObjectPath.filename () != wrapperLibraryName
453+ && sharedObjectPath.filename () != wrapperLibraryNamePyroscope )
457454 {
458455 // We assume that the profiler library is in the same folder as the wrapper library
459456 auto currentModulePath = fs::path (shared::GetCurrentModuleFileName ());
460- auto wrapperLibrary = currentModulePath.parent_path () / wrapperLibraryName ;
457+ auto wrapperLibrary = currentModulePath.parent_path () / wrapperLibraryNamePyroscope ;
461458 auto wrapperLibraryPath = wrapperLibrary.string ();
462459
463460 // Check if process is running is a secure-execution mode
@@ -466,7 +463,7 @@ bool OpSysTools::IsSafeToStartProfiler(double coresThreshold, double& cpuLimit)
466463 // Get LD_PRELOAD env var content
467464 auto envVarValue = shared::GetEnvironmentValue (WStr (" LD_PRELOAD" ));
468465
469- Log::Warn (" Profiling is disabled: It appears the wrapper library '" , wrapperLibraryName , " ' is not correctly loaded.\n " ,
466+ Log::Warn (" Profiling is disabled: It appears the wrapper library '" , wrapperLibraryNamePyroscope , " ' is not correctly loaded.\n " ,
470467 " Possible reason(s):\n " ,
471468 " * The LD_PRELOAD environment variable might not contain the path '" , wrapperLibraryPath, " '. Try adding " ,
472469 " '" , wrapperLibraryPath, " ' to LD_PRELOAD environment variable.\n " ,
0 commit comments