[Lldb-commits] [lldb] 7e825ab - Repair support for launching ios/tv/watch simulator binaries through platform
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 19 09:42:54 PDT 2020
Author: Adrian Prantl
Date: 2020-06-19T09:42:44-07:00
New Revision: 7e825abd5704ce28b166f9463d4bd304348fd2a9
URL: https://github.com/llvm/llvm-project/commit/7e825abd5704ce28b166f9463d4bd304348fd2a9
DIFF: https://github.com/llvm/llvm-project/commit/7e825abd5704ce28b166f9463d4bd304348fd2a9.diff
LOG: Repair support for launching ios/tv/watch simulator binaries through platform
and delete a bunch (but not all) redundant code. If you compare the remaining implementations of Platform*Simulator.cpp, there is still an obvious leftover cleanup task.
Specifically, this patch
- removes SDK initialization from dotest (there is equivalent but more
complete code in Makefile.rules)
- make Platform*Simulator inherit the generic implementation of
PlatformAppleSimulator (more can be done here)
- simplify the platform logic in Makefile.rules
- replace the custom SDK finding logic in Platform*Simulator with XcodeSDK
- adds a test for each supported simulator
Differential Revision: https://reviews.llvm.org/D81980
Added:
lldb/test/API/macosx/simulator/Makefile
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
lldb/test/API/macosx/simulator/hello.c
Modified:
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
lldb/test/API/functionalities/fat_archives/Makefile
lldb/test/API/lang/objcxx/class-name-clash/Makefile
lldb/test/API/macosx/find-app-in-bundle/Makefile
lldb/test/API/macosx/find-app-in-bundle/TestFindAppInBundle.py
lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/Makefile
lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py
lldb/test/API/macosx/find-dsym/deep-bundle/Makefile
lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py
lldb/test/API/macosx/universal/Makefile
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 8668ddb0fb82..2b8185a18b77 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -300,13 +300,6 @@ def parseOptionsAndInitTestdirs():
if args.arch:
configuration.arch = args.arch
- if configuration.arch.startswith(
- 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
- configuration.sdkroot = seven.get_command_output(
- 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
- if not os.path.exists(configuration.sdkroot):
- configuration.sdkroot = seven.get_command_output(
- 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
else:
configuration.arch = platform_machine
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 410097f816af..ff2ac5a47ea5 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -41,7 +41,7 @@ def create_parser():
group.add_argument('-C', '--compiler', metavar='compiler', dest='compiler', help=textwrap.dedent(
'''Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times.'''))
if sys.platform == 'darwin':
- group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="macosx", help=textwrap.dedent(
+ group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="", help=textwrap.dedent(
'''Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK's toolchain.'''))
# FIXME? This won't work for
diff erent extra flags according to each arch.
group.add_argument(
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 554d32007e64..5316c51899c7 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -106,52 +106,54 @@ ifneq "$(TRIPLE)" ""
TRIPLE_ENV =$(word 4, $(triple_space))
ifeq "$(TRIPLE_VENDOR)" "apple"
ifeq "$(TRIPLE_OS)" "ios"
- CODESIGN := codesign
- ifeq "$(SDKROOT)" ""
- # Set SDKROOT if it wasn't set
- ifneq (,$(findstring arm,$(ARCH)))
- SDKROOT = $(shell xcrun --sdk iphoneos --show-sdk-path)
- ifeq "$(TRIPLE_VERSION)" ""
- TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
- endif
- ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
- else
- ifeq "$(TRIPLE_ENV)" "macabi"
- SDKROOT = $(shell xcrun --sdk macosx --show-sdk-path)
- else
- SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
- endif
- ifeq "$(TRIPLE_VERSION)" ""
- TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
- endif
- ifeq "$(TRIPLE_ENV)" "macabi"
- ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
- else
- ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
- endif
- endif
+ ifeq "$(TRIPLE_ENV)" "simulator"
+ SDK_NAME := iphonesimulator
+ else
+ ifeq "$(TRIPLE_ENV)" "macabi"
+ SDK_NAME := macosx
+ else
+ SDK_NAME := iphoneos
+ endif
+ endif
+ endif
+ ifeq "$(TRIPLE_OS)" "tvos"
+ ifeq "$(TRIPLE_ENV)" "simulator"
+ SDK_NAME := appletvsimulator
+ else
+ SDK_NAME := appletvos
endif
endif
ifeq "$(TRIPLE_OS)" "watchos"
- CODESIGN := codesign
- ifeq "$(SDKROOT)" ""
- # Set SDKROOT if it wasn't set
- ifneq (,$(findstring arm,$(ARCH)))
- SDKROOT = $(shell xcrun --sdk watchos --show-sdk-path)
- ifeq "$(TRIPLE_VERSION)" ""
- TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
- endif
- ARCH_CFLAGS :=-mwatchos-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
- else
- SDKROOT = $(shell xcrun --sdk watchsimulator --show-sdk-path)
- ifeq "$(TRIPLE_VERSION)" ""
- TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
- endif
- ARCH_CFLAGS :=-mwatchos-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
- endif
+ ifeq "$(TRIPLE_ENV)" "simulator"
+ SDK_NAME := watchsimulator
+ else
+ SDK_NAME := watchos
+ endif
+ endif
+ ifneq "$(TRIPLE_OS)" "macosx"
+ ifeq "$(TRIPLE_ENV)" ""
+ CODESIGN := codesign
+ endif
+ endif
+
+ ifeq "$(SDKROOT)" ""
+ SDKROOT := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-path)
+ endif
+ ifeq "$(TRIPLE_VERSION)" ""
+ ifeq "$(SDK_NAME)" ""
+ $(error "SDK_NAME is empty")
endif
+ TRIPLE_VERSION := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-version)
+ endif
+ ifeq "$(TRIPLE_ENV)" "simulator"
+ ARCH_CFLAGS := -m$(TRIPLE_OS)-simulator-version-min=$(TRIPLE_VERSION)
+ else
+ ifneq "$(TRIPLE_OS)" "macosx"
+ ARCH_CFLAGS := -m$(TRIPLE_OS)-version-min=$(TRIPLE_VERSION)
+ endif
endif
endif
+ ARCH_CFLAGS += -target $(TRIPLE)
endif
ifeq "$(OS)" "Android"
include $(THIS_FILE_DIR)/Android.rules
@@ -305,7 +307,7 @@ endif
# Use this one if you want to build one part of the result without debug information:
ifeq "$(OS)" "Darwin"
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) -isysroot "$(SDKROOT)"
else
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
endif
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 02a147660ebb..bd0a231303bd 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -35,9 +35,9 @@ void PlatformAppleSimulator::Initialize() { PlatformDarwin::Initialize(); }
void PlatformAppleSimulator::Terminate() { PlatformDarwin::Terminate(); }
/// Default Constructor
-PlatformAppleSimulator::PlatformAppleSimulator()
- : PlatformDarwin(true), m_core_sim_path_mutex(),
- m_core_simulator_framework_path(), m_device() {}
+PlatformAppleSimulator::PlatformAppleSimulator(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID kind)
+ : PlatformDarwin(true), m_kind(kind) {}
/// Destructor.
///
@@ -215,18 +215,11 @@ FileSpec PlatformAppleSimulator::GetCoreSimulatorPath() {
#if defined(__APPLE__)
std::lock_guard<std::mutex> guard(m_core_sim_path_mutex);
if (!m_core_simulator_framework_path.hasValue()) {
- if (FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
- std::string developer_dir = fspec.GetPath();
- StreamString cs_path;
- cs_path.Printf(
- "%s/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator",
- developer_dir.c_str());
- m_core_simulator_framework_path = FileSpec(cs_path.GetData());
- FileSystem::Instance().Resolve(*m_core_simulator_framework_path);
- } else
- m_core_simulator_framework_path = FileSpec();
+ m_core_simulator_framework_path =
+ FileSpec("/Library/Developer/PrivateFrameworks/CoreSimulator.framework/"
+ "CoreSimulator");
+ FileSystem::Instance().Resolve(*m_core_simulator_framework_path);
}
-
return m_core_simulator_framework_path.getValue();
#else
return FileSpec();
@@ -247,8 +240,7 @@ void PlatformAppleSimulator::LoadCoreSimulator() {
#if defined(__APPLE__)
CoreSimulatorSupport::Device PlatformAppleSimulator::GetSimulatorDevice() {
if (!m_device.hasValue()) {
- const CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id =
- CoreSimulatorSupport::DeviceType::ProductFamilyID::iPhone;
+ const CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id = m_kind;
std::string developer_dir = HostInfo::GetXcodeDeveloperDirectory().GetPath();
m_device = CoreSimulatorSupport::DeviceSet::GetAvailableDevices(
developer_dir.c_str())
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
index 446f4fa9d97d..8c0174f2946e 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
@@ -25,7 +25,8 @@ class PlatformAppleSimulator : public PlatformDarwin {
static void Terminate();
// Class Methods
- PlatformAppleSimulator();
+ PlatformAppleSimulator(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID kind);
virtual ~PlatformAppleSimulator();
@@ -47,6 +48,7 @@ class PlatformAppleSimulator : public PlatformDarwin {
std::mutex m_core_sim_path_mutex;
llvm::Optional<lldb_private::FileSpec> m_core_simulator_framework_path;
llvm::Optional<CoreSimulatorSupport::Device> m_device;
+ CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind;
lldb_private::FileSpec GetCoreSimulatorPath();
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
index 82114c709481..461624a2adaa 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
@@ -143,7 +143,8 @@ const char *PlatformAppleTVSimulator::GetDescriptionStatic() {
/// Default Constructor
PlatformAppleTVSimulator::PlatformAppleTVSimulator()
- : PlatformDarwin(true), m_sdk_dir_mutex(), m_sdk_directory() {}
+ : PlatformAppleSimulator(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID::appleTV) {}
/// Destructor.
///
@@ -153,9 +154,9 @@ PlatformAppleTVSimulator::~PlatformAppleTVSimulator() {}
void PlatformAppleTVSimulator::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
- const char *sdk_directory = GetSDKDirectoryAsCString();
- if (sdk_directory)
- strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ llvm::StringRef sdk_directory = GetSDKDirectoryAsCString();
+ if (!sdk_directory.empty())
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory.str().c_str());
else
strm.PutCString(" SDK Path: error: unable to locate SDK\n");
}
@@ -236,59 +237,12 @@ Status PlatformAppleTVSimulator::ResolveExecutable(
return error;
}
-static FileSystem::EnumerateDirectoryResult
-EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
- llvm::StringRef path) {
- if (ft == llvm::sys::fs::file_type::directory_file) {
- FileSpec file_spec(path);
- const char *filename = file_spec.GetFilename().GetCString();
- if (filename &&
- strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) ==
- 0) {
- ::snprintf((char *)baton, PATH_MAX, "%s", filename);
- return FileSystem::eEnumerateDirectoryResultQuit;
- }
- }
- return FileSystem::eEnumerateDirectoryResultNext;
-}
-
-const char *PlatformAppleTVSimulator::GetSDKDirectoryAsCString() {
- std::lock_guard<std::mutex> guard(m_sdk_dir_mutex);
- if (m_sdk_directory.empty()) {
- if (FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
- std::string developer_dir = fspec.GetPath();
- char sdks_directory[PATH_MAX];
- char sdk_dirname[PATH_MAX];
- sdk_dirname[0] = '\0';
- snprintf(sdks_directory, sizeof(sdks_directory),
- "%s/Platforms/AppleTVSimulator.platform/Developer/SDKs",
- developer_dir.c_str());
- FileSpec simulator_sdk_spec;
- bool find_directories = true;
- bool find_files = false;
- bool find_other = false;
- FileSystem::Instance().EnumerateDirectory(
- sdks_directory, find_directories, find_files, find_other,
- EnumerateDirectoryCallback, sdk_dirname);
-
- if (sdk_dirname[0]) {
- m_sdk_directory = sdks_directory;
- m_sdk_directory.append(1, '/');
- m_sdk_directory.append(sdk_dirname);
- return m_sdk_directory.c_str();
- }
- }
- // Assign a single NULL character so we know we tried to find the device
- // support directory and we don't keep trying to find it over and over.
- m_sdk_directory.assign(1, '\0');
- }
-
- // We should have put a single NULL character into m_sdk_directory or it
- // should have a valid path if the code gets here
- assert(m_sdk_directory.empty() == false);
- if (m_sdk_directory[0])
- return m_sdk_directory.c_str();
- return NULL;
+llvm::StringRef PlatformAppleTVSimulator::GetSDKDirectoryAsCString() {
+ llvm::StringRef sdk;
+ sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("AppleTVSimulator.Internal.sdk"));
+ if (sdk.empty())
+ sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("AppleTVSimulator.sdk"));
+ return sdk;
}
Status PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file,
@@ -299,10 +253,10 @@ Status PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file,
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
char resolved_path[PATH_MAX];
- const char *sdk_dir = GetSDKDirectoryAsCString();
- if (sdk_dir) {
- ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", sdk_dir,
- platform_file_path);
+ llvm::StringRef sdk_dir = GetSDKDirectoryAsCString();
+ if (!sdk_dir.empty()) {
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
+ sdk_dir.str().c_str(), platform_file_path);
// First try in the SDK and see if the file is in there
local_file.SetFile(resolved_path, FileSpec::Style::native);
@@ -378,6 +332,7 @@ bool PlatformAppleTVSimulator::GetSupportedArchitectureAtIndex(uint32_t idx,
arch = platform_arch;
if (arch.IsValid()) {
arch.GetTriple().setOS(llvm::Triple::TvOS);
+ arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
return true;
}
}
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
index 2cbd38d36635..5a7b0ee0d7dc 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
@@ -9,9 +9,9 @@
#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLETVSIMULATOR_H
#define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLETVSIMULATOR_H
-#include "PlatformDarwin.h"
+#include "PlatformAppleSimulator.h"
-class PlatformAppleTVSimulator : public PlatformDarwin {
+class PlatformAppleTVSimulator : public PlatformAppleSimulator {
public:
// Class Functions
static lldb::PlatformSP CreateInstance(bool force,
@@ -77,7 +77,7 @@ class PlatformAppleTVSimulator : public PlatformDarwin {
std::string m_sdk_directory;
std::string m_build_update;
- const char *GetSDKDirectoryAsCString();
+ llvm::StringRef GetSDKDirectoryAsCString();
private:
PlatformAppleTVSimulator(const PlatformAppleTVSimulator &) = delete;
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
index c345c0cf3f6f..03a8fcd31360 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
@@ -76,7 +76,8 @@ PlatformSP PlatformAppleWatchSimulator::CreateInstance(bool force,
bool create = force;
if (!create && arch && arch->IsValid()) {
switch (arch->GetMachine()) {
- case llvm::Triple::x86_64: {
+ case llvm::Triple::x86_64:
+ case llvm::Triple::x86: {
const llvm::Triple &triple = arch->GetTriple();
switch (triple.getVendor()) {
case llvm::Triple::Apple:
@@ -143,7 +144,8 @@ const char *PlatformAppleWatchSimulator::GetDescriptionStatic() {
/// Default Constructor
PlatformAppleWatchSimulator::PlatformAppleWatchSimulator()
- : PlatformDarwin(true), m_sdk_directory() {}
+ : PlatformAppleSimulator(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID::appleWatch) {}
/// Destructor.
///
@@ -153,9 +155,9 @@ PlatformAppleWatchSimulator::~PlatformAppleWatchSimulator() {}
void PlatformAppleWatchSimulator::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
- const char *sdk_directory = GetSDKDirectoryAsCString();
- if (sdk_directory)
- strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ llvm::StringRef sdk_directory = GetSDKDirectoryAsCString();
+ if (!sdk_directory.empty())
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory.str().c_str());
else
strm.PutCString(" SDK Path: error: unable to locate SDK\n");
}
@@ -236,59 +238,12 @@ Status PlatformAppleWatchSimulator::ResolveExecutable(
return error;
}
-static FileSystem::EnumerateDirectoryResult
-EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
- llvm::StringRef path) {
- if (ft == llvm::sys::fs::file_type::directory_file) {
- FileSpec file_spec(path);
- const char *filename = file_spec.GetFilename().GetCString();
- if (filename &&
- strncmp(filename, "AppleWatchSimulator",
- strlen("AppleWatchSimulator")) == 0) {
- ::snprintf((char *)baton, PATH_MAX, "%s", filename);
- return FileSystem::eEnumerateDirectoryResultQuit;
- }
- }
- return FileSystem::eEnumerateDirectoryResultNext;
-}
-
-const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() {
- std::lock_guard<std::mutex> guard(m_sdk_dir_mutex);
- if (m_sdk_directory.empty()) {
- if (FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
- std::string developer_dir = fspec.GetPath();
- char sdks_directory[PATH_MAX];
- char sdk_dirname[PATH_MAX];
- sdk_dirname[0] = '\0';
- snprintf(sdks_directory, sizeof(sdks_directory),
- "%s/Platforms/AppleWatchSimulator.platform/Developer/SDKs",
- developer_dir.c_str());
- FileSpec simulator_sdk_spec;
- bool find_directories = true;
- bool find_files = false;
- bool find_other = false;
- FileSystem::Instance().EnumerateDirectory(
- sdks_directory, find_directories, find_files, find_other,
- EnumerateDirectoryCallback, sdk_dirname);
-
- if (sdk_dirname[0]) {
- m_sdk_directory = sdks_directory;
- m_sdk_directory.append(1, '/');
- m_sdk_directory.append(sdk_dirname);
- return m_sdk_directory.c_str();
- }
- }
- // Assign a single NULL character so we know we tried to find the device
- // support directory and we don't keep trying to find it over and over.
- m_sdk_directory.assign(1, '\0');
- }
-
- // We should have put a single NULL character into m_sdk_directory or it
- // should have a valid path if the code gets here
- assert(m_sdk_directory.empty() == false);
- if (m_sdk_directory[0])
- return m_sdk_directory.c_str();
- return NULL;
+llvm::StringRef PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() {
+ llvm::StringRef sdk;
+ sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("WatchSimulator.Internal.sdk"));
+ if (sdk.empty())
+ sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("WatchSimulator.sdk"));
+ return sdk;
}
Status PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file,
@@ -299,10 +254,10 @@ Status PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file,
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
char resolved_path[PATH_MAX];
- const char *sdk_dir = GetSDKDirectoryAsCString();
- if (sdk_dir) {
- ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", sdk_dir,
- platform_file_path);
+ llvm::StringRef sdk_dir = GetSDKDirectoryAsCString();
+ if (!sdk_dir.empty()) {
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
+ sdk_dir.str().c_str(), platform_file_path);
// First try in the SDK and see if the file is in there
local_file.SetFile(resolved_path, FileSpec::Style::native);
@@ -372,13 +327,20 @@ uint32_t PlatformAppleWatchSimulator::FindProcesses(
bool PlatformAppleWatchSimulator::GetSupportedArchitectureAtIndex(
uint32_t idx, ArchSpec &arch) {
- static const ArchSpec platform_arch(
- HostInfo::GetArchitecture(HostInfo::eArchKind64));
-
if (idx == 0) {
- arch = platform_arch;
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ if (arch.IsValid()) {
+ arch.GetTriple().setOS(llvm::Triple::WatchOS);
+ arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
+ return true;
+ }
+ }
+
+ if (idx == 1) {
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind64);
if (arch.IsValid()) {
arch.GetTriple().setOS(llvm::Triple::WatchOS);
+ arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
return true;
}
}
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
index cd80ece62f91..96dcd16ffa99 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
@@ -9,9 +9,9 @@
#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLEWATCHSIMULATOR_H
#define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMAPPLEWATCHSIMULATOR_H
-#include "PlatformDarwin.h"
+#include "PlatformAppleSimulator.h"
-class PlatformAppleWatchSimulator : public PlatformDarwin {
+class PlatformAppleWatchSimulator : public PlatformAppleSimulator {
public:
// Class Functions
static lldb::PlatformSP CreateInstance(bool force,
@@ -77,7 +77,7 @@ class PlatformAppleWatchSimulator : public PlatformDarwin {
std::string m_sdk_directory;
std::string m_build_update;
- const char *GetSDKDirectoryAsCString();
+ llvm::StringRef GetSDKDirectoryAsCString();
private:
PlatformAppleWatchSimulator(const PlatformAppleWatchSimulator &) = delete;
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
index 1a3e08714864..a890d0afdf1e 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
@@ -147,8 +147,8 @@ const char *PlatformiOSSimulator::GetDescriptionStatic() {
/// Default Constructor
PlatformiOSSimulator::PlatformiOSSimulator()
- : PlatformAppleSimulator(), m_sdk_dir_mutex(), m_sdk_directory(),
- m_build_update() {}
+ : PlatformAppleSimulator(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID::iPhone) {}
/// Destructor.
///
@@ -158,9 +158,9 @@ PlatformiOSSimulator::~PlatformiOSSimulator() {}
void PlatformiOSSimulator::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
- const char *sdk_directory = GetSDKDirectoryAsCString();
- if (sdk_directory)
- strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ llvm::StringRef sdk_directory = GetSDKDirectoryAsCString();
+ if (!sdk_directory.empty())
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory.str().c_str());
else
strm.PutCString(" SDK Path: error: unable to locate SDK\n");
PlatformAppleSimulator::GetStatus(strm);
@@ -242,58 +242,12 @@ Status PlatformiOSSimulator::ResolveExecutable(
return error;
}
-static FileSystem::EnumerateDirectoryResult
-EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
- llvm::StringRef path) {
- if (ft == llvm::sys::fs::file_type::directory_file) {
- FileSpec file_spec(path);
- const char *filename = file_spec.GetFilename().GetCString();
- if (filename &&
- strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) {
- ::snprintf((char *)baton, PATH_MAX, "%s", filename);
- return FileSystem::eEnumerateDirectoryResultQuit;
- }
- }
- return FileSystem::eEnumerateDirectoryResultNext;
-}
-
-const char *PlatformiOSSimulator::GetSDKDirectoryAsCString() {
- std::lock_guard<std::mutex> guard(m_sdk_dir_mutex);
- if (m_sdk_directory.empty()) {
- if (FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
- std::string developer_dir = fspec.GetPath();
- char sdks_directory[PATH_MAX];
- char sdk_dirname[PATH_MAX];
- sdk_dirname[0] = '\0';
- snprintf(sdks_directory, sizeof(sdks_directory),
- "%s/Platforms/iPhoneSimulator.platform/Developer/SDKs",
- developer_dir.c_str());
- FileSpec simulator_sdk_spec;
- bool find_directories = true;
- bool find_files = false;
- bool find_other = false;
- FileSystem::Instance().EnumerateDirectory(
- sdks_directory, find_directories, find_files, find_other,
- EnumerateDirectoryCallback, sdk_dirname);
-
- if (sdk_dirname[0]) {
- m_sdk_directory = sdks_directory;
- m_sdk_directory.append(1, '/');
- m_sdk_directory.append(sdk_dirname);
- return m_sdk_directory.c_str();
- }
- }
- // Assign a single NULL character so we know we tried to find the device
- // support directory and we don't keep trying to find it over and over.
- m_sdk_directory.assign(1, '\0');
- }
-
- // We should have put a single NULL character into m_sdk_directory or it
- // should have a valid path if the code gets here
- assert(m_sdk_directory.empty() == false);
- if (m_sdk_directory[0])
- return m_sdk_directory.c_str();
- return NULL;
+llvm::StringRef PlatformiOSSimulator::GetSDKDirectoryAsCString() {
+ llvm::StringRef sdk;
+ sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("iPhoneSimulator.Internal.sdk"));
+ if (sdk.empty())
+ sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("iPhoneSimulator.sdk"));
+ return sdk;
}
Status PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file,
@@ -304,10 +258,10 @@ Status PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file,
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
char resolved_path[PATH_MAX];
- const char *sdk_dir = GetSDKDirectoryAsCString();
- if (sdk_dir) {
- ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", sdk_dir,
- platform_file_path);
+ llvm::StringRef sdk_dir = GetSDKDirectoryAsCString();
+ if (!sdk_dir.empty()) {
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
+ sdk_dir.str().c_str(), platform_file_path);
// First try in the SDK and see if the file is in there
local_file.SetFile(resolved_path, FileSpec::Style::native);
@@ -385,6 +339,7 @@ bool PlatformiOSSimulator::GetSupportedArchitectureAtIndex(uint32_t idx,
arch = platform_arch;
if (arch.IsValid()) {
arch.GetTriple().setOS(llvm::Triple::IOS);
+ arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
return true;
}
} else {
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
index 9ede35d462a6..4d416d759bd2 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
@@ -79,7 +79,7 @@ class PlatformiOSSimulator : public PlatformAppleSimulator {
std::string m_sdk_directory;
std::string m_build_update;
- const char *GetSDKDirectoryAsCString();
+ llvm::StringRef GetSDKDirectoryAsCString();
private:
PlatformiOSSimulator(const PlatformiOSSimulator &) = delete;
diff --git a/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm b/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
index 1d08720df644..8f36640a66a5 100644
--- a/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
+++ b/lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
@@ -1,5 +1,4 @@
-//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ---------------*- C++
-//-*-===//
+//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -51,10 +50,12 @@ - (BOOL)bootWithOptions:(NSDictionary *)options error:(NSError **)error;
- (NSUInteger)state;
- (BOOL)shutdownWithError:(NSError **)error;
- (NSUUID *)UDID;
-- (pid_t)spawnWithPath:(NSString *)path
- options:(NSDictionary *)options
- terminationHandler:(void (^)(int status))terminationHandler
- error:(NSError **)error;
+- (BOOL)spawnWithPath:(NSString *)path
+ options:(nullable NSDictionary<NSString *, id> *)options
+ terminationQueue:(nullable dispatch_queue_t)terminationQueue
+ terminationHandler:(nullable void (^)(int status))terminationHandler
+ pid:(pid_t *_Nullable)pid
+ error:(NSError *__autoreleasing _Nullable *_Nullable)error;
@end
CoreSimulatorSupport::Process::Process(lldb::pid_t p) : m_pid(p), m_error() {}
@@ -468,9 +469,12 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info,
provided, path will be argv[0] */
#define kSimDeviceSpawnWaitForDebugger \
@"wait_for_debugger" /* An NSNumber (bool) */
+#define kSimDeviceSpawnStandalone @"standalone"
NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
+ options[kSimDeviceSpawnStandalone] = @(YES);
+
if (launch_info.GetFlags().Test(lldb::eLaunchFlagDebug))
[options setObject:@YES forKey:kSimDeviceSpawnWaitForDebugger];
@@ -527,16 +531,19 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info,
NSError *nserror;
- pid_t pid = [m_dev
+ pid_t pid;
+ BOOL success = [m_dev
spawnWithPath:[NSString stringWithUTF8String:launch_info
.GetExecutableFile()
.GetPath()
.c_str()]
options:options
+ terminationQueue:nil
terminationHandler:nil
+ pid:&pid
error:&nserror];
- if (pid < 0) {
+ if (!success) {
const char *nserror_string = [[nserror description] UTF8String];
error.SetErrorString(nserror_string ? nserror_string : "unable to launch");
}
diff --git a/lldb/test/API/functionalities/fat_archives/Makefile b/lldb/test/API/functionalities/fat_archives/Makefile
index 7fed83dc9eb0..f47f8786215b 100644
--- a/lldb/test/API/functionalities/fat_archives/Makefile
+++ b/lldb/test/API/functionalities/fat_archives/Makefile
@@ -1,15 +1,18 @@
-SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
-all: a.c clean
- $(CC) -arch i386 -g -c $(SRCDIR)/a.c
+all: clean $(EXE)
+
+include Makefile.rules
+
+$(EXE): a.c clean
+ $(CC) -isysroot "$(SDKROOT)" -arch i386 -g -c $(SRCDIR)/a.c
ar -q liba-i386.a a.o
ranlib liba-i386.a
- $(CC) -arch x86_64 -g -c $(SRCDIR)/a.c
+ $(CC) -isysroot "$(SDKROOT)" -arch x86_64 -g -c $(SRCDIR)/a.c
ar -q liba-x86_64.a a.o
ranlib liba-x86_64.a
lipo -create -output liba.a liba-i386.a liba-x86_64.a
- $(CC) -g -c $(SRCDIR)/main.c
- $(CC) -o a.out main.o -L. -la
+ $(CC) -isysroot "$(SDKROOT)" -g -c $(SRCDIR)/main.c
+ $(CC) -isysroot "$(SDKROOT)" -o a.out main.o -L. -la
-clean:
+clean::
rm -rf a.o a.out liba-i386.a liba-x86_64.a liba.a $(wildcard *un~ .*un~ main.o *.pyc)
diff --git a/lldb/test/API/lang/objcxx/class-name-clash/Makefile b/lldb/test/API/lang/objcxx/class-name-clash/Makefile
index bae88debbb1b..b2c98c223e72 100644
--- a/lldb/test/API/lang/objcxx/class-name-clash/Makefile
+++ b/lldb/test/API/lang/objcxx/class-name-clash/Makefile
@@ -1,9 +1,5 @@
OBJCXX_SOURCES := main.mm myobject.mm
include Makefile.rules
-CFLAGS_NO_DEBUG =
-ifeq "$(OS)" "Darwin"
- CFLAGS_NO_DEBUG += -arch $(ARCH)
-endif
# myobject.o needs to be built without debug info
myobject.o: myobject.mm
diff --git a/lldb/test/API/macosx/find-app-in-bundle/Makefile b/lldb/test/API/macosx/find-app-in-bundle/Makefile
index 9b1c15bc4230..62130458affb 100644
--- a/lldb/test/API/macosx/find-app-in-bundle/Makefile
+++ b/lldb/test/API/macosx/find-app-in-bundle/Makefile
@@ -1,17 +1,13 @@
-SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
-CC ?= clang
+C_SOURCES := main.c
+EXE := TestApp
+all: clean TestApp.app/Contents/MacOS/TestApp
-ifeq "$(ARCH)" ""
- ARCH = x86_64
-endif
+include Makefile.rules
-CFLAGS ?= -g -O0 -arch $(ARCH)
-
-all: TestApp.app/Contents/MacOS/TestApp
-
-TestApp.app/Contents/MacOS/TestApp: $(SRCDIR)/main.c
- $(CC) $(CFLAGS) -o TestApp $<
- rm -rf TestApp.app
+TestApp.app/Contents/MacOS/TestApp: $(EXE) $(DSYM)
cp -r $(SRCDIR)/TestApp.app .
mv TestApp TestApp.app/Contents/MacOS/TestApp
mv TestApp.dSYM TestApp.app.dSYM
+
+clean::
+ rm -rf $(EXE) TestApp.app TestApp.app.dSYM
diff --git a/lldb/test/API/macosx/find-app-in-bundle/TestFindAppInBundle.py b/lldb/test/API/macosx/find-app-in-bundle/TestFindAppInBundle.py
index 8e31b6d09e84..331bc6dae889 100644
--- a/lldb/test/API/macosx/find-app-in-bundle/TestFindAppInBundle.py
+++ b/lldb/test/API/macosx/find-app-in-bundle/TestFindAppInBundle.py
@@ -2,8 +2,6 @@
Make sure we can find the binary inside an app bundle.
"""
-
-
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
@@ -18,41 +16,8 @@ class FindAppInMacOSAppBundle(TestBase):
NO_DEBUG_INFO_TESTCASE = True
def test_find_app_in_bundle(self):
- """There can be many tests in a test case - describe this test here."""
- self.build()
- self.main_source_file = lldb.SBFileSpec("main.c")
- self.find_app_in_bundle_test()
-
- def find_app_in_bundle_test(self):
"""This reads in the .app, makes sure we get the right binary and can run it."""
-
- # This function starts a process, "a.out" by default, sets a source
- # breakpoint, runs to it, and returns the thread, process & target.
- # It optionally takes an SBLaunchOption argument if you want to pass
- # arguments or environment variables.
- exe = self.getBuildArtifact("TestApp.app")
- error = lldb.SBError()
- target = self.dbg.CreateTarget(exe, None, None, False, error)
- self.assertTrue(error.Success(), "Could not create target: %s"%(error.GetCString()))
- self.assertTrue(target.IsValid(), "Target: TestApp.app is not valid.")
- exe_module_spec = target.GetExecutable()
- self.assertTrue(exe_module_spec.GetFilename(), "TestApp")
-
- bkpt = target.BreakpointCreateBySourceRegex("Set a breakpoint here", self.main_source_file)
- self.assertEquals(bkpt.GetNumLocations(), 1, "Couldn't set a breakpoint in the main app")
-
- if lldbplatformutil.getPlatform() == "macosx":
- launch_info = lldb.SBLaunchInfo(None)
- launch_info.SetWorkingDirectory(self.get_process_working_directory())
-
- error = lldb.SBError()
- process = target.Launch(launch_info, error)
-
- self.assertTrue(process.IsValid(), "Could not create a valid process for TestApp: %s"%(error.GetCString()))
-
- # Frame #0 should be at our breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
-
- self.assertEquals(len(threads), 1, "Expected 1 thread to stop at breakpoint, %d did."%(len(threads)))
-
-
+ self.build()
+ lldbutil.run_to_source_breakpoint(
+ self, 'breakpoint here', lldb.SBFileSpec('main.c'),
+ exe_name=self.getBuildArtifact("TestApp.app"))
diff --git a/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/Makefile b/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/Makefile
index 658c9a938705..12781fd84776 100644
--- a/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/Makefile
+++ b/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/Makefile
@@ -1,13 +1,10 @@
-SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
-CC ?= clang
+EXE := find-bundle-with-dots-in-fn
-ifeq "$(ARCH)" ""
- ARCH = x86_64
-endif
+all: clean $(EXE)
-CFLAGS ?= -g -O0 -arch $(ARCH)
+include Makefile.rules
-all: clean
+$(EXE):
$(CC) $(CFLAGS) -dynamiclib -o com.apple.sbd $(SRCDIR)/bundle.c
mkdir com.apple.sbd.xpc
mv com.apple.sbd com.apple.sbd.xpc/
@@ -18,5 +15,5 @@ all: clean
tar cf - com.apple.sbd.xpc com.apple.sbd.xpc.dSYM | ( cd hide.app;tar xBpf -)
$(CC) $(CFLAGS) -o find-bundle-with-dots-in-fn $(SRCDIR)/main.c
-clean:
+clean::
rm -rf a.out a.out.dSYM hide.app com.apple.sbd com.apple.sbd.dSYM com.apple.sbd.xpc com.apple.sbd.xpc.dSYM find-bundle-with-dots-in-fn find-bundle-with-dots-in-fn.dSYM
diff --git a/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py b/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py
index 31676ffbae8c..793551259f9a 100644
--- a/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py
+++ b/lldb/test/API/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py
@@ -17,12 +17,6 @@ class BundleWithDotInFilenameTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfRemote
- @skipUnlessDarwin
- # This test is explicitly a dSYM test, it doesn't need to run for any other config, but
- # the following doesn't work, fixme.
- # @skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking explicitly for a dSYM")
-
def setUp(self):
TestBase.setUp(self)
self.source = 'main.c'
@@ -34,6 +28,10 @@ def tearDown(self):
# Call super's tearDown().
TestBase.tearDown(self)
+ @skipIfRemote
+ @skipUnlessDarwin
+ # This test is explicitly a dSYM test, it doesn't need to run for any other config.
+ @skipIf(debug_info=no_match(["dsym"]))
def test_attach_and_check_dsyms(self):
"""Test attach to binary, see if the bundle dSYM is found"""
exe = self.getBuildArtifact(exe_name)
diff --git a/lldb/test/API/macosx/find-dsym/deep-bundle/Makefile b/lldb/test/API/macosx/find-dsym/deep-bundle/Makefile
index b2a66c2ad41e..806c840c9f2e 100644
--- a/lldb/test/API/macosx/find-dsym/deep-bundle/Makefile
+++ b/lldb/test/API/macosx/find-dsym/deep-bundle/Makefile
@@ -1,13 +1,9 @@
-SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
-CC ?= clang
+EXE := deep-bundle
+all: clean $(EXE)
-ifeq "$(ARCH)" ""
- ARCH = x86_64
-endif
+include Makefile.rules
-CFLAGS ?= -g -O0 -arch $(ARCH)
-
-all: clean
+$(EXE):
$(CC) $(CFLAGS) -install_name $(shell pwd)/MyFramework.framework/Versions/A/MyFramework -dynamiclib -o MyFramework $(SRCDIR)/myframework.c
mkdir -p MyFramework.framework/Versions/A/Headers
mkdir -p MyFramework.framework/Versions/A/Resources
@@ -24,6 +20,5 @@ all: clean
tar cf - MyFramework.framework MyFramework.framework.dSYM | ( cd hide.app;tar xBpf -)
$(CC) $(CFLAGS) -o deep-bundle $(SRCDIR)/main.c -F. -framework MyFramework
-
-clean:
+clean::
rm -rf a.out a.out.dSYM deep-bundle deep-bundle.dSYM MyFramework.framework MyFramework.framework.dSYM MyFramework MyFramework.dSYM hide.app
diff --git a/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py b/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py
index 8dd30e34d943..379ff5d0a7ae 100644
--- a/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py
+++ b/lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py
@@ -16,12 +16,6 @@ class DeepBundleTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfRemote
- @skipUnlessDarwin
- # This test is explicitly a dSYM test, it doesn't need to run for any other config, but
- # the following doesn't work, fixme.
- # @skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking explicitly for a dSYM")
-
def setUp(self):
TestBase.setUp(self)
self.source = 'main.c'
@@ -33,6 +27,10 @@ def tearDown(self):
# Call super's tearDown().
TestBase.tearDown(self)
+ @skipIfRemote
+ @skipUnlessDarwin
+ # This test is explicitly a dSYM test, it doesn't need to run for any other config.
+ @skipIf(debug_info=no_match(["dsym"]))
def test_attach_and_check_dsyms(self):
"""Test attach to binary, see if the framework dSYM is found"""
exe = self.getBuildArtifact(exe_name)
@@ -67,6 +65,3 @@ def test_attach_and_check_dsyms(self):
i=i+1
self.assertTrue(found_module, "Check that we found the framework loaded in lldb's image list")
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/lldb/test/API/macosx/simulator/Makefile b/lldb/test/API/macosx/simulator/Makefile
new file mode 100644
index 000000000000..421e85117613
--- /dev/null
+++ b/lldb/test/API/macosx/simulator/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := hello.c
+
+include Makefile.rules
diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
new file mode 100644
index 000000000000..e9b26a4ee7d3
--- /dev/null
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -0,0 +1,46 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+import json
+import unittest2
+
+
+class TestSimulatorPlatformLaunching(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def run_with(self, arch, platform, os, env):
+ self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env, 'ARCH': arch})
+ lldbutil.run_to_source_breakpoint(self, "break here",
+ lldb.SBFileSpec("hello.c"))
+ self.expect('image list -b -t',
+ patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+
+ @skipUnlessDarwin
+ @skipIfDarwinEmbedded
+ @apple_simulator_test('iphone')
+ def test_ios(self):
+ """Test running an iOS simulator binary"""
+ self.run_with(arch=self.getArchitecture(),
+ os='ios', env='simulator',
+ platform='iphonesimulator')
+
+ @skipUnlessDarwin
+ @skipIfDarwinEmbedded
+ @apple_simulator_test('appletv')
+ def test_tvos(self):
+ """Test running an tvOS simulator binary"""
+ self.run_with(arch=self.getArchitecture(),
+ os='tvos', env='simulator',
+ platform='appletvsimulator')
+
+ @skipUnlessDarwin
+ @skipIfDarwinEmbedded
+ @apple_simulator_test('watch')
+ def test_watchos(self):
+ """Test running a 32-bit watchOS simulator binary"""
+ self.run_with(arch='i386',
+ os='watchos', env='simulator',
+ platform='watchsimulator')
diff --git a/lldb/test/API/macosx/simulator/hello.c b/lldb/test/API/macosx/simulator/hello.c
new file mode 100644
index 000000000000..9010d0e29515
--- /dev/null
+++ b/lldb/test/API/macosx/simulator/hello.c
@@ -0,0 +1,5 @@
+void puts(char *);
+int main(int argc, char **argv) {
+ puts("break here\n");
+ return 0;
+}
diff --git a/lldb/test/API/macosx/universal/Makefile b/lldb/test/API/macosx/universal/Makefile
index 7105181d8c66..a6926557015d 100644
--- a/lldb/test/API/macosx/universal/Makefile
+++ b/lldb/test/API/macosx/universal/Makefile
@@ -8,13 +8,13 @@ testit: testit.x86_64h testit.x86_64
lipo -create -o testit $^
testit.x86_64h: testit.x86_64h.o
- $(CC) -arch x86_64h -o testit.x86_64h $<
+ $(CC) -isysroot $(SDKROOT) -arch x86_64h -o testit.x86_64h $<
testit.x86_64: testit.x86_64.o
- $(CC) -arch x86_64 -o testit.x86_64 $<
+ $(CC) -isysroot $(SDKROOT) -arch x86_64 -o testit.x86_64 $<
testit.x86_64h.o: main.c
- $(CC) -g -O0 -arch x86_64h -c -o testit.x86_64h.o $<
+ $(CC) -isysroot $(SDKROOT) -g -O0 -arch x86_64h -c -o testit.x86_64h.o $<
testit.x86_64.o: main.c
- $(CC) -g -O0 -arch x86_64 -c -o testit.x86_64.o $<
+ $(CC) -isysroot $(SDKROOT) -g -O0 -arch x86_64 -c -o testit.x86_64.o $<
More information about the lldb-commits
mailing list