Exemplo n.º 1
0
    def test_paths(self):
        '''Test to make sure no file names are set in the lldb.SBFileSpec objects returned by lldb.SBHostOS.GetLLDBPath() for paths that are directories'''
        dir_path_types = [
            lldb.ePathTypeLLDBShlibDir, lldb.ePathTypeSupportExecutableDir,
            lldb.ePathTypeHeaderDir, lldb.ePathTypePythonDir,
            lldb.ePathTypeLLDBSystemPlugins, lldb.ePathTypeLLDBUserPlugins,
            lldb.ePathTypeLLDBTempSystemDir, lldb.ePathTypeClangDir
        ]

        for path_type in dir_path_types:
            f = lldb.SBHostOS.GetLLDBPath(path_type)
            # No directory path types should have the filename set
            self.assertIsNone(f.GetFilename())

        shlib_dir = lldb.SBHostOS.GetLLDBPath(
            lldb.ePathTypeLLDBShlibDir).GetDirectory()
        if lldbplatformutil.getHostPlatform() == 'windows':
            filenames = ['liblldb.dll']
        elif lldbplatformutil.getHostPlatform() == 'macosx':
            filenames = ['LLDB', 'liblldb.dylib']
        else:
            filenames = ['liblldb.so']
        self.assertTrue(
            any([
                os.path.exists(os.path.join(shlib_dir, f)) for f in filenames
            ]), "shlib_dir = " + shlib_dir)
Exemplo n.º 2
0
    def fn(self):
        skip_for_os = _match_decorator_property(lldbplatform.translate(oslist),
                                                self.getPlatform())
        skip_for_hostos = _match_decorator_property(
            lldbplatform.translate(hostoslist),
            lldbplatformutil.getHostPlatform())
        skip_for_compiler = _match_decorator_property(
            compiler, self.getCompiler()) and self.expectedCompilerVersion(
                compiler_version)
        skip_for_arch = _match_decorator_property(archs,
                                                  self.getArchitecture())
        skip_for_debug_info = _match_decorator_property(
            debug_info, self.debug_info)
        skip_for_triple = _match_decorator_property(
            triple,
            lldb.DBG.GetSelectedPlatform().GetTriple())
        skip_for_remote = _match_decorator_property(
            remote, lldb.remote_platform is not None)

        skip_for_swig_version = (swig_version is None) or (not hasattr(
            lldb, 'swig_version')) or (_check_expected_version(
                swig_version[0], swig_version[1], lldb.swig_version))
        skip_for_py_version = (py_version is None) or _check_expected_version(
            py_version[0], py_version[1], sys.version_info)

        # For the test to be skipped, all specified (e.g. not None) parameters must be True.
        # An unspecified parameter means "any", so those are marked skip by default.  And we skip
        # the final test if all conditions are True.
        conditions = [(oslist, skip_for_os, "target o/s"),
                      (hostoslist, skip_for_hostos, "host o/s"),
                      (compiler, skip_for_compiler, "compiler or version"),
                      (archs, skip_for_arch, "architecture"),
                      (debug_info, skip_for_debug_info, "debug info format"),
                      (triple, skip_for_triple, "target triple"),
                      (swig_version, skip_for_swig_version, "swig version"),
                      (py_version, skip_for_py_version, "python version"),
                      (remote, skip_for_remote,
                       "platform locality (remote/local)")]
        reasons = []
        final_skip_result = True
        for this_condition in conditions:
            final_skip_result = final_skip_result and this_condition[1]
            if this_condition[0] is not None and this_condition[1]:
                reasons.append(this_condition[2])
        reason_str = None
        if final_skip_result:
            mode_str = {
                DecorateMode.Skip: "skipping",
                DecorateMode.Xfail: "xfailing"
            }[mode]
            if len(reasons) > 0:
                reason_str = ",".join(reasons)
                reason_str = "{} due to the following parameter(s): {}".format(
                    mode_str, reason_str)
            else:
                reason_str = "{} unconditionally"
            if bugnumber is not None and not six.callable(bugnumber):
                reason_str = reason_str + " [" + str(bugnumber) + "]"
        return reason_str
Exemplo n.º 3
0
 def are_sb_headers_missing():
     if lldbplatformutil.getHostPlatform() == 'darwin':
         header = os.path.join(os.environ["LLDB_LIB_DIR"], 'LLDB.framework', 'Versions','Current','Headers','LLDB.h')
     else:
         header = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API", "LLDB.h")
     if not os.path.exists(header):
         return "skip because LLDB.h header not found"
     return None
Exemplo n.º 4
0
 def are_sb_headers_missing():
     if lldbplatformutil.getHostPlatform() == 'darwin':
         header = os.path.join(os.environ["LLDB_LIB_DIR"], 'LLDB.framework', 'Versions','Current','Headers','LLDB.h')
     else:
         header = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API", "LLDB.h")
     if not os.path.exists(header):
         return "skip because LLDB.h header not found"
     return None
Exemplo n.º 5
0
 def is_host_incompatible_with_remote(self):
     host_arch = self.getLldbArchitecture()
     host_platform = lldbplatformutil.getHostPlatform()
     target_arch = self.getArchitecture()
     target_platform = 'darwin' if self.platformIsDarwin() else self.getPlatform()
     if not (target_arch == 'x86_64' and host_arch == 'i386') and host_arch != target_arch:
         return "skipping because target %s is not compatible with host architecture %s" % (target_arch, host_arch)
     elif target_platform != host_platform:
         return "skipping because target is %s but host is %s" % (target_platform, host_platform)
     return None
