Skip to content

Commit 6335deb

Browse files
committed
[lldb/test] Use SBPlatform info for lldbplatformutil.getPlatform()
Previously, we just used the platform name. This worked mostly OK, but it required adding special handling for any unusual (and potentially downstream) platform plugins, as evidenced by the hardcoding of the qemu-user platform. The current implementation was added in D121605/21c5bb0a636c23ec75b13681c0a6fdb03ecd9c0d, which this essentially reverts and goes back to the previous method of retrieving the platform name from the platform triple (the "OS" field). The motivation for D121605 was the ability to retrieve the process without constructing an SBDebugger object (which would be necessary in a world where SBPlatforms are managed by SBDebuggers). However, this world did not arrive (mainly due to other commitments on my part), and I now think that if we do want to go in that direction, that we should just create a dummy/empty SBDebugger object for holding the initial SBPlatform. One benefit of D121605 was the unification of getPlatform and getHostPlatform code paths, and I preserve that benefit by unifying them in the other direction -- using the host SBPlatform for getHostPlatform. Differential Revision: https://reviews.llvm.org/D138430
1 parent 1147e70 commit 6335deb

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -849,14 +849,14 @@ def checkDebugServerSupport():
849849
skip_msg = "Skipping %s tests, as they are not compatible with remote testing on this platform"
850850
if lldbplatformutil.platformIsDarwin():
851851
configuration.skip_categories.append("llgs")
852-
if configuration.lldb_platform_name:
852+
if lldb.remote_platform:
853853
# <rdar://problem/34539270>
854854
configuration.skip_categories.append("debugserver")
855855
if configuration.verbose:
856856
print(skip_msg%"debugserver");
857857
else:
858858
configuration.skip_categories.append("debugserver")
859-
if configuration.lldb_platform_name and lldbplatformutil.getPlatform() == "windows":
859+
if lldb.remote_platform and lldbplatformutil.getPlatform() == "windows":
860860
configuration.skip_categories.append("llgs")
861861
if configuration.verbose:
862862
print(skip_msg%"lldb-server");
@@ -891,14 +891,6 @@ def run_suite():
891891
lldb.SBDebugger.Initialize()
892892
lldb.SBDebugger.PrintStackTraceOnError()
893893

894-
checkLibcxxSupport()
895-
checkLibstdcxxSupport()
896-
checkWatchpointSupport()
897-
checkDebugInfoSupport()
898-
checkDebugServerSupport()
899-
checkObjcSupport()
900-
checkForkVForkSupport()
901-
902894
# Use host platform by default.
903895
lldb.remote_platform = None
904896
lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()
@@ -957,8 +949,16 @@ def run_suite():
957949
# Note that it's not dotest's job to clean this directory.
958950
lldbutil.mkdir_p(configuration.test_build_dir)
959951

952+
checkLibcxxSupport()
953+
checkLibstdcxxSupport()
954+
checkWatchpointSupport()
955+
checkDebugInfoSupport()
956+
checkDebugServerSupport()
957+
checkObjcSupport()
958+
checkForkVForkSupport()
959+
960960
skipped_categories_list = ", ".join(configuration.skip_categories)
961-
print("Skipping the following test categories: {}".format(skipped_categories_list))
961+
print("Skipping the following test categories: {}".format(configuration.skip_categories))
962962

963963
for testdir in configuration.testdirs:
964964
for (dirpath, dirnames, filenames) in os.walk(testdir):

lldb/packages/Python/lldbsuite/test/lldbplatformutil.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,23 @@ def finalize_build_dictionary(dictionary):
9898
return dictionary
9999

100100

101+
def _get_platform_os(p):
102+
# Use the triple to determine the platform if set.
103+
triple = p.GetTriple()
104+
if triple:
105+
platform = triple.split('-')[2]
106+
if platform.startswith('freebsd'):
107+
platform = 'freebsd'
108+
elif platform.startswith('netbsd'):
109+
platform = 'netbsd'
110+
return platform
111+
112+
return ''
113+
114+
101115
def getHostPlatform():
102116
"""Returns the host platform running the test suite."""
103-
# Attempts to return a platform name matching a target Triple platform.
104-
if sys.platform.startswith('linux'):
105-
return 'linux'
106-
elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
107-
return 'windows'
108-
elif sys.platform.startswith('darwin'):
109-
return 'macosx'
110-
elif sys.platform.startswith('freebsd'):
111-
return 'freebsd'
112-
elif sys.platform.startswith('netbsd'):
113-
return 'netbsd'
114-
else:
115-
return sys.platform
117+
return _get_platform_os(lldb.SBPlatform("host"))
116118

117119

118120
def getDarwinOSTriples():
@@ -130,16 +132,7 @@ def getPlatform():
130132
platform = 'ios'
131133
return platform
132134

133-
platform = configuration.lldb_platform_name
134-
if platform is None:
135-
platform = "host"
136-
if platform == "qemu-user":
137-
platform = "host"
138-
if platform == "host":
139-
return getHostPlatform()
140-
if platform.startswith("remote-"):
141-
return platform[7:]
142-
return platform
135+
return _get_platform_os(lldb.selected_platform)
143136

144137

145138
def platformIsDarwin():

0 commit comments

Comments
 (0)