Michael137 created this revision.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Some tests in LLDB require the use of binutils tools. On Darwin,
we need to use the tools that ship with Xcode. Otherwise we risk
crashing in unpredictable ways.

This patch adds a check for this and bails early if the user has
a non-Xcode binutils in their path before the Xcode ones.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143842

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -869,6 +869,28 @@
     if platform not in ["freebsd", "linux", "netbsd"]:
         configuration.skip_categories.append("fork")
 
+def checkDarwinBinutilsPath():
+    from lldbsuite.test import lldbplatformutil
+
+    if not lldbplatformutil.platformIsDarwin():
+        return
+
+    cmd = ["strip", "--version"]
+    process = subprocess.Popen(
+        cmd,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.STDOUT)
+    cmd_output = process.stdout.read()
+    output_str = cmd_output.decode("utf-8")
+    if "GNU strip (GNU Binutils)" in output_str:
+        print("""
+The tool 'strip' in your path is not the one from the Xcode
+toolchain. Please make sure the Xcode tools are before any
+other tools in your path. Run `xcode -f strip` for the correct
+toolchain path.
+Exiting...
+        """)
+        sys.exit(0)
 
 def run_suite():
     # On MacOS X, check to make sure that domain for com.apple.DebugSymbols 
defaults
@@ -956,6 +978,7 @@
     checkDebugServerSupport()
     checkObjcSupport()
     checkForkVForkSupport()
+    checkDarwinBinutilsPath()
 
     skipped_categories_list = ", ".join(configuration.skip_categories)
     print("Skipping the following test categories: 
{}".format(configuration.skip_categories))


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -869,6 +869,28 @@
     if platform not in ["freebsd", "linux", "netbsd"]:
         configuration.skip_categories.append("fork")
 
+def checkDarwinBinutilsPath():
+    from lldbsuite.test import lldbplatformutil
+
+    if not lldbplatformutil.platformIsDarwin():
+        return
+
+    cmd = ["strip", "--version"]
+    process = subprocess.Popen(
+        cmd,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.STDOUT)
+    cmd_output = process.stdout.read()
+    output_str = cmd_output.decode("utf-8")
+    if "GNU strip (GNU Binutils)" in output_str:
+        print("""
+The tool 'strip' in your path is not the one from the Xcode
+toolchain. Please make sure the Xcode tools are before any
+other tools in your path. Run `xcode -f strip` for the correct
+toolchain path.
+Exiting...
+        """)
+        sys.exit(0)
 
 def run_suite():
     # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
@@ -956,6 +978,7 @@
     checkDebugServerSupport()
     checkObjcSupport()
     checkForkVForkSupport()
+    checkDarwinBinutilsPath()
 
     skipped_categories_list = ", ".join(configuration.skip_categories)
     print("Skipping the following test categories: {}".format(configuration.skip_categories))
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to