Exemplo n.º 6
0
 def is_host_incompatible_with_remote(self):
     host_arch = self.getLldbArchitecture()
     host_platform = lldbplatformutil.getHostPlatform()
     target_arch = self.getArchitecture()
     target_platform = 'darwin' if self.platformIsDarwin() else self.getPlatform()
     if not (target_arch == 'x86_64' and host_arch == 'i386') and host_arch != target_arch:
         return "skipping because target %s is not compatible with host architecture %s" % (target_arch, host_arch)
     elif target_platform != host_platform:
         return "skipping because target is %s but host is %s" % (target_platform, host_platform)
     return None
Exemplo n.º 7
0
 def should_skip_simulator_test():
     if lldbplatformutil.getHostPlatform() != 'darwin':
         return "simulator tests are run only on darwin hosts"
     try:
         DEVNULL = open(os.devnull, 'w')
         output = subprocess.check_output(["xcodebuild", "-showsdks"], stderr=DEVNULL).decode("utf-8")
         if re.search('%ssimulator' % platform, output):
             return None
         else:
             return "%s simulator is not supported on this system." % platform
     except subprocess.CalledProcessError:
         return "Simulators are unsupported on this system (xcodebuild failed)"
Exemplo n.º 8
0
    def are_sb_headers_missing():
        if lldb.remote_platform:
            return "skip because SBHeaders tests make no sense remotely"

        if lldbplatformutil.getHostPlatform(
        ) == 'darwin' and configuration.lldb_framework_path:
            header = os.path.join(configuration.lldb_framework_path,
                                  'Versions', 'Current', 'Headers', 'LLDB.h')
            if os.path.exists(header):
                return None

        header = os.path.join(os.environ["LLDB_SRC"], "include", "lldb", "API",
                              "LLDB.h")
        if not os.path.exists(header):
            return "skip because LLDB.h header not found"
        return None
Exemplo n.º 9
0
    def fn(self):
        skip_for_os = _match_decorator_property(oslist, self.getPlatform())
        skip_for_hostos = _match_decorator_property(hostoslist, lldbplatformutil.getHostPlatform())
        skip_for_compiler = _match_decorator_property(compiler, self.getCompiler()) and self.expectedCompilerVersion(compiler_version)
        skip_for_arch = _match_decorator_property(archs, self.getArchitecture())
        skip_for_debug_info = _match_decorator_property(debug_info, self.debug_info)
        skip_for_triple = _match_decorator_property(triple, lldb.DBG.GetSelectedPlatform().GetTriple())
        skip_for_remote = _match_decorator_property(remote, lldb.remote_platform is not None)

        skip_for_swig_version = (swig_version is None) or (not hasattr(lldb, 'swig_version')) or (_check_expected_version(swig_version[0], swig_version[1], lldb.swig_version))
        skip_for_py_version = (py_version is None) or _check_expected_version(py_version[0], py_version[1], sys.version_info)

        # For the test to be skipped, all specified (e.g. not None) parameters must be True.
        # An unspecified parameter means "any", so those are marked skip by default.  And we skip
        # the final test if all conditions are True.
        conditions = [(oslist, skip_for_os, "target o/s"),
                      (hostoslist, skip_for_hostos, "host o/s"),
                      (compiler, skip_for_compiler, "compiler or version"),
                      (archs, skip_for_arch, "architecture"),
                      (debug_info, skip_for_debug_info, "debug info format"),
                      (triple, skip_for_triple, "target triple"),
                      (swig_version, skip_for_swig_version, "swig version"),
                      (py_version, skip_for_py_version, "python version"),
                      (remote, skip_for_remote, "platform locality (remote/local)")]
        reasons = []
        final_skip_result = True
        for this_condition in conditions:
            final_skip_result = final_skip_result and this_condition[1]
            if this_condition[0] is not None and this_condition[1]:
                reasons.append(this_condition[2])
        reason_str = None
        if final_skip_result:
            mode_str = {DecorateMode.Skip : "skipping", DecorateMode.Xfail : "xfailing"}[mode]
            if len(reasons) > 0:
                reason_str = ",".join(reasons)
                reason_str = "{} due to the following parameter(s): {}".format(mode_str, reason_str)
            else:
                reason_str = "{} unconditionally"
            if bugnumber is not None and not six.callable(bugnumber):
                reason_str = reason_str + " [" + str(bugnumber) + "]"
        return reason_str
Exemplo n.º 10
0
from __future__ import print_function

import gdbremote_testcase
import select
import socket
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbplatformutil
import random

if lldbplatformutil.getHostPlatform() == "windows":
    import ctypes
    import ctypes.wintypes
    from ctypes.wintypes import (BOOL, DWORD, HANDLE, LPCWSTR, LPDWORD, LPVOID)

    kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)

    PIPE_ACCESS_INBOUND = 1
    FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000
    FILE_FLAG_OVERLAPPED = 0x40000000
    PIPE_TYPE_BYTE = 0
    PIPE_REJECT_REMOTE_CLIENTS = 8
    INVALID_HANDLE_VALUE = -1
    ERROR_ACCESS_DENIED = 5
    ERROR_IO_PENDING = 997

    class OVERLAPPED(ctypes.Structure):
        _fields_ = [("Internal", LPVOID), ("InternalHigh", LPVOID),
                    ("Offset", DWORD), ("OffsetHigh", DWORD),
                    ("hEvent", HANDLE)]