diff options
author | Pavel Labath <pavel@labath.sk> | 2021-02-11 20:25:10 +0100 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2021-02-11 20:26:05 +0100 |
commit | 3cad308ce5d9eb2cc52f43ccef68f3d2b12f2a32 (patch) | |
tree | 4c5717daede0b1f54fb509a31d1742baeb8f212f /lldb/packages/Python/lldbsuite/test | |
parent | 8880a63a15a011b3265a184c398f2ff81570cdb6 (diff) | |
download | llvm-3cad308ce5d9eb2cc52f43ccef68f3d2b12f2a32.zip llvm-3cad308ce5d9eb2cc52f43ccef68f3d2b12f2a32.tar.gz llvm-3cad308ce5d9eb2cc52f43ccef68f3d2b12f2a32.tar.bz2 |
Revert "[lldb/test] Automatically find debug servers to test"
The commit 7df4eaaa937332c0617aa665080533966e2c98a0 appears to
break the windows bot. Revert while I investigate.
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
3 files changed, 65 insertions, 6 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 945b3f0..62508a1 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -366,6 +366,12 @@ def parseOptionsAndInitTestdirs(): args.executable) sys.exit(-1) + if args.server and args.out_of_tree_debugserver: + logging.warning('Both --server and --out-of-tree-debugserver are set') + + if args.server and not args.out_of_tree_debugserver: + os.environ['LLDB_DEBUGSERVER_PATH'] = args.server + if args.excluded: for excl_file in args.excluded: parseExclusion(excl_file) diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py index af45205..4774ce3 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -101,6 +101,10 @@ def create_parser(): metavar='executable-path', help='The path to the lldb executable') group.add_argument( + '--server', + metavar='server-path', + help='The path to the debug server executable to use') + group.add_argument( '--out-of-tree-debugserver', dest='out_of_tree_debugserver', action='store_true', diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py index eba6f32..0713610 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py @@ -15,12 +15,54 @@ from lldbsuite.support import seven from lldbsuite.test.lldbtest import * from lldbsuite.test import configuration from textwrap import dedent -import shutil -def _get_support_exe(basename): - support_dir = lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir) +def _get_debug_monitor_from_lldb(lldb_exe, debug_monitor_basename): + """Return the debug monitor exe path given the lldb exe path. - return shutil.which(basename, path=support_dir.GetDirectory()) + This method attempts to construct a valid debug monitor exe name + from a given lldb exe name. It will return None if the synthesized + debug monitor name is not found to exist. + + The debug monitor exe path is synthesized by taking the directory + of the lldb exe, and replacing the portion of the base name that + matches "lldb" (case insensitive) and replacing with the value of + debug_monitor_basename. + + Args: + lldb_exe: the path to an lldb executable. + + debug_monitor_basename: the base name portion of the debug monitor + that will replace 'lldb'. + + Returns: + A path to the debug monitor exe if it is found to exist; otherwise, + returns None. + + """ + if not lldb_exe: + return None + + exe_dir = os.path.dirname(lldb_exe) + exe_base = os.path.basename(lldb_exe) + + # we'll rebuild the filename by replacing lldb with + # the debug monitor basename, keeping any prefix or suffix in place. + regex = re.compile(r"lldb", re.IGNORECASE) + new_base = regex.sub(debug_monitor_basename, exe_base) + + debug_monitor_exe = os.path.join(exe_dir, new_base) + if os.path.exists(debug_monitor_exe): + return debug_monitor_exe + + new_base = regex.sub( + 'LLDB.framework/Versions/A/Resources/' + + debug_monitor_basename, + exe_base) + debug_monitor_exe = os.path.join(exe_dir, new_base) + if os.path.exists(debug_monitor_exe): + return debug_monitor_exe + + return None def get_lldb_server_exe(): @@ -30,8 +72,11 @@ def get_lldb_server_exe(): A path to the lldb-server exe if it is found to exist; otherwise, returns None. """ + if "LLDB_DEBUGSERVER_PATH" in os.environ: + return os.environ["LLDB_DEBUGSERVER_PATH"] - return _get_support_exe("lldb-server") + return _get_debug_monitor_from_lldb( + lldbtest_config.lldbExec, "lldb-server") def get_debugserver_exe(): @@ -41,11 +86,15 @@ def get_debugserver_exe(): A path to the debugserver exe if it is found to exist; otherwise, returns None. """ + if "LLDB_DEBUGSERVER_PATH" in os.environ: + return os.environ["LLDB_DEBUGSERVER_PATH"] + if configuration.arch and configuration.arch == "x86_64" and \ platform.machine().startswith("arm64"): return '/Library/Apple/usr/libexec/oah/debugserver' - return _get_support_exe("debugserver") + return _get_debug_monitor_from_lldb( + lldbtest_config.lldbExec, "debugserver") _LOG_LINE_REGEX = re.compile(r'^(lldb-server|debugserver)\s+<\s*(\d+)>' + '\s+(read|send)\s+packet:\s+(.+)$') |