Check if OS is Windows when getting shared lib path

This commit is contained in:
Christophe Bedard 2019-08-15 09:36:40 +02:00
parent 45cb575467
commit 6dde4bd3f2

View file

@ -14,6 +14,7 @@
"""Module for the Trace action.""" """Module for the Trace action."""
import os
import re import re
import subprocess import subprocess
from typing import List from typing import List
@ -73,9 +74,11 @@ class Trace(Action):
self.__ld_preload_action = None self.__ld_preload_action = None
if self.has_profiling_events(events_ust): if self.has_profiling_events(events_ust):
profile_lib_name = self.PROFILE_LIB_FAST if profile_fast else self.PROFILE_LIB_NORMAL profile_lib_name = self.PROFILE_LIB_FAST if profile_fast else self.PROFILE_LIB_NORMAL
profile_lib_path = self.get_shared_lib_path(profile_lib_name)
if profile_lib_path is not None:
self.__ld_preload_action = SetEnvironmentVariable( self.__ld_preload_action = SetEnvironmentVariable(
'LD_PRELOAD', 'LD_PRELOAD',
self.get_shared_lib_path(profile_lib_name), profile_lib_path,
) )
@classmethod @classmethod
@ -91,6 +94,8 @@ class Trace(Action):
:param lib_name: the name of the shared library :param lib_name: the name of the shared library
:return: the full path if found, `None` otherwise :return: the full path if found, `None` otherwise
""" """
if os.name == 'nt':
return None
(exit_code, output) = subprocess.getstatusoutput(f'whereis -b {lib_name}') (exit_code, output) = subprocess.getstatusoutput(f'whereis -b {lib_name}')
if exit_code != 0: if exit_code != 0:
return None return None