[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Tue Sep 6 15:57:50 2016
@@ -33,8 +33,8 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
// Define these constants from Linux mman.h for use when targeting
// remote linux systems even when host has different values.
@@ -51,352 +51,305 @@ static uint32_t g_initialize_count = 0;
/// Code to handle the PlatformLinux settings
//------------------------------------------------------------------
-namespace
-{
- class PlatformLinuxProperties : public Properties
- {
- public:
- PlatformLinuxProperties();
-
- ~PlatformLinuxProperties() override = default;
-
- static ConstString&
- GetSettingName ();
-
- private:
- static const PropertyDefinition*
- GetStaticPropertyDefinitions();
- };
+namespace {
+class PlatformLinuxProperties : public Properties {
+public:
+ PlatformLinuxProperties();
- typedef std::shared_ptr<PlatformLinuxProperties> PlatformLinuxPropertiesSP;
+ ~PlatformLinuxProperties() override = default;
-} // anonymous namespace
+ static ConstString &GetSettingName();
-PlatformLinuxProperties::PlatformLinuxProperties() :
- Properties ()
-{
- m_collection_sp.reset (new OptionValueProperties(GetSettingName ()));
- m_collection_sp->Initialize (GetStaticPropertyDefinitions ());
-}
-
-ConstString&
-PlatformLinuxProperties::GetSettingName ()
-{
- static ConstString g_setting_name("linux");
- return g_setting_name;
-}
-
-const PropertyDefinition*
-PlatformLinuxProperties::GetStaticPropertyDefinitions()
-{
- static PropertyDefinition
- g_properties[] =
- {
- { NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
- };
-
- return g_properties;
-}
-
-static const PlatformLinuxPropertiesSP &
-GetGlobalProperties()
-{
- static PlatformLinuxPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp.reset (new PlatformLinuxProperties ());
- return g_settings_sp;
-}
-
-void
-PlatformLinux::DebuggerInitialize (Debugger &debugger)
-{
- if (!PluginManager::GetSettingForPlatformPlugin (debugger, PlatformLinuxProperties::GetSettingName()))
- {
- const bool is_global_setting = true;
- PluginManager::CreateSettingForPlatformPlugin (debugger,
- GetGlobalProperties()->GetValueProperties(),
- ConstString ("Properties for the PlatformLinux plug-in."),
- is_global_setting);
- }
-}
+private:
+ static const PropertyDefinition *GetStaticPropertyDefinitions();
+};
-//------------------------------------------------------------------
+typedef std::shared_ptr<PlatformLinuxProperties> PlatformLinuxPropertiesSP;
-PlatformSP
-PlatformLinux::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
-
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
-
- log->Printf ("PlatformLinux::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
-
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getOS())
- {
- case llvm::Triple::Linux:
- create = true;
- break;
+} // anonymous namespace
-#if defined(__linux__)
- // Only accept "unknown" for the OS if the host is linux and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::OSType::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
-#endif
- default:
- break;
- }
- }
+PlatformLinuxProperties::PlatformLinuxProperties() : Properties() {
+ m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(GetStaticPropertyDefinitions());
+}
- if (create)
- {
- if (log)
- log->Printf ("PlatformLinux::%s() creating remote-linux platform", __FUNCTION__);
- return PlatformSP(new PlatformLinux(false));
- }
+ConstString &PlatformLinuxProperties::GetSettingName() {
+ static ConstString g_setting_name("linux");
+ return g_setting_name;
+}
- if (log)
- log->Printf ("PlatformLinux::%s() aborting creation of remote-linux platform", __FUNCTION__);
+const PropertyDefinition *
+PlatformLinuxProperties::GetStaticPropertyDefinitions() {
+ static PropertyDefinition g_properties[] = {
+ {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}};
- return PlatformSP();
+ return g_properties;
}
-ConstString
-PlatformLinux::GetPluginNameStatic (bool is_host)
-{
- if (is_host)
- {
- static ConstString g_host_name(Platform::GetHostPlatformName ());
- return g_host_name;
- }
- else
- {
- static ConstString g_remote_name("remote-linux");
- return g_remote_name;
- }
+static const PlatformLinuxPropertiesSP &GetGlobalProperties() {
+ static PlatformLinuxPropertiesSP g_settings_sp;
+ if (!g_settings_sp)
+ g_settings_sp.reset(new PlatformLinuxProperties());
+ return g_settings_sp;
}
-const char *
-PlatformLinux::GetPluginDescriptionStatic (bool is_host)
-{
- if (is_host)
- return "Local Linux user platform plug-in.";
- else
- return "Remote Linux user platform plug-in.";
+void PlatformLinux::DebuggerInitialize(Debugger &debugger) {
+ if (!PluginManager::GetSettingForPlatformPlugin(
+ debugger, PlatformLinuxProperties::GetSettingName())) {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForPlatformPlugin(
+ debugger, GetGlobalProperties()->GetValueProperties(),
+ ConstString("Properties for the PlatformLinux plug-in."),
+ is_global_setting);
+ }
}
-ConstString
-PlatformLinux::GetPluginName()
-{
- return GetPluginNameStatic(IsHost());
-}
+//------------------------------------------------------------------
-void
-PlatformLinux::Initialize ()
-{
- PlatformPOSIX::Initialize ();
+PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
+
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
+
+ log->Printf("PlatformLinux::%s(force=%s, arch={%s,%s})", __FUNCTION__,
+ force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getOS()) {
+ case llvm::Triple::Linux:
+ create = true;
+ break;
- if (g_initialize_count++ == 0)
- {
-#if defined(__linux__) && !defined(__ANDROID__)
- PlatformSP default_platform_sp (new PlatformLinux(true));
- default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
- Platform::SetHostPlatform (default_platform_sp);
+#if defined(__linux__)
+ // Only accept "unknown" for the OS if the host is linux and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::OSType::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
#endif
- PluginManager::RegisterPlugin(PlatformLinux::GetPluginNameStatic(false),
- PlatformLinux::GetPluginDescriptionStatic(false),
- PlatformLinux::CreateInstance,
- PlatformLinux::DebuggerInitialize);
+ default:
+ break;
}
-}
+ }
-void
-PlatformLinux::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformLinux::CreateInstance);
- }
- }
-
- PlatformPOSIX::Terminate ();
-}
+ if (create) {
+ if (log)
+ log->Printf("PlatformLinux::%s() creating remote-linux platform",
+ __FUNCTION__);
+ return PlatformSP(new PlatformLinux(false));
+ }
-Error
-PlatformLinux::ResolveExecutable (const ModuleSpec &ms,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec (ms);
-
- if (IsHost())
- {
- // If we have "ls" as the exe_file, resolve the executable location based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists())
- {
- resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
+ if (log)
+ log->Printf(
+ "PlatformLinux::%s() aborting creation of remote-linux platform",
+ __FUNCTION__);
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
+ return PlatformSP();
+}
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- {
- error.SetErrorStringWithFormat("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- else
- {
- if (m_remote_platform_sp)
- {
- error = GetCachedExecutable (resolved_module_spec, exe_module_sp, module_search_paths_ptr, *m_remote_platform_sp);
- }
- else
- {
- // We may connect to a process and use the provided executable (Don't use local $PATH).
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
- }
- }
+ConstString PlatformLinux::GetPluginNameStatic(bool is_host) {
+ if (is_host) {
+ static ConstString g_host_name(Platform::GetHostPlatformName());
+ return g_host_name;
+ } else {
+ static ConstString g_remote_name("remote-linux");
+ return g_remote_name;
+ }
+}
- if (error.Success())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- if (error.Fail())
- {
- // If we failed, it may be because the vendor and os aren't known. If that is the
- // case, try setting them to the host architecture and give it another try.
- llvm::Triple &module_triple = resolved_module_spec.GetArchitecture().GetTriple();
- bool is_vendor_specified = (module_triple.getVendor() != llvm::Triple::UnknownVendor);
- bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS);
- if (!is_vendor_specified || !is_os_specified)
- {
- const llvm::Triple &host_triple = HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
-
- if (!is_vendor_specified)
- module_triple.setVendorName (host_triple.getVendorName());
- if (!is_os_specified)
- module_triple.setOSName (host_triple.getOSName());
-
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- }
- }
-
- // TODO find out why exe_module_sp might be NULL
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
- {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- }
- else
- {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
+const char *PlatformLinux::GetPluginDescriptionStatic(bool is_host) {
+ if (is_host)
+ return "Local Linux user platform plug-in.";
+ else
+ return "Remote Linux user platform plug-in.";
+}
- return error;
+ConstString PlatformLinux::GetPluginName() {
+ return GetPluginNameStatic(IsHost());
}
-Error
-PlatformLinux::GetFileWithUUID (const FileSpec &platform_file,
- const UUID *uuid_ptr, FileSpec &local_file)
-{
- if (IsRemote())
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
- }
-
- // Default to the local case
- local_file = platform_file;
- return Error();
+void PlatformLinux::Initialize() {
+ PlatformPOSIX::Initialize();
+
+ if (g_initialize_count++ == 0) {
+#if defined(__linux__) && !defined(__ANDROID__)
+ PlatformSP default_platform_sp(new PlatformLinux(true));
+ default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+ Platform::SetHostPlatform(default_platform_sp);
+#endif
+ PluginManager::RegisterPlugin(
+ PlatformLinux::GetPluginNameStatic(false),
+ PlatformLinux::GetPluginDescriptionStatic(false),
+ PlatformLinux::CreateInstance, PlatformLinux::DebuggerInitialize);
+ }
+}
+
+void PlatformLinux::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformLinux::CreateInstance);
+ }
+ }
+
+ PlatformPOSIX::Terminate();
+}
+
+Error PlatformLinux::ResolveExecutable(
+ const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ ModuleSpec resolved_module_spec(ms);
+
+ if (IsHost()) {
+ // If we have "ls" as the exe_file, resolve the executable location based on
+ // the current path variables
+ if (!resolved_module_spec.GetFileSpec().Exists()) {
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+ }
+
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else {
+ error.SetErrorStringWithFormat(
+ "unable to find executable for '%s'",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ } else {
+ if (m_remote_platform_sp) {
+ error =
+ GetCachedExecutable(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, *m_remote_platform_sp);
+ } else {
+ // We may connect to a process and use the provided executable (Don't use
+ // local $PATH).
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else
+ error.SetErrorStringWithFormat("the platform is not currently "
+ "connected, and '%s' doesn't exist in "
+ "the system root.",
+ exe_path);
+ }
+ }
+
+ if (error.Success()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+ if (error.Fail()) {
+ // If we failed, it may be because the vendor and os aren't known. If
+ // that is the
+ // case, try setting them to the host architecture and give it another
+ // try.
+ llvm::Triple &module_triple =
+ resolved_module_spec.GetArchitecture().GetTriple();
+ bool is_vendor_specified =
+ (module_triple.getVendor() != llvm::Triple::UnknownVendor);
+ bool is_os_specified =
+ (module_triple.getOS() != llvm::Triple::UnknownOS);
+ if (!is_vendor_specified || !is_os_specified) {
+ const llvm::Triple &host_triple =
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
+
+ if (!is_vendor_specified)
+ module_triple.setVendorName(host_triple.getVendorName());
+ if (!is_os_specified)
+ module_triple.setOSName(host_triple.getOSName());
+
+ error = ModuleList::GetSharedModule(resolved_module_spec,
+ exe_module_sp, NULL, NULL, NULL);
+ }
+ }
+
+ // TODO find out why exe_module_sp might be NULL
+ if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain the architecture %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+ } else {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+ }
+
+ return error;
+}
+
+Error PlatformLinux::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+ }
+
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformLinux::PlatformLinux (bool is_host) :
- PlatformPOSIX(is_host) // This is the local host platform
-{
-}
+PlatformLinux::PlatformLinux(bool is_host)
+ : PlatformPOSIX(is_host) // This is the local host platform
+{}
//------------------------------------------------------------------
/// Destructor.
@@ -406,373 +359,359 @@ PlatformLinux::PlatformLinux (bool is_ho
//------------------------------------------------------------------
PlatformLinux::~PlatformLinux() = default;
-bool
-PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
- bool success = false;
- if (IsHost())
- {
- success = Platform::GetProcessInfo (pid, process_info);
- }
- else
- {
- if (m_remote_platform_sp)
- success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
- }
- return success;
+bool PlatformLinux::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ bool success = false;
+ if (IsHost()) {
+ success = Platform::GetProcessInfo(pid, process_info);
+ } else {
+ if (m_remote_platform_sp)
+ success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ }
+ return success;
}
uint32_t
-PlatformLinux::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- uint32_t match_count = 0;
- if (IsHost())
- {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses (match_info, process_infos);
- }
- else
- {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
- }
- return match_count;
-}
-
-bool
-PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- if (IsHost())
- {
- ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
- if (hostArch.GetTriple().isOSLinux())
- {
- if (idx == 0)
- {
- arch = hostArch;
- return arch.IsValid();
- }
- else if (idx == 1)
- {
- // If the default host architecture is 64-bit, look for a 32-bit variant
- if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit())
- {
- arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
- return arch.IsValid();
- }
- }
- }
- }
- else
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
-
- llvm::Triple triple;
- // Set the OS to linux
- triple.setOS(llvm::Triple::Linux);
- // Set the architecture
- switch (idx)
- {
- case 0: triple.setArchName("x86_64"); break;
- case 1: triple.setArchName("i386"); break;
- case 2: triple.setArchName("arm"); break;
- case 3: triple.setArchName("aarch64"); break;
- case 4: triple.setArchName("mips64"); break;
- case 5: triple.setArchName("hexagon"); break;
- case 6: triple.setArchName("mips"); break;
- case 7: triple.setArchName("mips64el"); break;
- case 8: triple.setArchName("mipsel"); break;
- case 9: triple.setArchName("s390x"); break;
- default: return false;
- }
- // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the vendor by
- // calling triple.SetVendorName("unknown") so that it is a "unspecified unknown".
- // This means when someone calls triple.GetVendorName() it will return an empty string
- // which indicates that the vendor can be set when two architectures are merged
-
- // Now set the triple into "arch" and return true
- arch.SetTriple(triple);
- return true;
- }
- return false;
-}
-
-void
-PlatformLinux::GetStatus (Stream &strm)
-{
- Platform::GetStatus(strm);
+PlatformLinux::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ uint32_t match_count = 0;
+ if (IsHost()) {
+ // Let the base class figure out the host details
+ match_count = Platform::FindProcesses(match_info, process_infos);
+ } else {
+ // If we are remote, we can only return results if we are connected
+ if (m_remote_platform_sp)
+ match_count =
+ m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ }
+ return match_count;
+}
+
+bool PlatformLinux::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ if (IsHost()) {
+ ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ if (hostArch.GetTriple().isOSLinux()) {
+ if (idx == 0) {
+ arch = hostArch;
+ return arch.IsValid();
+ } else if (idx == 1) {
+ // If the default host architecture is 64-bit, look for a 32-bit variant
+ if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) {
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ return arch.IsValid();
+ }
+ }
+ }
+ } else {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
+
+ llvm::Triple triple;
+ // Set the OS to linux
+ triple.setOS(llvm::Triple::Linux);
+ // Set the architecture
+ switch (idx) {
+ case 0:
+ triple.setArchName("x86_64");
+ break;
+ case 1:
+ triple.setArchName("i386");
+ break;
+ case 2:
+ triple.setArchName("arm");
+ break;
+ case 3:
+ triple.setArchName("aarch64");
+ break;
+ case 4:
+ triple.setArchName("mips64");
+ break;
+ case 5:
+ triple.setArchName("hexagon");
+ break;
+ case 6:
+ triple.setArchName("mips");
+ break;
+ case 7:
+ triple.setArchName("mips64el");
+ break;
+ case 8:
+ triple.setArchName("mipsel");
+ break;
+ case 9:
+ triple.setArchName("s390x");
+ break;
+ default:
+ return false;
+ }
+ // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
+ // vendor by
+ // calling triple.SetVendorName("unknown") so that it is a "unspecified
+ // unknown".
+ // This means when someone calls triple.GetVendorName() it will return an
+ // empty string
+ // which indicates that the vendor can be set when two architectures are
+ // merged
+
+ // Now set the triple into "arch" and return true
+ arch.SetTriple(triple);
+ return true;
+ }
+ return false;
+}
+
+void PlatformLinux::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
#ifndef LLDB_DISABLE_POSIX
- // Display local kernel information only when we are running in host mode.
- // Otherwise, we would end up printing non-Linux information (when running
- // on Mac OS for example).
- if (IsHost())
- {
- struct utsname un;
-
- if (uname(&un))
- return;
-
- strm.Printf (" Kernel: %s\n", un.sysname);
- strm.Printf (" Release: %s\n", un.release);
- strm.Printf (" Version: %s\n", un.version);
- }
+ // Display local kernel information only when we are running in host mode.
+ // Otherwise, we would end up printing non-Linux information (when running
+ // on Mac OS for example).
+ if (IsHost()) {
+ struct utsname un;
+
+ if (uname(&un))
+ return;
+
+ strm.Printf(" Kernel: %s\n", un.sysname);
+ strm.Printf(" Release: %s\n", un.release);
+ strm.Printf(" Version: %s\n", un.version);
+ }
#endif
}
int32_t
-PlatformLinux::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
-{
- int32_t resume_count = 0;
-
- // Always resume past the initial stop when we use eLaunchFlagDebug
- if (launch_info.GetFlags ().Test (eLaunchFlagDebug))
- {
- // Resume past the stop for the final exec into the true inferior.
- ++resume_count;
- }
-
- // If we're not launching a shell, we're done.
- const FileSpec &shell = launch_info.GetShell();
- if (!shell)
- return resume_count;
+PlatformLinux::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
+ int32_t resume_count = 0;
- std::string shell_string = shell.GetPath();
- // We're in a shell, so for sure we have to resume past the shell exec.
+ // Always resume past the initial stop when we use eLaunchFlagDebug
+ if (launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+ // Resume past the stop for the final exec into the true inferior.
++resume_count;
+ }
- // Figure out what shell we're planning on using.
- const char *shell_name = strrchr (shell_string.c_str(), '/');
- if (shell_name == NULL)
- shell_name = shell_string.c_str();
- else
- shell_name++;
+ // If we're not launching a shell, we're done.
+ const FileSpec &shell = launch_info.GetShell();
+ if (!shell)
+ return resume_count;
- if (strcmp (shell_name, "csh") == 0
- || strcmp (shell_name, "tcsh") == 0
- || strcmp (shell_name, "zsh") == 0
- || strcmp (shell_name, "sh") == 0)
- {
- // These shells seem to re-exec themselves. Add another resume.
- ++resume_count;
- }
+ std::string shell_string = shell.GetPath();
+ // We're in a shell, so for sure we have to resume past the shell exec.
+ ++resume_count;
+
+ // Figure out what shell we're planning on using.
+ const char *shell_name = strrchr(shell_string.c_str(), '/');
+ if (shell_name == NULL)
+ shell_name = shell_string.c_str();
+ else
+ shell_name++;
+
+ if (strcmp(shell_name, "csh") == 0 || strcmp(shell_name, "tcsh") == 0 ||
+ strcmp(shell_name, "zsh") == 0 || strcmp(shell_name, "sh") == 0) {
+ // These shells seem to re-exec themselves. Add another resume.
+ ++resume_count;
+ }
- return resume_count;
+ return resume_count;
}
-bool
-PlatformLinux::CanDebugProcess ()
-{
- if (IsHost ())
- {
- return true;
- }
- else
- {
- // If we're connected, we can debug.
- return IsConnected ();
- }
+bool PlatformLinux::CanDebugProcess() {
+ if (IsHost()) {
+ return true;
+ } else {
+ // If we're connected, we can debug.
+ return IsConnected();
+ }
}
-// For local debugging, Linux will override the debug logic to use llgs-launch rather than
-// lldb-launch, llgs-attach. This differs from current lldb-launch, debugserver-attach
+// For local debugging, Linux will override the debug logic to use llgs-launch
+// rather than
+// lldb-launch, llgs-attach. This differs from current lldb-launch,
+// debugserver-attach
// approach on MacOSX.
lldb::ProcessSP
-PlatformLinux::DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf ("PlatformLinux::%s entered (target %p)", __FUNCTION__, static_cast<void*>(target));
+PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new
+ // target, else use existing one
+ Error &error) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("PlatformLinux::%s entered (target %p)", __FUNCTION__,
+ static_cast<void *>(target));
+
+ // If we're a remote host, use standard behavior from parent class.
+ if (!IsHost())
+ return PlatformPOSIX::DebugProcess(launch_info, debugger, target, error);
+
+ //
+ // For local debugging, we'll insist on having ProcessGDBRemote create the
+ // process.
+ //
+
+ ProcessSP process_sp;
+
+ // Make sure we stop at the entry point
+ launch_info.GetFlags().Set(eLaunchFlagDebug);
+
+ // We always launch the process we are going to debug in a separate process
+ // group, since then we can handle ^C interrupts ourselves w/o having to worry
+ // about the target getting them as well.
+ launch_info.SetLaunchInSeparateProcessGroup(true);
- // If we're a remote host, use standard behavior from parent class.
- if (!IsHost ())
- return PlatformPOSIX::DebugProcess (launch_info, debugger, target, error);
-
- //
- // For local debugging, we'll insist on having ProcessGDBRemote create the process.
- //
-
- ProcessSP process_sp;
-
- // Make sure we stop at the entry point
- launch_info.GetFlags ().Set (eLaunchFlagDebug);
+ // Ensure we have a target.
+ if (target == nullptr) {
+ if (log)
+ log->Printf("PlatformLinux::%s creating new target", __FUNCTION__);
- // We always launch the process we are going to debug in a separate process
- // group, since then we can handle ^C interrupts ourselves w/o having to worry
- // about the target getting them as well.
- launch_info.SetLaunchInSeparateProcessGroup(true);
+ TargetSP new_target_sp;
+ error = debugger.GetTargetList().CreateTarget(
+ debugger, nullptr, nullptr, false, nullptr, new_target_sp);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("PlatformLinux::%s failed to create new target: %s",
+ __FUNCTION__, error.AsCString());
+ return process_sp;
+ }
+
+ target = new_target_sp.get();
+ if (!target) {
+ error.SetErrorString("CreateTarget() returned nullptr");
+ if (log)
+ log->Printf("PlatformLinux::%s failed: %s", __FUNCTION__,
+ error.AsCString());
+ return process_sp;
+ }
+ } else {
+ if (log)
+ log->Printf("PlatformLinux::%s using provided target", __FUNCTION__);
+ }
- // Ensure we have a target.
- if (target == nullptr)
- {
- if (log)
- log->Printf ("PlatformLinux::%s creating new target", __FUNCTION__);
+ // Mark target as currently selected target.
+ debugger.GetTargetList().SetSelectedTarget(target);
- TargetSP new_target_sp;
- error = debugger.GetTargetList().CreateTarget (debugger,
- nullptr,
- nullptr,
- false,
- nullptr,
- new_target_sp);
- if (error.Fail ())
- {
- if (log)
- log->Printf ("PlatformLinux::%s failed to create new target: %s", __FUNCTION__, error.AsCString ());
- return process_sp;
- }
+ // Now create the gdb-remote process.
+ if (log)
+ log->Printf(
+ "PlatformLinux::%s having target create process with gdb-remote plugin",
+ __FUNCTION__);
+ process_sp = target->CreateProcess(
+ launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
- target = new_target_sp.get();
- if (!target)
- {
- error.SetErrorString ("CreateTarget() returned nullptr");
- if (log)
- log->Printf ("PlatformLinux::%s failed: %s", __FUNCTION__, error.AsCString ());
- return process_sp;
- }
- }
- else
- {
- if (log)
- log->Printf ("PlatformLinux::%s using provided target", __FUNCTION__);
- }
+ if (!process_sp) {
+ error.SetErrorString("CreateProcess() failed for gdb-remote process");
+ if (log)
+ log->Printf("PlatformLinux::%s failed: %s", __FUNCTION__,
+ error.AsCString());
+ return process_sp;
+ } else {
+ if (log)
+ log->Printf("PlatformLinux::%s successfully created process",
+ __FUNCTION__);
+ }
+
+ // Adjust launch for a hijacker.
+ ListenerSP listener_sp;
+ if (!launch_info.GetHijackListener()) {
+ if (log)
+ log->Printf("PlatformLinux::%s setting up hijacker", __FUNCTION__);
- // Mark target as currently selected target.
- debugger.GetTargetList().SetSelectedTarget(target);
+ listener_sp =
+ Listener::MakeListener("lldb.PlatformLinux.DebugProcess.hijack");
+ launch_info.SetHijackListener(listener_sp);
+ process_sp->HijackProcessEvents(listener_sp);
+ }
+
+ // Log file actions.
+ if (log) {
+ log->Printf(
+ "PlatformLinux::%s launching process with the following file actions:",
+ __FUNCTION__);
- // Now create the gdb-remote process.
- if (log)
- log->Printf ("PlatformLinux::%s having target create process with gdb-remote plugin", __FUNCTION__);
- process_sp = target->CreateProcess (launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
+ StreamString stream;
+ size_t i = 0;
+ const FileAction *file_action;
+ while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
+ file_action->Dump(stream);
+ log->PutCString(stream.GetString().c_str());
+ stream.Clear();
+ }
+ }
+
+ // Do the launch.
+ error = process_sp->Launch(launch_info);
+ if (error.Success()) {
+ // Handle the hijacking of process events.
+ if (listener_sp) {
+ const StateType state = process_sp->WaitForProcessToStop(
+ std::chrono::microseconds(0), NULL, false, listener_sp);
- if (!process_sp)
- {
- error.SetErrorString ("CreateProcess() failed for gdb-remote process");
- if (log)
- log->Printf ("PlatformLinux::%s failed: %s", __FUNCTION__, error.AsCString ());
- return process_sp;
- }
- else
- {
+ if (state == eStateStopped) {
if (log)
- log->Printf ("PlatformLinux::%s successfully created process", __FUNCTION__);
- }
-
- // Adjust launch for a hijacker.
- ListenerSP listener_sp;
- if (!launch_info.GetHijackListener ())
- {
+ log->Printf("PlatformLinux::%s pid %" PRIu64 " state %s\n",
+ __FUNCTION__, process_sp->GetID(), StateAsCString(state));
+ } else {
if (log)
- log->Printf ("PlatformLinux::%s setting up hijacker", __FUNCTION__);
-
- listener_sp = Listener::MakeListener("lldb.PlatformLinux.DebugProcess.hijack");
- launch_info.SetHijackListener (listener_sp);
- process_sp->HijackProcessEvents (listener_sp);
+ log->Printf("PlatformLinux::%s pid %" PRIu64
+ " state is not stopped - %s\n",
+ __FUNCTION__, process_sp->GetID(), StateAsCString(state));
+ }
+ }
+
+ // Hook up process PTY if we have one (which we should for local debugging
+ // with llgs).
+ int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) {
+ process_sp->SetSTDIOFileDescriptor(pty_fd);
+ if (log)
+ log->Printf("PlatformLinux::%s pid %" PRIu64
+ " hooked up STDIO pty to process",
+ __FUNCTION__, process_sp->GetID());
+ } else {
+ if (log)
+ log->Printf("PlatformLinux::%s pid %" PRIu64
+ " not using process STDIO pty",
+ __FUNCTION__, process_sp->GetID());
}
-
- // Log file actions.
+ } else {
if (log)
- {
- log->Printf ("PlatformLinux::%s launching process with the following file actions:", __FUNCTION__);
+ log->Printf("PlatformLinux::%s process launch failed: %s", __FUNCTION__,
+ error.AsCString());
+ // FIXME figure out appropriate cleanup here. Do we delete the target? Do
+ // we delete the process? Does our caller do that?
+ }
- StreamString stream;
- size_t i = 0;
- const FileAction *file_action;
- while ((file_action = launch_info.GetFileActionAtIndex (i++)) != nullptr)
- {
- file_action->Dump (stream);
- log->PutCString (stream.GetString().c_str ());
- stream.Clear();
- }
- }
+ return process_sp;
+}
- // Do the launch.
- error = process_sp->Launch(launch_info);
- if (error.Success ())
- {
- // Handle the hijacking of process events.
- if (listener_sp)
- {
- const StateType state =
- process_sp->WaitForProcessToStop(std::chrono::microseconds(0), NULL, false, listener_sp);
-
- if (state == eStateStopped)
- {
- if (log)
- log->Printf ("PlatformLinux::%s pid %" PRIu64 " state %s\n",
- __FUNCTION__, process_sp->GetID (), StateAsCString (state));
- }
- else
- {
- if (log)
- log->Printf ("PlatformLinux::%s pid %" PRIu64 " state is not stopped - %s\n",
- __FUNCTION__, process_sp->GetID (), StateAsCString (state));
- }
- }
+void PlatformLinux::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
+}
- // Hook up process PTY if we have one (which we should for local debugging with llgs).
- int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
- if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd)
- {
- process_sp->SetSTDIOFileDescriptor(pty_fd);
- if (log)
- log->Printf ("PlatformLinux::%s pid %" PRIu64 " hooked up STDIO pty to process", __FUNCTION__, process_sp->GetID ());
- }
- else
- {
- if (log)
- log->Printf ("PlatformLinux::%s pid %" PRIu64 " not using process STDIO pty", __FUNCTION__, process_sp->GetID ());
- }
- }
- else
- {
- if (log)
- log->Printf ("PlatformLinux::%s process launch failed: %s", __FUNCTION__, error.AsCString ());
- // FIXME figure out appropriate cleanup here. Do we delete the target? Do we delete the process? Does our caller do that?
- }
+uint64_t PlatformLinux::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) {
+ uint64_t flags_platform = 0;
+ uint64_t map_anon = MAP_ANON;
- return process_sp;
+ // To get correct flags for MIPS Architecture
+ if (arch.GetTriple().getArch() == llvm::Triple::mips64 ||
+ arch.GetTriple().getArch() == llvm::Triple::mips64el ||
+ arch.GetTriple().getArch() == llvm::Triple::mips ||
+ arch.GetTriple().getArch() == llvm::Triple::mipsel)
+ map_anon = 0x800;
+
+ if (flags & eMmapFlagsPrivate)
+ flags_platform |= MAP_PRIVATE;
+ if (flags & eMmapFlagsAnon)
+ flags_platform |= map_anon;
+ return flags_platform;
}
-void
-PlatformLinux::CalculateTrapHandlerSymbolNames ()
-{
- m_trap_handlers.push_back (ConstString ("_sigtramp"));
-}
-
-uint64_t
-PlatformLinux::ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags)
-{
- uint64_t flags_platform = 0;
- uint64_t map_anon = MAP_ANON;
-
- // To get correct flags for MIPS Architecture
- if (arch.GetTriple ().getArch () == llvm::Triple::mips64
- || arch.GetTriple ().getArch () == llvm::Triple::mips64el
- || arch.GetTriple ().getArch () == llvm::Triple::mips
- || arch.GetTriple ().getArch () == llvm::Triple::mipsel)
- map_anon = 0x800;
-
- if (flags & eMmapFlagsPrivate)
- flags_platform |= MAP_PRIVATE;
- if (flags & eMmapFlagsAnon)
- flags_platform |= map_anon;
- return flags_platform;
-}
-
-ConstString
-PlatformLinux::GetFullNameForDylib (ConstString basename)
-{
- if (basename.IsEmpty())
- return basename;
-
- StreamString stream;
- stream.Printf("lib%s.so", basename.GetCString());
- return ConstString(stream.GetData());
+ConstString PlatformLinux::GetFullNameForDylib(ConstString basename) {
+ if (basename.IsEmpty())
+ return basename;
+
+ StreamString stream;
+ stream.Printf("lib%s.so", basename.GetCString());
+ return ConstString(stream.GetData());
}
Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Tue Sep 6 15:57:50 2016
@@ -19,98 +19,72 @@
namespace lldb_private {
namespace platform_linux {
- class PlatformLinux : public PlatformPOSIX
- {
- public:
- PlatformLinux(bool is_host);
-
- ~PlatformLinux() override;
-
- static void
- DebuggerInitialize (Debugger &debugger);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const ArchSpec *arch);
-
- static ConstString
- GetPluginNameStatic (bool is_host);
-
- static const char *
- GetPluginDescriptionStatic (bool is_host);
-
- ConstString
- GetPluginName() override;
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- Error
- ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetPluginDescriptionStatic(IsHost());
- }
-
- void
- GetStatus (Stream &strm) override;
-
- Error
- GetFileWithUUID (const FileSpec &platform_file,
- const UUID* uuid, FileSpec &local_file) override;
-
- bool
- GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
- uint32_t
- FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) override;
-
- int32_t
- GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info) override;
-
- bool
- CanDebugProcess () override;
-
- lldb::ProcessSP
- DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target,
- Error &error) override;
-
- void
- CalculateTrapHandlerSymbolNames () override;
-
- uint64_t
- ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags) override;
-
- ConstString
- GetFullNameForDylib (ConstString basename) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (PlatformLinux);
- };
+class PlatformLinux : public PlatformPOSIX {
+public:
+ PlatformLinux(bool is_host);
+
+ ~PlatformLinux() override;
+
+ static void DebuggerInitialize(Debugger &debugger);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
+
+ static ConstString GetPluginNameStatic(bool is_host);
+
+ static const char *GetPluginDescriptionStatic(bool is_host);
+
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ Error ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override {
+ return GetPluginDescriptionStatic(IsHost());
+ }
+
+ void GetStatus(Stream &strm) override;
+
+ Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
+ FileSpec &local_file) override;
+
+ bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
+
+ uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+
+ int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
+
+ bool CanDebugProcess() override;
+
+ lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
+ Debugger &debugger, Target *target,
+ Error &error) override;
+
+ void CalculateTrapHandlerSymbolNames() override;
+
+ uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) override;
+
+ ConstString GetFullNameForDylib(ConstString basename) override;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformLinux);
+};
} // namespace platform_linux
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp Tue Sep 6 15:57:50 2016
@@ -35,28 +35,16 @@ using namespace lldb_private;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformAppleSimulator::Initialize ()
-{
- PlatformDarwin::Initialize ();
-}
+void PlatformAppleSimulator::Initialize() { PlatformDarwin::Initialize(); }
-void
-PlatformAppleSimulator::Terminate ()
-{
- PlatformDarwin::Terminate ();
-}
+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()
+ : PlatformDarwin(true), m_core_sim_path_mutex(),
+ m_core_simulator_framework_path(), m_device() {}
//------------------------------------------------------------------
/// Destructor.
@@ -64,242 +52,218 @@ PlatformAppleSimulator::PlatformAppleSim
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformAppleSimulator::~PlatformAppleSimulator()
-{
-}
+PlatformAppleSimulator::~PlatformAppleSimulator() {}
-lldb_private::Error
-PlatformAppleSimulator::LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info)
-{
+lldb_private::Error PlatformAppleSimulator::LaunchProcess(
+ lldb_private::ProcessLaunchInfo &launch_info) {
#if defined(__APPLE__)
- LoadCoreSimulator();
- CoreSimulatorSupport::Device device(GetSimulatorDevice());
-
- if (device.GetState() != CoreSimulatorSupport::Device::State::Booted)
- {
- Error boot_err;
- device.Boot(boot_err);
- if (boot_err.Fail())
- return boot_err;
- }
-
- auto spawned = device.Spawn(launch_info);
-
- if (spawned)
- {
- launch_info.SetProcessID(spawned.GetPID());
- return Error();
- }
- else
- return spawned.GetError();
+ LoadCoreSimulator();
+ CoreSimulatorSupport::Device device(GetSimulatorDevice());
+
+ if (device.GetState() != CoreSimulatorSupport::Device::State::Booted) {
+ Error boot_err;
+ device.Boot(boot_err);
+ if (boot_err.Fail())
+ return boot_err;
+ }
+
+ auto spawned = device.Spawn(launch_info);
+
+ if (spawned) {
+ launch_info.SetProcessID(spawned.GetPID());
+ return Error();
+ } else
+ return spawned.GetError();
#else
- Error err;
- err.SetErrorString(UNSUPPORTED_ERROR);
- return err;
+ Error err;
+ err.SetErrorString(UNSUPPORTED_ERROR);
+ return err;
#endif
}
-void
-PlatformAppleSimulator::GetStatus (Stream &strm)
-{
+void PlatformAppleSimulator::GetStatus(Stream &strm) {
#if defined(__APPLE__)
- // This will get called by subclasses, so just output status on the
- // current simulator
- PlatformAppleSimulator::LoadCoreSimulator();
-
- CoreSimulatorSupport::DeviceSet devices = CoreSimulatorSupport::DeviceSet::GetAvailableDevices(GetDeveloperDirectory());
- const size_t num_devices = devices.GetNumDevices();
- if (num_devices)
- {
- strm.Printf("Available devices:\n");
- for (size_t i=0; i<num_devices; ++i)
- {
- CoreSimulatorSupport::Device device = devices.GetDeviceAtIndex(i);
- strm.Printf(" %s: %s\n", device.GetUDID().c_str(), device.GetName().c_str());
- }
+ // This will get called by subclasses, so just output status on the
+ // current simulator
+ PlatformAppleSimulator::LoadCoreSimulator();
- if (m_device.hasValue() && m_device->operator bool())
- {
- strm.Printf("Current device: %s: %s", m_device->GetUDID().c_str(), m_device->GetName().c_str());
- if (m_device->GetState() == CoreSimulatorSupport::Device::State::Booted)
- {
- strm.Printf(" state = booted");
- }
- strm.Printf("\nType \"platform connect <ARG>\" where <ARG> is a device UDID or a device name to disconnect and connect to a different device.\n");
+ CoreSimulatorSupport::DeviceSet devices =
+ CoreSimulatorSupport::DeviceSet::GetAvailableDevices(
+ GetDeveloperDirectory());
+ const size_t num_devices = devices.GetNumDevices();
+ if (num_devices) {
+ strm.Printf("Available devices:\n");
+ for (size_t i = 0; i < num_devices; ++i) {
+ CoreSimulatorSupport::Device device = devices.GetDeviceAtIndex(i);
+ strm.Printf(" %s: %s\n", device.GetUDID().c_str(),
+ device.GetName().c_str());
+ }
- }
- else
- {
- strm.Printf("No current device is selected, \"platform connect <ARG>\" where <ARG> is a device UDID or a device name to connect to a specific device.\n");
- }
+ if (m_device.hasValue() && m_device->operator bool()) {
+ strm.Printf("Current device: %s: %s", m_device->GetUDID().c_str(),
+ m_device->GetName().c_str());
+ if (m_device->GetState() == CoreSimulatorSupport::Device::State::Booted) {
+ strm.Printf(" state = booted");
+ }
+ strm.Printf("\nType \"platform connect <ARG>\" where <ARG> is a device "
+ "UDID or a device name to disconnect and connect to a "
+ "different device.\n");
+ } else {
+ strm.Printf("No current device is selected, \"platform connect <ARG>\" "
+ "where <ARG> is a device UDID or a device name to connect to "
+ "a specific device.\n");
}
- else
- {
- strm.Printf("No devices are available.\n");
- }
+
+ } else {
+ strm.Printf("No devices are available.\n");
+ }
#else
- strm.Printf(UNSUPPORTED_ERROR);
+ strm.Printf(UNSUPPORTED_ERROR);
#endif
}
-Error
-PlatformAppleSimulator::ConnectRemote (Args& args)
-{
+Error PlatformAppleSimulator::ConnectRemote(Args &args) {
#if defined(__APPLE__)
- Error error;
- if (args.GetArgumentCount() == 1)
- {
- if (m_device)
- DisconnectRemote ();
- PlatformAppleSimulator::LoadCoreSimulator();
- const char *arg_cstr = args.GetArgumentAtIndex(0);
- if (arg_cstr)
- {
- std::string arg_str(arg_cstr);
- CoreSimulatorSupport::DeviceSet devices = CoreSimulatorSupport::DeviceSet::GetAvailableDevices(GetDeveloperDirectory());
- devices.ForEach([this, &arg_str](const CoreSimulatorSupport::Device &device) -> bool {
- if (arg_str == device.GetUDID() || arg_str == device.GetName())
- {
- m_device = device;
- return false; // Stop iterating
- }
- else
- {
- return true; // Keep iterating
- }
- });
- if (!m_device)
- error.SetErrorStringWithFormat("no device with UDID or name '%s' was found", arg_cstr);
- }
- }
- else
- {
- error.SetErrorString("this command take a single UDID argument of the device you want to connect to.");
+ Error error;
+ if (args.GetArgumentCount() == 1) {
+ if (m_device)
+ DisconnectRemote();
+ PlatformAppleSimulator::LoadCoreSimulator();
+ const char *arg_cstr = args.GetArgumentAtIndex(0);
+ if (arg_cstr) {
+ std::string arg_str(arg_cstr);
+ CoreSimulatorSupport::DeviceSet devices =
+ CoreSimulatorSupport::DeviceSet::GetAvailableDevices(
+ GetDeveloperDirectory());
+ devices.ForEach(
+ [this, &arg_str](const CoreSimulatorSupport::Device &device) -> bool {
+ if (arg_str == device.GetUDID() || arg_str == device.GetName()) {
+ m_device = device;
+ return false; // Stop iterating
+ } else {
+ return true; // Keep iterating
+ }
+ });
+ if (!m_device)
+ error.SetErrorStringWithFormat(
+ "no device with UDID or name '%s' was found", arg_cstr);
}
- return error;
+ } else {
+ error.SetErrorString("this command take a single UDID argument of the "
+ "device you want to connect to.");
+ }
+ return error;
#else
- Error err;
- err.SetErrorString(UNSUPPORTED_ERROR);
- return err;
+ Error err;
+ err.SetErrorString(UNSUPPORTED_ERROR);
+ return err;
#endif
}
-Error
-PlatformAppleSimulator::DisconnectRemote ()
-{
+Error PlatformAppleSimulator::DisconnectRemote() {
#if defined(__APPLE__)
- m_device.reset();
- return Error();
+ m_device.reset();
+ return Error();
#else
- Error err;
- err.SetErrorString(UNSUPPORTED_ERROR);
- return err;
+ Error err;
+ err.SetErrorString(UNSUPPORTED_ERROR);
+ return err;
#endif
}
-
-lldb::ProcessSP
-PlatformAppleSimulator::DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error)
-{
+lldb::ProcessSP PlatformAppleSimulator::DebugProcess(
+ ProcessLaunchInfo &launch_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new target, else use
+ // existing one
+ Error &error) {
#if defined(__APPLE__)
- ProcessSP process_sp;
- // Make sure we stop at the entry point
- launch_info.GetFlags ().Set (eLaunchFlagDebug);
- // We always launch the process we are going to debug in a separate process
- // group, since then we can handle ^C interrupts ourselves w/o having to worry
- // about the target getting them as well.
- launch_info.SetLaunchInSeparateProcessGroup(true);
-
- error = LaunchProcess (launch_info);
- if (error.Success())
- {
- if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
- {
- ProcessAttachInfo attach_info (launch_info);
- process_sp = Attach (attach_info, debugger, target, error);
- if (process_sp)
- {
- launch_info.SetHijackListener(attach_info.GetHijackListener());
-
- // Since we attached to the process, it will think it needs to detach
- // if the process object just goes away without an explicit call to
- // Process::Kill() or Process::Detach(), so let it know to kill the
- // process if this happens.
- process_sp->SetShouldDetach (false);
-
- // If we didn't have any file actions, the pseudo terminal might
- // have been used where the slave side was given as the file to
- // open for stdin/out/err after we have already opened the master
- // so we can read/write stdin/out/err.
- int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
- if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd)
- {
- process_sp->SetSTDIOFileDescriptor(pty_fd);
- }
- }
+ ProcessSP process_sp;
+ // Make sure we stop at the entry point
+ launch_info.GetFlags().Set(eLaunchFlagDebug);
+ // We always launch the process we are going to debug in a separate process
+ // group, since then we can handle ^C interrupts ourselves w/o having to worry
+ // about the target getting them as well.
+ launch_info.SetLaunchInSeparateProcessGroup(true);
+
+ error = LaunchProcess(launch_info);
+ if (error.Success()) {
+ if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
+ ProcessAttachInfo attach_info(launch_info);
+ process_sp = Attach(attach_info, debugger, target, error);
+ if (process_sp) {
+ launch_info.SetHijackListener(attach_info.GetHijackListener());
+
+ // Since we attached to the process, it will think it needs to detach
+ // if the process object just goes away without an explicit call to
+ // Process::Kill() or Process::Detach(), so let it know to kill the
+ // process if this happens.
+ process_sp->SetShouldDetach(false);
+
+ // If we didn't have any file actions, the pseudo terminal might
+ // have been used where the slave side was given as the file to
+ // open for stdin/out/err after we have already opened the master
+ // so we can read/write stdin/out/err.
+ int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) {
+ process_sp->SetSTDIOFileDescriptor(pty_fd);
}
+ }
}
+ }
- return process_sp;
+ return process_sp;
#else
- return ProcessSP();
+ return ProcessSP();
#endif
}
-FileSpec
-PlatformAppleSimulator::GetCoreSimulatorPath()
-{
+FileSpec PlatformAppleSimulator::GetCoreSimulatorPath() {
#if defined(__APPLE__)
- std::lock_guard<std::mutex> guard(m_core_sim_path_mutex);
- if (!m_core_simulator_framework_path.hasValue())
- {
- const char *developer_dir = GetDeveloperDirectory();
- if (developer_dir)
- {
- StreamString cs_path;
- cs_path.Printf("%s/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator", developer_dir);
- const bool resolve_path = true;
- m_core_simulator_framework_path = FileSpec(cs_path.GetData(), resolve_path);
- }
+ std::lock_guard<std::mutex> guard(m_core_sim_path_mutex);
+ if (!m_core_simulator_framework_path.hasValue()) {
+ const char *developer_dir = GetDeveloperDirectory();
+ if (developer_dir) {
+ StreamString cs_path;
+ cs_path.Printf(
+ "%s/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator",
+ developer_dir);
+ const bool resolve_path = true;
+ m_core_simulator_framework_path =
+ FileSpec(cs_path.GetData(), resolve_path);
}
-
- return m_core_simulator_framework_path.getValue();
+ }
+
+ return m_core_simulator_framework_path.getValue();
#else
- return FileSpec();
+ return FileSpec();
#endif
}
-void
-PlatformAppleSimulator::LoadCoreSimulator ()
-{
+void PlatformAppleSimulator::LoadCoreSimulator() {
#if defined(__APPLE__)
- static std::once_flag g_load_core_sim_flag;
- std::call_once(g_load_core_sim_flag, [this] {
- const std::string core_sim_path(GetCoreSimulatorPath().GetPath());
- if (core_sim_path.size())
- dlopen(core_sim_path.c_str(), RTLD_LAZY);
- });
+ static std::once_flag g_load_core_sim_flag;
+ std::call_once(g_load_core_sim_flag, [this] {
+ const std::string core_sim_path(GetCoreSimulatorPath().GetPath());
+ if (core_sim_path.size())
+ dlopen(core_sim_path.c_str(), RTLD_LAZY);
+ });
#endif
}
#if defined(__APPLE__)
-CoreSimulatorSupport::Device
-PlatformAppleSimulator::GetSimulatorDevice ()
-{
- if (!m_device.hasValue())
- {
- const CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id = CoreSimulatorSupport::DeviceType::ProductFamilyID::iPhone;
- m_device = CoreSimulatorSupport::DeviceSet::GetAvailableDevices(GetDeveloperDirectory()).GetFanciest(dev_id);
- }
-
- if (m_device.hasValue())
- return m_device.getValue();
- else
- return CoreSimulatorSupport::Device();
+CoreSimulatorSupport::Device PlatformAppleSimulator::GetSimulatorDevice() {
+ if (!m_device.hasValue()) {
+ const CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id =
+ CoreSimulatorSupport::DeviceType::ProductFamilyID::iPhone;
+ m_device = CoreSimulatorSupport::DeviceSet::GetAvailableDevices(
+ GetDeveloperDirectory())
+ .GetFanciest(dev_id);
+ }
+
+ if (m_device.hasValue())
+ return m_device.getValue();
+ else
+ return CoreSimulatorSupport::Device();
}
#endif
-
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h Tue Sep 6 15:57:50 2016
@@ -16,69 +16,57 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
#include "PlatformDarwin.h"
#include "PlatformiOSSimulatorCoreSimulatorSupport.h"
+#include "lldb/Host/FileSpec.h"
#include "llvm/ADT/Optional.h"
-class PlatformAppleSimulator : public PlatformDarwin
-{
+class PlatformAppleSimulator : public PlatformDarwin {
public:
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- //------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
- PlatformAppleSimulator ();
-
- virtual
- ~PlatformAppleSimulator();
-
- lldb_private::Error
- LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info) override;
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- lldb_private::Error
- ConnectRemote (lldb_private::Args& args) override;
-
- lldb_private::Error
- DisconnectRemote () override;
-
- lldb::ProcessSP
- DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Error &error) override;
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static void Initialize();
+
+ static void Terminate();
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ PlatformAppleSimulator();
+
+ virtual ~PlatformAppleSimulator();
+
+ lldb_private::Error
+ LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ lldb_private::Error ConnectRemote(lldb_private::Args &args) override;
+
+ lldb_private::Error DisconnectRemote() override;
+
+ lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
protected:
- std::mutex m_core_sim_path_mutex;
- llvm::Optional<lldb_private::FileSpec> m_core_simulator_framework_path;
- llvm::Optional<CoreSimulatorSupport::Device> m_device;
-
- lldb_private::FileSpec
- GetCoreSimulatorPath();
-
- void
- LoadCoreSimulator ();
-
+ std::mutex m_core_sim_path_mutex;
+ llvm::Optional<lldb_private::FileSpec> m_core_simulator_framework_path;
+ llvm::Optional<CoreSimulatorSupport::Device> m_device;
+
+ lldb_private::FileSpec GetCoreSimulatorPath();
+
+ void LoadCoreSimulator();
+
#if defined(__APPLE__)
- CoreSimulatorSupport::Device
- GetSimulatorDevice ();
+ CoreSimulatorSupport::Device GetSimulatorDevice();
#endif
-
+
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformAppleSimulator);
-
+ DISALLOW_COPY_AND_ASSIGN(PlatformAppleSimulator);
};
-#endif // liblldb_PlatformAppleSimulator_h_
+#endif // liblldb_PlatformAppleSimulator_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp Tue Sep 6 15:57:50 2016
@@ -39,139 +39,118 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformAppleTVSimulator::Initialize ()
-{
- PlatformDarwin::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformAppleTVSimulator::GetPluginNameStatic(),
- PlatformAppleTVSimulator::GetDescriptionStatic(),
- PlatformAppleTVSimulator::CreateInstance);
- }
-}
-
-void
-PlatformAppleTVSimulator::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformAppleTVSimulator::CreateInstance);
- }
- }
-
- PlatformDarwin::Terminate ();
-}
+void PlatformAppleTVSimulator::Initialize() {
+ PlatformDarwin::Initialize();
-PlatformSP
-PlatformAppleTVSimulator::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(
+ PlatformAppleTVSimulator::GetPluginNameStatic(),
+ PlatformAppleTVSimulator::GetDescriptionStatic(),
+ PlatformAppleTVSimulator::CreateInstance);
+ }
+}
+
+void PlatformAppleTVSimulator::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformAppleTVSimulator::CreateInstance);
+ }
+ }
+
+ PlatformDarwin::Terminate();
+}
+
+PlatformSP PlatformAppleTVSimulator::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
- log->Printf ("PlatformAppleTVSimulator::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
+ log->Printf("PlatformAppleTVSimulator::%s(force=%s, arch={%s,%s})",
+ __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::x86_64: {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor()) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::x86_64:
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getVendor())
- {
- case llvm::Triple::Apple:
- create = true;
- break;
-
#if defined(__APPLE__)
- // Only accept "unknown" for the vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for the vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
-
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::TvOS:
- break;
-
+ default:
+ break;
+ }
+
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::TvOS:
+ break;
+
#if defined(__APPLE__)
- // Only accept "unknown" for the OS if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
+ // Only accept "unknown" for the OS if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
#endif
- default:
- create = false;
- break;
- }
- }
- }
- break;
default:
- break;
+ create = false;
+ break;
}
+ }
+ } break;
+ default:
+ break;
}
- if (create)
- {
- if (log)
- log->Printf ("PlatformAppleTVSimulator::%s() creating platform", __FUNCTION__);
-
- return PlatformSP(new PlatformAppleTVSimulator ());
- }
-
+ }
+ if (create) {
if (log)
- log->Printf ("PlatformAppleTVSimulator::%s() aborting creation of platform", __FUNCTION__);
+ log->Printf("PlatformAppleTVSimulator::%s() creating platform",
+ __FUNCTION__);
- return PlatformSP();
-}
+ return PlatformSP(new PlatformAppleTVSimulator());
+ }
+ if (log)
+ log->Printf("PlatformAppleTVSimulator::%s() aborting creation of platform",
+ __FUNCTION__);
-lldb_private::ConstString
-PlatformAppleTVSimulator::GetPluginNameStatic ()
-{
- static ConstString g_name("tvos-simulator");
- return g_name;
+ return PlatformSP();
}
-const char *
-PlatformAppleTVSimulator::GetDescriptionStatic()
-{
- return "Apple TV simulator platform plug-in.";
+lldb_private::ConstString PlatformAppleTVSimulator::GetPluginNameStatic() {
+ static ConstString g_name("tvos-simulator");
+ return g_name;
}
+const char *PlatformAppleTVSimulator::GetDescriptionStatic() {
+ return "Apple TV simulator platform plug-in.";
+}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformAppleTVSimulator::PlatformAppleTVSimulator () :
- PlatformDarwin (true),
- m_sdk_directory ()
-{
-}
+PlatformAppleTVSimulator::PlatformAppleTVSimulator()
+ : PlatformDarwin(true), m_sdk_directory() {}
//------------------------------------------------------------------
/// Destructor.
@@ -179,288 +158,236 @@ PlatformAppleTVSimulator::PlatformAppleT
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-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);
- else
- strm.PutCString (" SDK Path: error: unable to locate SDK\n");
-}
-
-
-Error
-PlatformAppleTVSimulator::ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- ModuleSpec resolved_module_spec(module_spec);
-
- // If we have "ls" as the exe_file, resolve the executable loation based on
- // the current path variables
- // TODO: resolve bare executables in the Platform SDK
-// if (!resolved_exe_file.Exists())
-// resolved_exe_file.ResolveExecutableLocation ();
-
- // Resolve any executable within a bundle on MacOSX
- // TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact ARM slice wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- ArchSpec platform_arch;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- // Only match x86 with x86 and x86_64 with x86_64...
- if (!module_spec.GetArchitecture().IsValid() || module_spec.GetArchitecture().GetCore() == resolved_module_spec.GetArchitecture().GetCore())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (platform_arch.GetArchitectureName());
- }
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- module_spec.GetFileSpec().GetPath().c_str());
- }
+PlatformAppleTVSimulator::~PlatformAppleTVSimulator() {}
- return error;
-}
-
-static FileSpec::EnumerateDirectoryResult
-EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const FileSpec &file_spec)
-{
- if (file_type == FileSpec::eFileTypeDirectory)
- {
- const char *filename = file_spec.GetFilename().GetCString();
- if (filename && strncmp(filename, "AppleTVSimulator", strlen ("AppleTVSimulator")) == 0)
- {
- ::snprintf ((char *)baton, PATH_MAX, "%s", filename);
- return FileSpec::eEnumerateDirectoryResultQuit;
- }
- }
- return FileSpec::eEnumerateDirectoryResultNext;
-}
-
-
-
-const char *
-PlatformAppleTVSimulator::GetSDKDirectoryAsCString()
-{
- std::lock_guard<std::mutex> guard(m_mutex);
- if (m_sdk_directory.empty())
- {
- const char *developer_dir = GetDeveloperDirectory();
- if (developer_dir)
- {
- 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);
- FileSpec simulator_sdk_spec;
- bool find_directories = true;
- bool find_files = false;
- bool find_other = false;
- FileSpec::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();
- }
+void PlatformAppleTVSimulator::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+ const char *sdk_directory = GetSDKDirectoryAsCString();
+ if (sdk_directory)
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ else
+ strm.PutCString(" SDK Path: error: unable to locate SDK\n");
+}
+
+Error PlatformAppleTVSimulator::ResolveExecutable(
+ const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ ModuleSpec resolved_module_spec(module_spec);
+
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ // TODO: resolve bare executables in the Platform SDK
+ // if (!resolved_exe_file.Exists())
+ // resolved_exe_file.ResolveExecutableLocation ();
+
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one
+ // ourselves
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ ArchSpec platform_arch;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ // Only match x86 with x86 and x86_64 with x86_64...
+ if (!module_spec.GetArchitecture().IsValid() ||
+ module_spec.GetArchitecture().GetCore() ==
+ resolved_module_spec.GetArchitecture().GetCore()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
}
- // 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])
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(platform_arch.GetArchitectureName());
+ }
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat("'%s' does not exist",
+ module_spec.GetFileSpec().GetPath().c_str());
+ }
+
+ return error;
+}
+
+static FileSpec::EnumerateDirectoryResult
+EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
+ const FileSpec &file_spec) {
+ if (file_type == FileSpec::eFileTypeDirectory) {
+ const char *filename = file_spec.GetFilename().GetCString();
+ if (filename &&
+ strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) ==
+ 0) {
+ ::snprintf((char *)baton, PATH_MAX, "%s", filename);
+ return FileSpec::eEnumerateDirectoryResultQuit;
+ }
+ }
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+const char *PlatformAppleTVSimulator::GetSDKDirectoryAsCString() {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ if (m_sdk_directory.empty()) {
+ const char *developer_dir = GetDeveloperDirectory();
+ if (developer_dir) {
+ 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);
+ FileSpec simulator_sdk_spec;
+ bool find_directories = true;
+ bool find_files = false;
+ bool find_other = false;
+ FileSpec::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();
- return NULL;
-}
-
-Error
-PlatformAppleTVSimulator::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- Error error;
- char platform_file_path[PATH_MAX];
- 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);
-
- // First try in the SDK and see if the file is in there
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- return error;
-
- // Else fall back to the actual path itself
- local_file.SetFile(platform_file_path, true);
- if (local_file.Exists())
- return error;
-
- }
- error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
- platform_file_path,
- GetPluginName().GetCString());
- }
- else
- {
- error.SetErrorString ("invalid platform file argument");
+ }
}
- return error;
-}
-
-Error
-PlatformAppleTVSimulator::GetSharedModule (const ModuleSpec &module_spec,
- lldb_private::Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- // For AppleTV, the SDK files are all cached locally on the host
- // system. So first we ask for the file in the cached SDK,
- // then we attempt to get a shared module for the right architecture
- // with the right UUID.
- Error error;
- ModuleSpec platform_module_spec (module_spec);
- const FileSpec &platform_file = module_spec.GetFileSpec();
- error = GetSymbolFile (platform_file, module_spec.GetUUIDPtr(), platform_module_spec.GetFileSpec());
- if (error.Success())
- {
- error = ResolveExecutable (platform_module_spec, module_sp, module_search_paths_ptr);
- }
- else
- {
- const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr,
- always_create);
-
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(platform_file);
-
- return error;
-}
-
-
-uint32_t
-PlatformAppleTVSimulator::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- ProcessInstanceInfoList all_osx_process_infos;
- // First we get all OSX processes
- const uint32_t n = Host::FindProcesses (match_info, all_osx_process_infos);
-
- // Now we filter them down to only the TvOS triples
- for (uint32_t i=0; i<n; ++i)
- {
- const ProcessInstanceInfo &proc_info = all_osx_process_infos.GetProcessInfoAtIndex(i);
- if (proc_info.GetArchitecture().GetTriple().getOS() == llvm::Triple::TvOS) {
- process_infos.Append(proc_info);
- }
- }
- return process_infos.GetSize();
-}
-
-bool
-PlatformAppleTVSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- static const ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKind64));
-
- if (idx == 0)
- {
- arch = platform_arch;
- if (arch.IsValid())
- {
- arch.GetTriple().setOS (llvm::Triple::TvOS);
- return true;
- }
+ // 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;
+}
+
+Error PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ Error error;
+ char platform_file_path[PATH_MAX];
+ 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);
+
+ // First try in the SDK and see if the file is in there
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists())
+ return error;
+
+ // Else fall back to the actual path itself
+ local_file.SetFile(platform_file_path, true);
+ if (local_file.Exists())
+ return error;
+ }
+ error.SetErrorStringWithFormat(
+ "unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path, GetPluginName().GetCString());
+ } else {
+ error.SetErrorString("invalid platform file argument");
+ }
+ return error;
+}
+
+Error PlatformAppleTVSimulator::GetSharedModule(
+ const ModuleSpec &module_spec, lldb_private::Process *process,
+ ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
+ // For AppleTV, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ Error error;
+ ModuleSpec platform_module_spec(module_spec);
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
+ platform_module_spec.GetFileSpec());
+ if (error.Success()) {
+ error = ResolveExecutable(platform_module_spec, module_sp,
+ module_search_paths_ptr);
+ } else {
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr, always_create);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
+
+ return error;
+}
+
+uint32_t PlatformAppleTVSimulator::FindProcesses(
+ const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ ProcessInstanceInfoList all_osx_process_infos;
+ // First we get all OSX processes
+ const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
+
+ // Now we filter them down to only the TvOS triples
+ for (uint32_t i = 0; i < n; ++i) {
+ const ProcessInstanceInfo &proc_info =
+ all_osx_process_infos.GetProcessInfoAtIndex(i);
+ if (proc_info.GetArchitecture().GetTriple().getOS() == llvm::Triple::TvOS) {
+ process_infos.Append(proc_info);
+ }
+ }
+ return process_infos.GetSize();
+}
+
+bool PlatformAppleTVSimulator::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ static const ArchSpec platform_arch(
+ HostInfo::GetArchitecture(HostInfo::eArchKind64));
+
+ if (idx == 0) {
+ arch = platform_arch;
+ if (arch.IsValid()) {
+ arch.GetTriple().setOS(llvm::Triple::TvOS);
+ return true;
}
- return false;
+ }
+ return false;
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h Tue Sep 6 15:57:50 2016
@@ -16,106 +16,83 @@
// Project includes
#include "PlatformDarwin.h"
-class PlatformAppleTVSimulator : public PlatformDarwin
-{
+class PlatformAppleTVSimulator : public PlatformDarwin {
public:
-
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
- PlatformAppleTVSimulator ();
-
- virtual
- ~PlatformAppleTVSimulator();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- virtual lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- uint32_t
- FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneSimulator);
- }
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ PlatformAppleTVSimulator();
+
+ virtual ~PlatformAppleTVSimulator();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override { return GetDescriptionStatic(); }
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ virtual lldb_private::Error
+ GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ uint32_t
+ FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::iPhoneSimulator);
+ }
protected:
- std::string m_sdk_directory;
- std::string m_build_update;
-
- const char *
- GetSDKDirectoryAsCString();
+ std::string m_sdk_directory;
+ std::string m_build_update;
-private:
- DISALLOW_COPY_AND_ASSIGN (PlatformAppleTVSimulator);
+ const char *GetSDKDirectoryAsCString();
+private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformAppleTVSimulator);
};
-
-#endif // liblldb_PlatformAppleTVSimulator_h_
+#endif // liblldb_PlatformAppleTVSimulator_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp Tue Sep 6 15:57:50 2016
@@ -39,139 +39,120 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformAppleWatchSimulator::Initialize ()
-{
- PlatformDarwin::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformAppleWatchSimulator::GetPluginNameStatic(),
- PlatformAppleWatchSimulator::GetDescriptionStatic(),
- PlatformAppleWatchSimulator::CreateInstance);
- }
-}
-
-void
-PlatformAppleWatchSimulator::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformAppleWatchSimulator::CreateInstance);
- }
- }
-
- PlatformDarwin::Terminate ();
-}
+void PlatformAppleWatchSimulator::Initialize() {
+ PlatformDarwin::Initialize();
-PlatformSP
-PlatformAppleWatchSimulator::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(
+ PlatformAppleWatchSimulator::GetPluginNameStatic(),
+ PlatformAppleWatchSimulator::GetDescriptionStatic(),
+ PlatformAppleWatchSimulator::CreateInstance);
+ }
+}
+
+void PlatformAppleWatchSimulator::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(
+ PlatformAppleWatchSimulator::CreateInstance);
+ }
+ }
+
+ PlatformDarwin::Terminate();
+}
+
+PlatformSP PlatformAppleWatchSimulator::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
- log->Printf ("PlatformAppleWatchSimulator::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
+ log->Printf("PlatformAppleWatchSimulator::%s(force=%s, arch={%s,%s})",
+ __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::x86_64: {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor()) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::x86_64:
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getVendor())
- {
- case llvm::Triple::Apple:
- create = true;
- break;
-
#if defined(__APPLE__)
- // Only accept "unknown" for the vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for the vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
-
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::WatchOS:
- break;
-
+ default:
+ break;
+ }
+
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::WatchOS:
+ break;
+
#if defined(__APPLE__)
- // Only accept "unknown" for the OS if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
+ // Only accept "unknown" for the OS if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
#endif
- default:
- create = false;
- break;
- }
- }
- }
- break;
default:
- break;
+ create = false;
+ break;
}
+ }
+ } break;
+ default:
+ break;
}
- if (create)
- {
- if (log)
- log->Printf ("PlatformAppleWatchSimulator::%s() creating platform", __FUNCTION__);
-
- return PlatformSP(new PlatformAppleWatchSimulator ());
- }
-
+ }
+ if (create) {
if (log)
- log->Printf ("PlatformAppleWatchSimulator::%s() aborting creation of platform", __FUNCTION__);
+ log->Printf("PlatformAppleWatchSimulator::%s() creating platform",
+ __FUNCTION__);
- return PlatformSP();
-}
+ return PlatformSP(new PlatformAppleWatchSimulator());
+ }
+ if (log)
+ log->Printf(
+ "PlatformAppleWatchSimulator::%s() aborting creation of platform",
+ __FUNCTION__);
-lldb_private::ConstString
-PlatformAppleWatchSimulator::GetPluginNameStatic ()
-{
- static ConstString g_name("watchos-simulator");
- return g_name;
+ return PlatformSP();
}
-const char *
-PlatformAppleWatchSimulator::GetDescriptionStatic()
-{
- return "Apple Watch simulator platform plug-in.";
+lldb_private::ConstString PlatformAppleWatchSimulator::GetPluginNameStatic() {
+ static ConstString g_name("watchos-simulator");
+ return g_name;
}
+const char *PlatformAppleWatchSimulator::GetDescriptionStatic() {
+ return "Apple Watch simulator platform plug-in.";
+}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformAppleWatchSimulator::PlatformAppleWatchSimulator () :
- PlatformDarwin (true),
- m_sdk_directory ()
-{
-}
+PlatformAppleWatchSimulator::PlatformAppleWatchSimulator()
+ : PlatformDarwin(true), m_sdk_directory() {}
//------------------------------------------------------------------
/// Destructor.
@@ -179,288 +160,237 @@ PlatformAppleWatchSimulator::PlatformApp
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-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);
- else
- strm.PutCString (" SDK Path: error: unable to locate SDK\n");
-}
-
-
-Error
-PlatformAppleWatchSimulator::ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- ModuleSpec resolved_module_spec(module_spec);
-
- // If we have "ls" as the exe_file, resolve the executable loation based on
- // the current path variables
- // TODO: resolve bare executables in the Platform SDK
-// if (!resolved_exe_file.Exists())
-// resolved_exe_file.ResolveExecutableLocation ();
-
- // Resolve any executable within a bundle on MacOSX
- // TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact ARM slice wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- ArchSpec platform_arch;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- // Only match x86 with x86 and x86_64 with x86_64...
- if (!module_spec.GetArchitecture().IsValid() || module_spec.GetArchitecture().GetCore() == resolved_module_spec.GetArchitecture().GetCore())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (platform_arch.GetArchitectureName());
- }
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- module_spec.GetFileSpec().GetPath().c_str());
- }
+PlatformAppleWatchSimulator::~PlatformAppleWatchSimulator() {}
- return error;
-}
-
-static FileSpec::EnumerateDirectoryResult
-EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const FileSpec &file_spec)
-{
- if (file_type == FileSpec::eFileTypeDirectory)
- {
- const char *filename = file_spec.GetFilename().GetCString();
- if (filename && strncmp(filename, "AppleWatchSimulator", strlen ("AppleWatchSimulator")) == 0)
- {
- ::snprintf ((char *)baton, PATH_MAX, "%s", filename);
- return FileSpec::eEnumerateDirectoryResultQuit;
- }
- }
- return FileSpec::eEnumerateDirectoryResultNext;
-}
-
-
-
-const char *
-PlatformAppleWatchSimulator::GetSDKDirectoryAsCString()
-{
- std::lock_guard<std::mutex> guard(m_mutex);
- if (m_sdk_directory.empty())
- {
- const char *developer_dir = GetDeveloperDirectory();
- if (developer_dir)
- {
- 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);
- FileSpec simulator_sdk_spec;
- bool find_directories = true;
- bool find_files = false;
- bool find_other = false;
- FileSpec::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();
- }
+void PlatformAppleWatchSimulator::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+ const char *sdk_directory = GetSDKDirectoryAsCString();
+ if (sdk_directory)
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ else
+ strm.PutCString(" SDK Path: error: unable to locate SDK\n");
+}
+
+Error PlatformAppleWatchSimulator::ResolveExecutable(
+ const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ ModuleSpec resolved_module_spec(module_spec);
+
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ // TODO: resolve bare executables in the Platform SDK
+ // if (!resolved_exe_file.Exists())
+ // resolved_exe_file.ResolveExecutableLocation ();
+
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one
+ // ourselves
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ ArchSpec platform_arch;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ // Only match x86 with x86 and x86_64 with x86_64...
+ if (!module_spec.GetArchitecture().IsValid() ||
+ module_spec.GetArchitecture().GetCore() ==
+ resolved_module_spec.GetArchitecture().GetCore()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
}
- // 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])
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(platform_arch.GetArchitectureName());
+ }
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat("'%s' does not exist",
+ module_spec.GetFileSpec().GetPath().c_str());
+ }
+
+ return error;
+}
+
+static FileSpec::EnumerateDirectoryResult
+EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
+ const FileSpec &file_spec) {
+ if (file_type == FileSpec::eFileTypeDirectory) {
+ const char *filename = file_spec.GetFilename().GetCString();
+ if (filename &&
+ strncmp(filename, "AppleWatchSimulator",
+ strlen("AppleWatchSimulator")) == 0) {
+ ::snprintf((char *)baton, PATH_MAX, "%s", filename);
+ return FileSpec::eEnumerateDirectoryResultQuit;
+ }
+ }
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ if (m_sdk_directory.empty()) {
+ const char *developer_dir = GetDeveloperDirectory();
+ if (developer_dir) {
+ 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);
+ FileSpec simulator_sdk_spec;
+ bool find_directories = true;
+ bool find_files = false;
+ bool find_other = false;
+ FileSpec::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();
- return NULL;
-}
-
-Error
-PlatformAppleWatchSimulator::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- Error error;
- char platform_file_path[PATH_MAX];
- 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);
-
- // First try in the SDK and see if the file is in there
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- return error;
-
- // Else fall back to the actual path itself
- local_file.SetFile(platform_file_path, true);
- if (local_file.Exists())
- return error;
-
- }
- error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
- platform_file_path,
- GetPluginName().GetCString());
- }
- else
- {
- error.SetErrorString ("invalid platform file argument");
+ }
}
- return error;
-}
-
-Error
-PlatformAppleWatchSimulator::GetSharedModule (const ModuleSpec &module_spec,
- lldb_private::Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- // For AppleWatch, the SDK files are all cached locally on the host
- // system. So first we ask for the file in the cached SDK,
- // then we attempt to get a shared module for the right architecture
- // with the right UUID.
- Error error;
- ModuleSpec platform_module_spec (module_spec);
- const FileSpec &platform_file = module_spec.GetFileSpec();
- error = GetSymbolFile (platform_file, module_spec.GetUUIDPtr(), platform_module_spec.GetFileSpec());
- if (error.Success())
- {
- error = ResolveExecutable (platform_module_spec, module_sp, module_search_paths_ptr);
- }
- else
- {
- const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr,
- always_create);
-
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(platform_file);
-
- return error;
-}
-
-
-uint32_t
-PlatformAppleWatchSimulator::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- ProcessInstanceInfoList all_osx_process_infos;
- // First we get all OSX processes
- const uint32_t n = Host::FindProcesses (match_info, all_osx_process_infos);
-
- // Now we filter them down to only the WatchOS triples
- for (uint32_t i=0; i<n; ++i)
- {
- const ProcessInstanceInfo &proc_info = all_osx_process_infos.GetProcessInfoAtIndex(i);
- if (proc_info.GetArchitecture().GetTriple().getOS() == llvm::Triple::WatchOS) {
- process_infos.Append(proc_info);
- }
- }
- return process_infos.GetSize();
-}
-
-bool
-PlatformAppleWatchSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- static const ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKind64));
-
- if (idx == 0)
- {
- arch = platform_arch;
- if (arch.IsValid())
- {
- arch.GetTriple().setOS (llvm::Triple::WatchOS);
- return true;
- }
+ // 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;
+}
+
+Error PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ Error error;
+ char platform_file_path[PATH_MAX];
+ 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);
+
+ // First try in the SDK and see if the file is in there
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists())
+ return error;
+
+ // Else fall back to the actual path itself
+ local_file.SetFile(platform_file_path, true);
+ if (local_file.Exists())
+ return error;
+ }
+ error.SetErrorStringWithFormat(
+ "unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path, GetPluginName().GetCString());
+ } else {
+ error.SetErrorString("invalid platform file argument");
+ }
+ return error;
+}
+
+Error PlatformAppleWatchSimulator::GetSharedModule(
+ const ModuleSpec &module_spec, lldb_private::Process *process,
+ ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
+ // For AppleWatch, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ Error error;
+ ModuleSpec platform_module_spec(module_spec);
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
+ platform_module_spec.GetFileSpec());
+ if (error.Success()) {
+ error = ResolveExecutable(platform_module_spec, module_sp,
+ module_search_paths_ptr);
+ } else {
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr, always_create);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
+
+ return error;
+}
+
+uint32_t PlatformAppleWatchSimulator::FindProcesses(
+ const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ ProcessInstanceInfoList all_osx_process_infos;
+ // First we get all OSX processes
+ const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
+
+ // Now we filter them down to only the WatchOS triples
+ for (uint32_t i = 0; i < n; ++i) {
+ const ProcessInstanceInfo &proc_info =
+ all_osx_process_infos.GetProcessInfoAtIndex(i);
+ if (proc_info.GetArchitecture().GetTriple().getOS() ==
+ llvm::Triple::WatchOS) {
+ process_infos.Append(proc_info);
+ }
+ }
+ return process_infos.GetSize();
+}
+
+bool PlatformAppleWatchSimulator::GetSupportedArchitectureAtIndex(
+ uint32_t idx, ArchSpec &arch) {
+ static const ArchSpec platform_arch(
+ HostInfo::GetArchitecture(HostInfo::eArchKind64));
+
+ if (idx == 0) {
+ arch = platform_arch;
+ if (arch.IsValid()) {
+ arch.GetTriple().setOS(llvm::Triple::WatchOS);
+ return true;
}
- return false;
+ }
+ return false;
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h Tue Sep 6 15:57:50 2016
@@ -16,105 +16,83 @@
// Project includes
#include "PlatformDarwin.h"
-class PlatformAppleWatchSimulator : public PlatformDarwin
-{
+class PlatformAppleWatchSimulator : public PlatformDarwin {
public:
-
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
- PlatformAppleWatchSimulator ();
-
- virtual
- ~PlatformAppleWatchSimulator();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- virtual lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- uint32_t
- FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneSimulator);
- }
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ PlatformAppleWatchSimulator();
+
+ virtual ~PlatformAppleWatchSimulator();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override { return GetDescriptionStatic(); }
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ virtual lldb_private::Error
+ GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ uint32_t
+ FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::iPhoneSimulator);
+ }
protected:
- std::string m_sdk_directory;
- std::string m_build_update;
-
- const char *
- GetSDKDirectoryAsCString();
+ std::string m_sdk_directory;
+ std::string m_build_update;
-private:
- DISALLOW_COPY_AND_ASSIGN (PlatformAppleWatchSimulator);
+ const char *GetSDKDirectoryAsCString();
+private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformAppleWatchSimulator);
};
-#endif // liblldb_PlatformAppleWatchSimulator_h_
+#endif // liblldb_PlatformAppleWatchSimulator_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Tue Sep 6 15:57:50 2016
@@ -27,11 +27,11 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/Symbols.h"
#include "lldb/Host/XML.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -41,22 +41,19 @@
#include "lldb/Target/Target.h"
#include "llvm/ADT/STLExtras.h"
-#if defined (__APPLE__)
+#if defined(__APPLE__)
#include <TargetConditionals.h> // for TARGET_OS_TV, TARGET_OS_WATCH
#endif
using namespace lldb;
using namespace lldb_private;
-
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformDarwin::PlatformDarwin (bool is_host) :
- PlatformPOSIX(is_host), // This is the local host platform
- m_developer_directory ()
-{
-}
+PlatformDarwin::PlatformDarwin(bool is_host)
+ : PlatformPOSIX(is_host), // This is the local host platform
+ m_developer_directory() {}
//------------------------------------------------------------------
/// Destructor.
@@ -64,1659 +61,1820 @@ PlatformDarwin::PlatformDarwin (bool is_
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformDarwin::~PlatformDarwin()
-{
-}
+PlatformDarwin::~PlatformDarwin() {}
-FileSpecList
-PlatformDarwin::LocateExecutableScriptingResources (Target *target,
- Module &module,
- Stream* feedback_stream)
-{
- FileSpecList file_list;
- if (target && target->GetDebugger().GetScriptLanguage() == eScriptLanguagePython)
- {
- // NB some extensions might be meaningful and should not be stripped - "this.binary.file"
- // should not lose ".file" but GetFileNameStrippingExtension() will do precisely that.
- // Ideally, we should have a per-platform list of extensions (".exe", ".app", ".dSYM", ".framework")
- // which should be stripped while leaving "this.binary.file" as-is.
- ScriptInterpreter *script_interpreter = target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- FileSpec module_spec = module.GetFileSpec();
-
- if (module_spec)
- {
- SymbolVendor *symbols = module.GetSymbolVendor ();
- if (symbols)
- {
- SymbolFile *symfile = symbols->GetSymbolFile();
- if (symfile)
- {
- ObjectFile *objfile = symfile->GetObjectFile();
- if (objfile)
- {
- FileSpec symfile_spec (objfile->GetFileSpec());
- if (symfile_spec && symfile_spec.Exists())
- {
- while (module_spec.GetFilename())
- {
- std::string module_basename (module_spec.GetFilename().GetCString());
- std::string original_module_basename (module_basename);
-
- bool was_keyword = false;
-
- // FIXME: for Python, we cannot allow certain characters in module
- // filenames we import. Theoretically, different scripting languages may
- // have different sets of forbidden tokens in filenames, and that should
- // be dealt with by each ScriptInterpreter. For now, we just replace dots
- // with underscores, but if we ever support anything other than Python
- // we will need to rework this
- std::replace(module_basename.begin(), module_basename.end(), '.', '_');
- std::replace(module_basename.begin(), module_basename.end(), ' ', '_');
- std::replace(module_basename.begin(), module_basename.end(), '-', '_');
- if (script_interpreter && script_interpreter->IsReservedWord(module_basename.c_str()))
- {
- module_basename.insert(module_basename.begin(), '_');
- was_keyword = true;
- }
-
- StreamString path_string;
- StreamString original_path_string;
- // for OSX we are going to be in .dSYM/Contents/Resources/DWARF/<basename>
- // let us go to .dSYM/Contents/Resources/Python/<basename>.py and see if the file exists
- path_string.Printf("%s/../Python/%s.py",symfile_spec.GetDirectory().GetCString(), module_basename.c_str());
- original_path_string.Printf("%s/../Python/%s.py",symfile_spec.GetDirectory().GetCString(), original_module_basename.c_str());
- FileSpec script_fspec(path_string.GetData(), true);
- FileSpec orig_script_fspec(original_path_string.GetData(), true);
-
- // if we did some replacements of reserved characters, and a file with the untampered name
- // exists, then warn the user that the file as-is shall not be loaded
- if (feedback_stream)
- {
- if (module_basename != original_module_basename
- && orig_script_fspec.Exists())
- {
- const char* reason_for_complaint = was_keyword ? "conflicts with a keyword" : "contains reserved characters";
- if (script_fspec.Exists())
- feedback_stream->Printf("warning: the symbol file '%s' contains a debug script. However, its name"
- " '%s' %s and as such cannot be loaded. LLDB will"
- " load '%s' instead. Consider removing the file with the malformed name to"
- " eliminate this warning.\n",
- symfile_spec.GetPath().c_str(),
- original_path_string.GetData(),
- reason_for_complaint,
- path_string.GetData());
- else
- feedback_stream->Printf("warning: the symbol file '%s' contains a debug script. However, its name"
- " %s and as such cannot be loaded. If you intend"
- " to have this script loaded, please rename '%s' to '%s' and retry.\n",
- symfile_spec.GetPath().c_str(),
- reason_for_complaint,
- original_path_string.GetData(),
- path_string.GetData());
- }
- }
-
- if (script_fspec.Exists())
- {
- file_list.Append (script_fspec);
- break;
- }
-
- // If we didn't find the python file, then keep
- // stripping the extensions and try again
- ConstString filename_no_extension (module_spec.GetFileNameStrippingExtension());
- if (module_spec.GetFilename() == filename_no_extension)
- break;
-
- module_spec.GetFilename() = filename_no_extension;
- }
- }
- }
+FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
+ Target *target, Module &module, Stream *feedback_stream) {
+ FileSpecList file_list;
+ if (target &&
+ target->GetDebugger().GetScriptLanguage() == eScriptLanguagePython) {
+ // NB some extensions might be meaningful and should not be stripped -
+ // "this.binary.file"
+ // should not lose ".file" but GetFileNameStrippingExtension() will do
+ // precisely that.
+ // Ideally, we should have a per-platform list of extensions (".exe",
+ // ".app", ".dSYM", ".framework")
+ // which should be stripped while leaving "this.binary.file" as-is.
+ ScriptInterpreter *script_interpreter =
+ target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+
+ FileSpec module_spec = module.GetFileSpec();
+
+ if (module_spec) {
+ SymbolVendor *symbols = module.GetSymbolVendor();
+ if (symbols) {
+ SymbolFile *symfile = symbols->GetSymbolFile();
+ if (symfile) {
+ ObjectFile *objfile = symfile->GetObjectFile();
+ if (objfile) {
+ FileSpec symfile_spec(objfile->GetFileSpec());
+ if (symfile_spec && symfile_spec.Exists()) {
+ while (module_spec.GetFilename()) {
+ std::string module_basename(
+ module_spec.GetFilename().GetCString());
+ std::string original_module_basename(module_basename);
+
+ bool was_keyword = false;
+
+ // FIXME: for Python, we cannot allow certain characters in
+ // module
+ // filenames we import. Theoretically, different scripting
+ // languages may
+ // have different sets of forbidden tokens in filenames, and
+ // that should
+ // be dealt with by each ScriptInterpreter. For now, we just
+ // replace dots
+ // with underscores, but if we ever support anything other than
+ // Python
+ // we will need to rework this
+ std::replace(module_basename.begin(), module_basename.end(),
+ '.', '_');
+ std::replace(module_basename.begin(), module_basename.end(),
+ ' ', '_');
+ std::replace(module_basename.begin(), module_basename.end(),
+ '-', '_');
+ if (script_interpreter &&
+ script_interpreter->IsReservedWord(
+ module_basename.c_str())) {
+ module_basename.insert(module_basename.begin(), '_');
+ was_keyword = true;
}
- }
- }
- }
- return file_list;
-}
-
-Error
-PlatformDarwin::ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(module_spec);
-
- if (IsHost())
- {
- // If we have "ls" as the exe_file, resolve the executable loation based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists())
- {
- module_spec.GetFileSpec().GetPath (exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
-
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- {
- const uint32_t permissions = resolved_module_spec.GetFileSpec().GetPermissions();
- if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
- error.SetErrorStringWithFormat ("executable '%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- else
- error.SetErrorStringWithFormat ("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- else
- {
- if (m_remote_platform_sp)
- {
- error = GetCachedExecutable (resolved_module_spec, exe_module_sp, module_search_paths_ptr, *m_remote_platform_sp);
- }
- else
- {
- // We may connect to a process and use the provided executable (Don't use local $PATH).
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_module_spec.GetFileSpec().GetFilename().AsCString(""));
- }
- }
-
-
- if (error.Success())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- module_search_paths_ptr,
- NULL,
- NULL);
-
- if (error.Fail() || exe_module_sp.get() == NULL || exe_module_sp->GetObjectFile() == NULL)
- {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- }
- else
- {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = GetSharedModule (resolved_module_spec,
- NULL,
- exe_module_sp,
- module_search_paths_ptr,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
+ StreamString path_string;
+ StreamString original_path_string;
+ // for OSX we are going to be in
+ // .dSYM/Contents/Resources/DWARF/<basename>
+ // let us go to .dSYM/Contents/Resources/Python/<basename>.py
+ // and see if the file exists
+ path_string.Printf("%s/../Python/%s.py",
+ symfile_spec.GetDirectory().GetCString(),
+ module_basename.c_str());
+ original_path_string.Printf(
+ "%s/../Python/%s.py",
+ symfile_spec.GetDirectory().GetCString(),
+ original_module_basename.c_str());
+ FileSpec script_fspec(path_string.GetData(), true);
+ FileSpec orig_script_fspec(original_path_string.GetData(),
+ true);
+
+ // if we did some replacements of reserved characters, and a
+ // file with the untampered name
+ // exists, then warn the user that the file as-is shall not be
+ // loaded
+ if (feedback_stream) {
+ if (module_basename != original_module_basename &&
+ orig_script_fspec.Exists()) {
+ const char *reason_for_complaint =
+ was_keyword ? "conflicts with a keyword"
+ : "contains reserved characters";
+ if (script_fspec.Exists())
+ feedback_stream->Printf(
+ "warning: the symbol file '%s' contains a debug "
+ "script. However, its name"
+ " '%s' %s and as such cannot be loaded. LLDB will"
+ " load '%s' instead. Consider removing the file with "
+ "the malformed name to"
+ " eliminate this warning.\n",
+ symfile_spec.GetPath().c_str(),
+ original_path_string.GetData(), reason_for_complaint,
+ path_string.GetData());
else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
+ feedback_stream->Printf(
+ "warning: the symbol file '%s' contains a debug "
+ "script. However, its name"
+ " %s and as such cannot be loaded. If you intend"
+ " to have this script loaded, please rename '%s' to "
+ "'%s' and retry.\n",
+ symfile_spec.GetPath().c_str(), reason_for_complaint,
+ original_path_string.GetData(),
+ path_string.GetData());
+ }
}
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
- return error;
-}
+ if (script_fspec.Exists()) {
+ file_list.Append(script_fspec);
+ break;
+ }
-Error
-PlatformDarwin::ResolveSymbolFile (Target &target,
- const ModuleSpec &sym_spec,
- FileSpec &sym_file)
-{
- Error error;
- sym_file = sym_spec.GetSymbolFileSpec();
- if (sym_file.Exists())
- {
- if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory)
- {
- sym_file = Symbols::FindSymbolFileInBundle (sym_file,
- sym_spec.GetUUIDPtr(),
- sym_spec.GetArchitecturePtr());
+ // If we didn't find the python file, then keep
+ // stripping the extensions and try again
+ ConstString filename_no_extension(
+ module_spec.GetFileNameStrippingExtension());
+ if (module_spec.GetFilename() == filename_no_extension)
+ break;
+
+ module_spec.GetFilename() = filename_no_extension;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return file_list;
+}
+
+Error PlatformDarwin::ResolveExecutable(
+ const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ ModuleSpec resolved_module_spec(module_spec);
+
+ if (IsHost()) {
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ if (!resolved_module_spec.GetFileSpec().Exists()) {
+ module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+ }
+
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else {
+ const uint32_t permissions =
+ resolved_module_spec.GetFileSpec().GetPermissions();
+ if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
+ error.SetErrorStringWithFormat(
+ "executable '%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ else
+ error.SetErrorStringWithFormat(
+ "unable to find executable for '%s'",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ } else {
+ if (m_remote_platform_sp) {
+ error =
+ GetCachedExecutable(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, *m_remote_platform_sp);
+ } else {
+ // We may connect to a process and use the provided executable (Don't use
+ // local $PATH).
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else
+ error.SetErrorStringWithFormat(
+ "the platform is not currently connected, and '%s' doesn't exist "
+ "in the system root.",
+ resolved_module_spec.GetFileSpec().GetFilename().AsCString(""));
+ }
+ }
+
+ if (error.Success()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, NULL, NULL);
+
+ if (error.Fail() || exe_module_sp.get() == NULL ||
+ exe_module_sp->GetObjectFile() == NULL) {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain the architecture %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+ } else {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = GetSharedModule(resolved_module_spec, NULL, exe_module_sp,
+ module_search_paths_ptr, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
}
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+ }
+
+ return error;
+}
+
+Error PlatformDarwin::ResolveSymbolFile(Target &target,
+ const ModuleSpec &sym_spec,
+ FileSpec &sym_file) {
+ Error error;
+ sym_file = sym_spec.GetSymbolFileSpec();
+ if (sym_file.Exists()) {
+ if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory) {
+ sym_file = Symbols::FindSymbolFileInBundle(
+ sym_file, sym_spec.GetUUIDPtr(), sym_spec.GetArchitecturePtr());
}
- else
- {
- if (sym_spec.GetUUID().IsValid())
- {
-
- }
+ } else {
+ if (sym_spec.GetUUID().IsValid()) {
}
- return error;
-
+ }
+ return error;
}
static lldb_private::Error
-MakeCacheFolderForFile (const FileSpec& module_cache_spec)
-{
- FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent();
- return FileSystem::MakeDirectory(module_cache_folder, eFilePermissionsDirectoryDefault);
+MakeCacheFolderForFile(const FileSpec &module_cache_spec) {
+ FileSpec module_cache_folder =
+ module_cache_spec.CopyByRemovingLastPathComponent();
+ return FileSystem::MakeDirectory(module_cache_folder,
+ eFilePermissionsDirectoryDefault);
}
static lldb_private::Error
-BringInRemoteFile (Platform* platform,
- const lldb_private::ModuleSpec &module_spec,
- const FileSpec& module_cache_spec)
-{
- MakeCacheFolderForFile(module_cache_spec);
- Error err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec);
+BringInRemoteFile(Platform *platform,
+ const lldb_private::ModuleSpec &module_spec,
+ const FileSpec &module_cache_spec) {
+ MakeCacheFolderForFile(module_cache_spec);
+ Error err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec);
+ return err;
+}
+
+lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
+
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol "
+ "path %s/%s",
+ (IsHost() ? "host" : "remote"),
+ module_spec.GetFileSpec().GetDirectory().AsCString(),
+ module_spec.GetFileSpec().GetFilename().AsCString(),
+ module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
+ module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
+ module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
+ module_spec.GetSymbolFileSpec().GetFilename().AsCString());
+
+ Error err;
+
+ err = ModuleList::GetSharedModule(module_spec, module_sp,
+ module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr);
+ if (module_sp)
return err;
-}
-lldb_private::Error
-PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
-
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s",
- (IsHost() ? "host" : "remote"),
- module_spec.GetFileSpec().GetDirectory().AsCString(),
- module_spec.GetFileSpec().GetFilename().AsCString(),
- module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
- module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
- module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
- module_spec.GetSymbolFileSpec().GetFilename().AsCString());
-
- Error err;
-
- err = ModuleList::GetSharedModule(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
- if (module_sp)
- return err;
-
- if (!IsHost())
- {
- std::string cache_path(GetLocalCacheDirectory());
- // Only search for a locally cached file if we have a valid cache path
- if (!cache_path.empty())
- {
- std::string module_path (module_spec.GetFileSpec().GetPath());
- cache_path.append(module_path);
- FileSpec module_cache_spec(cache_path.c_str(),false);
-
- // if rsync is supported, always bring in the file - rsync will be very efficient
- // when files are the same on the local and remote end of the connection
- if (this->GetSupportsRSync())
- {
- err = BringInRemoteFile (this, module_spec, module_cache_spec);
- if (err.Fail())
- return err;
- if (module_cache_spec.Exists())
- {
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("[%s] module %s/%s was rsynced and is now there",
- (IsHost() ? "host" : "remote"),
- module_spec.GetFileSpec().GetDirectory().AsCString(),
- module_spec.GetFileSpec().GetFilename().AsCString());
- ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
- module_sp.reset(new Module(local_spec));
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return Error();
- }
- }
-
- // try to find the module in the cache
- if (module_cache_spec.Exists())
- {
- // get the local and remote MD5 and compare
- if (m_remote_platform_sp)
- {
- // when going over the *slow* GDB remote transfer mechanism we first check
- // the hashes of the files - and only do the actual transfer if they differ
- uint64_t high_local,high_remote,low_local,low_remote;
- FileSystem::CalculateMD5(module_cache_spec, low_local, high_local);
- m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(), low_remote, high_remote);
- if (low_local != low_remote || high_local != high_remote)
- {
- // bring in the remote file
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("[%s] module %s/%s needs to be replaced from remote copy",
- (IsHost() ? "host" : "remote"),
- module_spec.GetFileSpec().GetDirectory().AsCString(),
- module_spec.GetFileSpec().GetFilename().AsCString());
- Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
- if (err.Fail())
- return err;
- }
- }
-
- ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
- module_sp.reset(new Module(local_spec));
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("[%s] module %s/%s was found in the cache",
- (IsHost() ? "host" : "remote"),
- module_spec.GetFileSpec().GetDirectory().AsCString(),
- module_spec.GetFileSpec().GetFilename().AsCString());
- return Error();
- }
-
- // bring in the remote module file
+ if (!IsHost()) {
+ std::string cache_path(GetLocalCacheDirectory());
+ // Only search for a locally cached file if we have a valid cache path
+ if (!cache_path.empty()) {
+ std::string module_path(module_spec.GetFileSpec().GetPath());
+ cache_path.append(module_path);
+ FileSpec module_cache_spec(cache_path.c_str(), false);
+
+ // if rsync is supported, always bring in the file - rsync will be very
+ // efficient
+ // when files are the same on the local and remote end of the connection
+ if (this->GetSupportsRSync()) {
+ err = BringInRemoteFile(this, module_spec, module_cache_spec);
+ if (err.Fail())
+ return err;
+ if (module_cache_spec.Exists()) {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("[%s] module %s/%s was rsynced and is now there",
+ (IsHost() ? "host" : "remote"),
+ module_spec.GetFileSpec().GetDirectory().AsCString(),
+ module_spec.GetFileSpec().GetFilename().AsCString());
+ ModuleSpec local_spec(module_cache_spec,
+ module_spec.GetArchitecture());
+ module_sp.reset(new Module(local_spec));
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return Error();
+ }
+ }
+
+ // try to find the module in the cache
+ if (module_cache_spec.Exists()) {
+ // get the local and remote MD5 and compare
+ if (m_remote_platform_sp) {
+ // when going over the *slow* GDB remote transfer mechanism we first
+ // check
+ // the hashes of the files - and only do the actual transfer if they
+ // differ
+ uint64_t high_local, high_remote, low_local, low_remote;
+ FileSystem::CalculateMD5(module_cache_spec, low_local, high_local);
+ m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(),
+ low_remote, high_remote);
+ if (low_local != low_remote || high_local != high_remote) {
+ // bring in the remote file
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (log)
- log->Printf("[%s] module %s/%s needs to come in remotely",
- (IsHost() ? "host" : "remote"),
- module_spec.GetFileSpec().GetDirectory().AsCString(),
- module_spec.GetFileSpec().GetFilename().AsCString());
- Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
+ log->Printf(
+ "[%s] module %s/%s needs to be replaced from remote copy",
+ (IsHost() ? "host" : "remote"),
+ module_spec.GetFileSpec().GetDirectory().AsCString(),
+ module_spec.GetFileSpec().GetFilename().AsCString());
+ Error err = BringInRemoteFile(this, module_spec, module_cache_spec);
if (err.Fail())
- return err;
- if (module_cache_spec.Exists())
- {
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("[%s] module %s/%s is now cached and fine",
- (IsHost() ? "host" : "remote"),
- module_spec.GetFileSpec().GetDirectory().AsCString(),
- module_spec.GetFileSpec().GetFilename().AsCString());
- ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
- module_sp.reset(new Module(local_spec));
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return Error();
- }
- else
- return Error("unable to obtain valid module file");
+ return err;
+ }
}
- else
- return Error("no cache path");
- }
- else
- return Error ("unable to resolve module");
-}
-Error
-PlatformDarwin::GetSharedModule (const ModuleSpec &module_spec,
- Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- Error error;
- module_sp.reset();
-
- if (IsRemote())
- {
- // If we have a remote platform always, let it try and locate
- // the shared module first.
- if (m_remote_platform_sp)
- {
- error = m_remote_platform_sp->GetSharedModule (module_spec,
- process,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr);
- }
- }
-
- if (!module_sp)
- {
- // Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule (module_spec,
- process,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr);
-
- const FileSpec &platform_file = module_spec.GetFileSpec();
- if (!module_sp && module_search_paths_ptr && platform_file)
- {
- // We can try to pull off part of the file path up to the bundle
- // directory level and try any module search paths...
- FileSpec bundle_directory;
- if (Host::GetBundleDirectory (platform_file, bundle_directory))
- {
- if (platform_file == bundle_directory)
- {
- ModuleSpec new_module_spec (module_spec);
- new_module_spec.GetFileSpec() = bundle_directory;
- if (Host::ResolveExecutableInBundle (new_module_spec.GetFileSpec()))
- {
- Error new_error (Platform::GetSharedModule (new_module_spec,
- process,
- module_sp,
- NULL,
- old_module_sp_ptr,
- did_create_ptr));
-
- if (module_sp)
- return new_error;
- }
- }
- else
- {
- char platform_path[PATH_MAX];
- char bundle_dir[PATH_MAX];
- platform_file.GetPath (platform_path, sizeof(platform_path));
- const size_t bundle_directory_len = bundle_directory.GetPath (bundle_dir, sizeof(bundle_dir));
- char new_path[PATH_MAX];
- size_t num_module_search_paths = module_search_paths_ptr->GetSize();
- for (size_t i=0; i<num_module_search_paths; ++i)
- {
- const size_t search_path_len = module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath(new_path, sizeof(new_path));
- if (search_path_len < sizeof(new_path))
- {
- snprintf (new_path + search_path_len, sizeof(new_path) - search_path_len, "/%s", platform_path + bundle_directory_len);
- FileSpec new_file_spec (new_path, false);
- if (new_file_spec.Exists())
- {
- ModuleSpec new_module_spec (module_spec);
- new_module_spec.GetFileSpec() = new_file_spec;
- Error new_error (Platform::GetSharedModule (new_module_spec,
- process,
- module_sp,
- NULL,
- old_module_sp_ptr,
- did_create_ptr));
-
- if (module_sp)
- {
- module_sp->SetPlatformFileSpec(new_file_spec);
- return new_error;
- }
- }
- }
- }
+ ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
+ module_sp.reset(new Module(local_spec));
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("[%s] module %s/%s was found in the cache",
+ (IsHost() ? "host" : "remote"),
+ module_spec.GetFileSpec().GetDirectory().AsCString(),
+ module_spec.GetFileSpec().GetFilename().AsCString());
+ return Error();
+ }
+
+ // bring in the remote module file
+ if (log)
+ log->Printf("[%s] module %s/%s needs to come in remotely",
+ (IsHost() ? "host" : "remote"),
+ module_spec.GetFileSpec().GetDirectory().AsCString(),
+ module_spec.GetFileSpec().GetFilename().AsCString());
+ Error err = BringInRemoteFile(this, module_spec, module_cache_spec);
+ if (err.Fail())
+ return err;
+ if (module_cache_spec.Exists()) {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("[%s] module %s/%s is now cached and fine",
+ (IsHost() ? "host" : "remote"),
+ module_spec.GetFileSpec().GetDirectory().AsCString(),
+ module_spec.GetFileSpec().GetFilename().AsCString());
+ ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
+ module_sp.reset(new Module(local_spec));
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return Error();
+ } else
+ return Error("unable to obtain valid module file");
+ } else
+ return Error("no cache path");
+ } else
+ return Error("unable to resolve module");
+}
+
+Error PlatformDarwin::GetSharedModule(
+ const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
+ Error error;
+ module_sp.reset();
+
+ if (IsRemote()) {
+ // If we have a remote platform always, let it try and locate
+ // the shared module first.
+ if (m_remote_platform_sp) {
+ error = m_remote_platform_sp->GetSharedModule(
+ module_spec, process, module_sp, module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ }
+ }
+
+ if (!module_sp) {
+ // Fall back to the local platform and find the file locally
+ error = Platform::GetSharedModule(module_spec, process, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ if (!module_sp && module_search_paths_ptr && platform_file) {
+ // We can try to pull off part of the file path up to the bundle
+ // directory level and try any module search paths...
+ FileSpec bundle_directory;
+ if (Host::GetBundleDirectory(platform_file, bundle_directory)) {
+ if (platform_file == bundle_directory) {
+ ModuleSpec new_module_spec(module_spec);
+ new_module_spec.GetFileSpec() = bundle_directory;
+ if (Host::ResolveExecutableInBundle(new_module_spec.GetFileSpec())) {
+ Error new_error(Platform::GetSharedModule(
+ new_module_spec, process, module_sp, NULL, old_module_sp_ptr,
+ did_create_ptr));
+
+ if (module_sp)
+ return new_error;
+ }
+ } else {
+ char platform_path[PATH_MAX];
+ char bundle_dir[PATH_MAX];
+ platform_file.GetPath(platform_path, sizeof(platform_path));
+ const size_t bundle_directory_len =
+ bundle_directory.GetPath(bundle_dir, sizeof(bundle_dir));
+ char new_path[PATH_MAX];
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i) {
+ const size_t search_path_len =
+ module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath(
+ new_path, sizeof(new_path));
+ if (search_path_len < sizeof(new_path)) {
+ snprintf(new_path + search_path_len,
+ sizeof(new_path) - search_path_len, "/%s",
+ platform_path + bundle_directory_len);
+ FileSpec new_file_spec(new_path, false);
+ if (new_file_spec.Exists()) {
+ ModuleSpec new_module_spec(module_spec);
+ new_module_spec.GetFileSpec() = new_file_spec;
+ Error new_error(Platform::GetSharedModule(
+ new_module_spec, process, module_sp, NULL,
+ old_module_sp_ptr, did_create_ptr));
+
+ if (module_sp) {
+ module_sp->SetPlatformFileSpec(new_file_spec);
+ return new_error;
}
+ }
}
+ }
}
+ }
}
- if (module_sp)
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return error;
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return error;
}
size_t
-PlatformDarwin::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
-{
- const uint8_t *trap_opcode = nullptr;
- uint32_t trap_opcode_size = 0;
- bool bp_is_thumb = false;
-
- llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
- switch (machine)
- {
- case llvm::Triple::aarch64:
- {
- // TODO: fix this with actual darwin breakpoint opcode for arm64.
- // right now debugging uses the Z packets with GDB remote so this
- // is not needed, but the size needs to be correct...
- static const uint8_t g_arm64_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
- trap_opcode = g_arm64_breakpoint_opcode;
- trap_opcode_size = sizeof(g_arm64_breakpoint_opcode);
- }
- break;
-
- case llvm::Triple::thumb:
- bp_is_thumb = true;
- LLVM_FALLTHROUGH;
- case llvm::Triple::arm:
- {
- static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
- static const uint8_t g_thumb_breakpooint_opcode[] = { 0xFE, 0xDE };
-
- // Auto detect arm/thumb if it wasn't explicitly specified
- if (!bp_is_thumb)
- {
- lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
- if (bp_loc_sp)
- bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass () == eAddressClassCodeAlternateISA;
- }
- if (bp_is_thumb)
- {
- trap_opcode = g_thumb_breakpooint_opcode;
- trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
- break;
- }
- trap_opcode = g_arm_breakpoint_opcode;
- trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
- }
- break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- {
- static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
- trap_opcode = g_ppc_breakpoint_opcode;
- trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
- }
- break;
-
- default:
- return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
- }
+PlatformDarwin::GetSoftwareBreakpointTrapOpcode(Target &target,
+ BreakpointSite *bp_site) {
+ const uint8_t *trap_opcode = nullptr;
+ uint32_t trap_opcode_size = 0;
+ bool bp_is_thumb = false;
+
+ llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
+ switch (machine) {
+ case llvm::Triple::aarch64: {
+ // TODO: fix this with actual darwin breakpoint opcode for arm64.
+ // right now debugging uses the Z packets with GDB remote so this
+ // is not needed, but the size needs to be correct...
+ static const uint8_t g_arm64_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
+ trap_opcode = g_arm64_breakpoint_opcode;
+ trap_opcode_size = sizeof(g_arm64_breakpoint_opcode);
+ } break;
+
+ case llvm::Triple::thumb:
+ bp_is_thumb = true;
+ LLVM_FALLTHROUGH;
+ case llvm::Triple::arm: {
+ static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
+ static const uint8_t g_thumb_breakpooint_opcode[] = {0xFE, 0xDE};
+
+ // Auto detect arm/thumb if it wasn't explicitly specified
+ if (!bp_is_thumb) {
+ lldb::BreakpointLocationSP bp_loc_sp(bp_site->GetOwnerAtIndex(0));
+ if (bp_loc_sp)
+ bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
+ eAddressClassCodeAlternateISA;
+ }
+ if (bp_is_thumb) {
+ trap_opcode = g_thumb_breakpooint_opcode;
+ trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
+ break;
+ }
+ trap_opcode = g_arm_breakpoint_opcode;
+ trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+ } break;
+
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64: {
+ static const uint8_t g_ppc_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
+ trap_opcode = g_ppc_breakpoint_opcode;
+ trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
+ } break;
+
+ default:
+ return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
+ }
+
+ if (trap_opcode && trap_opcode_size) {
+ if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
+ return trap_opcode_size;
+ }
+ return 0;
+}
+
+bool PlatformDarwin::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ bool success = false;
+ if (IsHost()) {
+ success = Platform::GetProcessInfo(pid, process_info);
+ } else {
+ if (m_remote_platform_sp)
+ success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ }
+ return success;
+}
- if (trap_opcode && trap_opcode_size)
- {
- if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
- return trap_opcode_size;
- }
- return 0;
+uint32_t
+PlatformDarwin::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ uint32_t match_count = 0;
+ if (IsHost()) {
+ // Let the base class figure out the host details
+ match_count = Platform::FindProcesses(match_info, process_infos);
+ } else {
+ // If we are remote, we can only return results if we are connected
+ if (m_remote_platform_sp)
+ match_count =
+ m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ }
+ return match_count;
+}
+
+bool PlatformDarwin::ModuleIsExcludedForUnconstrainedSearches(
+ lldb_private::Target &target, const lldb::ModuleSP &module_sp) {
+ if (!module_sp)
+ return false;
-}
+ ObjectFile *obj_file = module_sp->GetObjectFile();
+ if (!obj_file)
+ return false;
-bool
-PlatformDarwin::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
- bool success = false;
- if (IsHost())
- {
- success = Platform::GetProcessInfo (pid, process_info);
- }
- else
- {
- if (m_remote_platform_sp)
- success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
- }
- return success;
+ ObjectFile::Type obj_type = obj_file->GetType();
+ if (obj_type == ObjectFile::eTypeDynamicLinker)
+ return true;
+ else
+ return false;
}
-uint32_t
-PlatformDarwin::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- uint32_t match_count = 0;
- if (IsHost())
- {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses (match_info, process_infos);
- }
- else
- {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
- }
- return match_count;
-}
-
-bool
-PlatformDarwin::ModuleIsExcludedForUnconstrainedSearches (lldb_private::Target &target, const lldb::ModuleSP &module_sp)
-{
- if (!module_sp)
- return false;
-
- ObjectFile *obj_file = module_sp->GetObjectFile();
- if (!obj_file)
- return false;
-
- ObjectFile::Type obj_type = obj_file->GetType();
- if (obj_type == ObjectFile::eTypeDynamicLinker)
- return true;
- else
- return false;
-}
-
-bool
-PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
- if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h)
- {
- switch (idx)
- {
- case 0:
- arch = host_arch;
- return true;
-
- case 1:
- arch.SetTriple("x86_64-apple-macosx");
- return true;
-
- case 2:
- arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
- return true;
+bool PlatformDarwin::x86GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h) {
+ switch (idx) {
+ case 0:
+ arch = host_arch;
+ return true;
+
+ case 1:
+ arch.SetTriple("x86_64-apple-macosx");
+ return true;
+
+ case 2:
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ return true;
- default: return false;
- }
+ default:
+ return false;
}
- else
- {
- if (idx == 0)
- {
- arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
- return arch.IsValid();
- }
- else if (idx == 1)
- {
- ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
- ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64));
- if (platform_arch.IsExactMatch(platform_arch64))
- {
- // This macosx platform supports both 32 and 64 bit. Since we already
- // returned the 64 bit arch for idx == 0, return the 32 bit arch
- // for idx == 1
- arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
- return arch.IsValid();
- }
- }
+ } else {
+ if (idx == 0) {
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ return arch.IsValid();
+ } else if (idx == 1) {
+ ArchSpec platform_arch(
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
+ ArchSpec platform_arch64(
+ HostInfo::GetArchitecture(HostInfo::eArchKind64));
+ if (platform_arch.IsExactMatch(platform_arch64)) {
+ // This macosx platform supports both 32 and 64 bit. Since we already
+ // returned the 64 bit arch for idx == 0, return the 32 bit arch
+ // for idx == 1
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ return arch.IsValid();
+ }
}
- return false;
+ }
+ return false;
}
// The architecture selection rules for arm processors
-// These cpu subtypes have distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f processor.
+// These cpu subtypes have distinct names (e.g. armv7f) but armv7 binaries run
+// fine on an armv7f processor.
-bool
-PlatformDarwin::ARMGetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- ArchSpec system_arch (GetSystemArchitecture());
+bool PlatformDarwin::ARMGetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ ArchSpec system_arch(GetSystemArchitecture());
- // When lldb is running on a watch or tv, set the arch OS name appropriately.
-#if defined (TARGET_OS_TV) && TARGET_OS_TV == 1
+// When lldb is running on a watch or tv, set the arch OS name appropriately.
+#if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
#define OSNAME "tvos"
-#elif defined (TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
+#elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
#define OSNAME "watchos"
#else
#define OSNAME "ios"
#endif
- const ArchSpec::Core system_core = system_arch.GetCore();
- switch (system_core)
- {
+ const ArchSpec::Core system_core = system_arch.GetCore();
+ switch (system_core) {
+ default:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("arm64-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv7f-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv7k-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv7s-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv7m-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("armv7em-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumbv7f-apple-" OSNAME);
+ return true;
+ case 14:
+ arch.SetTriple("thumbv7k-apple-" OSNAME);
+ return true;
+ case 15:
+ arch.SetTriple("thumbv7s-apple-" OSNAME);
+ return true;
+ case 16:
+ arch.SetTriple("thumbv7m-apple-" OSNAME);
+ return true;
+ case 17:
+ arch.SetTriple("thumbv7em-apple-" OSNAME);
+ return true;
+ case 18:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 19:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 20:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 21:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 22:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
default:
- switch (idx)
- {
- case 0: arch.SetTriple ("arm64-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv7f-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv7k-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv7s-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv7m-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("armv7em-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumbv7f-apple-" OSNAME); return true;
- case 14: arch.SetTriple ("thumbv7k-apple-" OSNAME); return true;
- case 15: arch.SetTriple ("thumbv7s-apple-" OSNAME); return true;
- case 16: arch.SetTriple ("thumbv7m-apple-" OSNAME); return true;
- case 17: arch.SetTriple ("thumbv7em-apple-" OSNAME); return true;
- case 18: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 19: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 20: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 21: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 22: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_arm64:
- switch (idx)
- {
- case 0: arch.SetTriple ("arm64-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7s-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv7f-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv7m-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv7em-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv7f-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumbv7k-apple-" OSNAME); return true;
- case 14: arch.SetTriple ("thumbv7s-apple-" OSNAME); return true;
- case 15: arch.SetTriple ("thumbv7m-apple-" OSNAME); return true;
- case 16: arch.SetTriple ("thumbv7em-apple-" OSNAME); return true;
- case 17: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 18: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 19: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 20: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 21: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_arm64:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("arm64-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7s-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv7f-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv7m-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv7em-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv7f-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumbv7k-apple-" OSNAME);
+ return true;
+ case 14:
+ arch.SetTriple("thumbv7s-apple-" OSNAME);
+ return true;
+ case 15:
+ arch.SetTriple("thumbv7m-apple-" OSNAME);
+ return true;
+ case 16:
+ arch.SetTriple("thumbv7em-apple-" OSNAME);
+ return true;
+ case 17:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 18:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 19:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 20:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 21:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7f:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7f-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv7f-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7f:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7f-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv7f-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7k:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7k-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv7k-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7k:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7k-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv7k-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7s:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7s-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv7s-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7s:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7s-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv7s-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7m:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7m-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv7m-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7m:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7m-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv7m-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7em:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7em-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv7em-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 12: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 13: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7em:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7em-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv7em-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 12:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 13:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("thumbv7-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 10: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 11: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("thumbv7-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 10:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 11:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv6m:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv6m-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("thumbv6m-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 8: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 9: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv6m:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv6m-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("thumbv6m-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 8:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 9:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv6:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv6-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("thumbv6-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 6: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 7: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv6:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv6-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("thumbv6-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 6:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 7:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv5:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv5-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("thumbv5-apple-" OSNAME); return true;
- case 4: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 5: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv5:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv5-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("thumbv5-apple-" OSNAME);
+ return true;
+ case 4:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 5:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv4:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv4-apple-" OSNAME); return true;
- case 1: arch.SetTriple ("arm-apple-" OSNAME); return true;
- case 2: arch.SetTriple ("thumbv4t-apple-" OSNAME); return true;
- case 3: arch.SetTriple ("thumb-apple-" OSNAME); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv4:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv4-apple-" OSNAME);
+ return true;
+ case 1:
+ arch.SetTriple("arm-apple-" OSNAME);
+ return true;
+ case 2:
+ arch.SetTriple("thumbv4t-apple-" OSNAME);
+ return true;
+ case 3:
+ arch.SetTriple("thumb-apple-" OSNAME);
+ return true;
+ default:
+ break;
}
- arch.Clear();
- return false;
-}
+ break;
+ }
+ arch.Clear();
+ return false;
+}
+
+const char *PlatformDarwin::GetDeveloperDirectory() {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ if (m_developer_directory.empty()) {
+ bool developer_dir_path_valid = false;
+ char developer_dir_path[PATH_MAX];
+ FileSpec temp_file_spec;
+ if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, temp_file_spec)) {
+ if (temp_file_spec.GetPath(developer_dir_path,
+ sizeof(developer_dir_path))) {
+ char *shared_frameworks =
+ strstr(developer_dir_path, "/SharedFrameworks/LLDB.framework");
+ if (shared_frameworks) {
+ ::snprintf(shared_frameworks,
+ sizeof(developer_dir_path) -
+ (shared_frameworks - developer_dir_path),
+ "/Developer");
+ developer_dir_path_valid = true;
+ } else {
+ char *lib_priv_frameworks = strstr(
+ developer_dir_path, "/Library/PrivateFrameworks/LLDB.framework");
+ if (lib_priv_frameworks) {
+ *lib_priv_frameworks = '\0';
+ developer_dir_path_valid = true;
+ }
+ }
+ }
+ }
+
+ if (!developer_dir_path_valid) {
+ std::string xcode_dir_path;
+ const char *xcode_select_prefix_dir = getenv("XCODE_SELECT_PREFIX_DIR");
+ if (xcode_select_prefix_dir)
+ xcode_dir_path.append(xcode_select_prefix_dir);
+ xcode_dir_path.append("/usr/share/xcode-select/xcode_dir_path");
+ temp_file_spec.SetFile(xcode_dir_path.c_str(), false);
+ size_t bytes_read = temp_file_spec.ReadFileContents(
+ 0, developer_dir_path, sizeof(developer_dir_path), NULL);
+ if (bytes_read > 0) {
+ developer_dir_path[bytes_read] = '\0';
+ while (developer_dir_path[bytes_read - 1] == '\r' ||
+ developer_dir_path[bytes_read - 1] == '\n')
+ developer_dir_path[--bytes_read] = '\0';
+ developer_dir_path_valid = true;
+ }
+ }
+
+ if (!developer_dir_path_valid) {
+ FileSpec xcode_select_cmd("/usr/bin/xcode-select", false);
+ if (xcode_select_cmd.Exists()) {
+ int exit_status = -1;
+ int signo = -1;
+ std::string command_output;
+ Error error =
+ Host::RunShellCommand("/usr/bin/xcode-select --print-path",
+ NULL, // current working directory
+ &exit_status, &signo, &command_output,
+ 2, // short timeout
+ false); // don't run in a shell
+ if (error.Success() && exit_status == 0 && !command_output.empty()) {
+ const char *cmd_output_ptr = command_output.c_str();
+ developer_dir_path[sizeof(developer_dir_path) - 1] = '\0';
+ size_t i;
+ for (i = 0; i < sizeof(developer_dir_path) - 1; i++) {
+ if (cmd_output_ptr[i] == '\r' || cmd_output_ptr[i] == '\n' ||
+ cmd_output_ptr[i] == '\0')
+ break;
+ developer_dir_path[i] = cmd_output_ptr[i];
+ }
+ developer_dir_path[i] = '\0';
+
+ FileSpec devel_dir(developer_dir_path, false);
+ if (devel_dir.Exists() && devel_dir.IsDirectory()) {
+ developer_dir_path_valid = true;
+ }
+ }
+ }
+ }
+
+ if (developer_dir_path_valid) {
+ temp_file_spec.SetFile(developer_dir_path, false);
+ if (temp_file_spec.Exists()) {
+ m_developer_directory.assign(developer_dir_path);
+ return m_developer_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_developer_directory.assign(1, '\0');
+ }
+
+ // We should have put a single NULL character into m_developer_directory
+ // or it should have a valid path if the code gets here
+ assert(m_developer_directory.empty() == false);
+ if (m_developer_directory[0])
+ return m_developer_directory.c_str();
+ return NULL;
+}
+
+BreakpointSP PlatformDarwin::SetThreadCreationBreakpoint(Target &target) {
+ BreakpointSP bp_sp;
+ static const char *g_bp_names[] = {
+ "start_wqthread", "_pthread_wqthread", "_pthread_start",
+ };
+
+ static const char *g_bp_modules[] = {"libsystem_c.dylib",
+ "libSystem.B.dylib"};
+
+ FileSpecList bp_modules;
+ for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++) {
+ const char *bp_module = g_bp_modules[i];
+ bp_modules.Append(FileSpec(bp_module, false));
+ }
+
+ bool internal = true;
+ bool hardware = false;
+ LazyBool skip_prologue = eLazyBoolNo;
+ bp_sp = target.CreateBreakpoint(&bp_modules, NULL, g_bp_names,
+ llvm::array_lengthof(g_bp_names),
+ eFunctionNameTypeFull, eLanguageTypeUnknown,
+ 0, skip_prologue, internal, hardware);
+ bp_sp->SetBreakpointKind("thread-creation");
+ return bp_sp;
+}
-const char *
-PlatformDarwin::GetDeveloperDirectory()
-{
- std::lock_guard<std::mutex> guard(m_mutex);
- if (m_developer_directory.empty())
- {
- bool developer_dir_path_valid = false;
- char developer_dir_path[PATH_MAX];
- FileSpec temp_file_spec;
- if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, temp_file_spec))
- {
- if (temp_file_spec.GetPath (developer_dir_path, sizeof(developer_dir_path)))
- {
- char *shared_frameworks = strstr (developer_dir_path, "/SharedFrameworks/LLDB.framework");
- if (shared_frameworks)
- {
- ::snprintf (shared_frameworks,
- sizeof(developer_dir_path) - (shared_frameworks - developer_dir_path),
- "/Developer");
- developer_dir_path_valid = true;
- }
- else
- {
- char *lib_priv_frameworks = strstr (developer_dir_path, "/Library/PrivateFrameworks/LLDB.framework");
- if (lib_priv_frameworks)
- {
- *lib_priv_frameworks = '\0';
- developer_dir_path_valid = true;
- }
- }
- }
- }
-
- if (!developer_dir_path_valid)
- {
- std::string xcode_dir_path;
- const char *xcode_select_prefix_dir = getenv ("XCODE_SELECT_PREFIX_DIR");
- if (xcode_select_prefix_dir)
- xcode_dir_path.append (xcode_select_prefix_dir);
- xcode_dir_path.append ("/usr/share/xcode-select/xcode_dir_path");
- temp_file_spec.SetFile(xcode_dir_path.c_str(), false);
- size_t bytes_read = temp_file_spec.ReadFileContents(0, developer_dir_path, sizeof(developer_dir_path), NULL);
- if (bytes_read > 0)
- {
- developer_dir_path[bytes_read] = '\0';
- while (developer_dir_path[bytes_read-1] == '\r' ||
- developer_dir_path[bytes_read-1] == '\n')
- developer_dir_path[--bytes_read] = '\0';
- developer_dir_path_valid = true;
- }
- }
-
- if (!developer_dir_path_valid)
- {
- FileSpec xcode_select_cmd ("/usr/bin/xcode-select", false);
- if (xcode_select_cmd.Exists())
- {
- int exit_status = -1;
- int signo = -1;
- std::string command_output;
- Error error = Host::RunShellCommand ("/usr/bin/xcode-select --print-path",
- NULL, // current working directory
- &exit_status,
- &signo,
- &command_output,
- 2, // short timeout
- false); // don't run in a shell
- if (error.Success() && exit_status == 0 && !command_output.empty())
- {
- const char *cmd_output_ptr = command_output.c_str();
- developer_dir_path[sizeof (developer_dir_path) - 1] = '\0';
- size_t i;
- for (i = 0; i < sizeof (developer_dir_path) - 1; i++)
- {
- if (cmd_output_ptr[i] == '\r' || cmd_output_ptr[i] == '\n' || cmd_output_ptr[i] == '\0')
- break;
- developer_dir_path[i] = cmd_output_ptr[i];
- }
- developer_dir_path[i] = '\0';
-
- FileSpec devel_dir (developer_dir_path, false);
- if (devel_dir.Exists() && devel_dir.IsDirectory())
- {
- developer_dir_path_valid = true;
- }
- }
- }
- }
+int32_t
+PlatformDarwin::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
+ const FileSpec &shell = launch_info.GetShell();
+ if (!shell)
+ return 1;
+
+ std::string shell_string = shell.GetPath();
+ const char *shell_name = strrchr(shell_string.c_str(), '/');
+ if (shell_name == NULL)
+ shell_name = shell_string.c_str();
+ else
+ shell_name++;
+
+ if (strcmp(shell_name, "sh") == 0) {
+ // /bin/sh re-exec's itself as /bin/bash requiring another resume.
+ // But it only does this if the COMMAND_MODE environment variable
+ // is set to "legacy".
+ const char **envp =
+ launch_info.GetEnvironmentEntries().GetConstArgumentVector();
+ if (envp != NULL) {
+ for (int i = 0; envp[i] != NULL; i++) {
+ if (strcmp(envp[i], "COMMAND_MODE=legacy") == 0)
+ return 2;
+ }
+ }
+ return 1;
+ } else if (strcmp(shell_name, "csh") == 0 ||
+ strcmp(shell_name, "tcsh") == 0 ||
+ strcmp(shell_name, "zsh") == 0) {
+ // csh and tcsh always seem to re-exec themselves.
+ return 2;
+ } else
+ return 1;
+}
- if (developer_dir_path_valid)
- {
- temp_file_spec.SetFile (developer_dir_path, false);
- if (temp_file_spec.Exists())
- {
- m_developer_directory.assign (developer_dir_path);
- return m_developer_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_developer_directory.assign (1, '\0');
- }
-
- // We should have put a single NULL character into m_developer_directory
- // or it should have a valid path if the code gets here
- assert (m_developer_directory.empty() == false);
- if (m_developer_directory[0])
- return m_developer_directory.c_str();
- return NULL;
+void PlatformDarwin::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
}
+static const char *const sdk_strings[] = {
+ "MacOSX", "iPhoneSimulator", "iPhoneOS",
+};
-BreakpointSP
-PlatformDarwin::SetThreadCreationBreakpoint (Target &target)
-{
- BreakpointSP bp_sp;
- static const char *g_bp_names[] =
- {
- "start_wqthread",
- "_pthread_wqthread",
- "_pthread_start",
- };
-
- static const char *g_bp_modules[] =
- {
- "libsystem_c.dylib",
- "libSystem.B.dylib"
- };
-
- FileSpecList bp_modules;
- for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++)
- {
- const char *bp_module = g_bp_modules[i];
- bp_modules.Append(FileSpec(bp_module, false));
- }
-
- bool internal = true;
- bool hardware = false;
- LazyBool skip_prologue = eLazyBoolNo;
- bp_sp = target.CreateBreakpoint (&bp_modules,
- NULL,
- g_bp_names,
- llvm::array_lengthof(g_bp_names),
- eFunctionNameTypeFull,
- eLanguageTypeUnknown,
- 0,
- skip_prologue,
- internal,
- hardware);
- bp_sp->SetBreakpointKind("thread-creation");
+static FileSpec CheckPathForXcode(const FileSpec &fspec) {
+ if (fspec.Exists()) {
+ const char substr[] = ".app/Contents/";
+
+ std::string path_to_shlib = fspec.GetPath();
+ size_t pos = path_to_shlib.rfind(substr);
+ if (pos != std::string::npos) {
+ path_to_shlib.erase(pos + strlen(substr));
+ FileSpec ret(path_to_shlib.c_str(), false);
+
+ FileSpec xcode_binary_path = ret;
+ xcode_binary_path.AppendPathComponent("MacOS");
+ xcode_binary_path.AppendPathComponent("Xcode");
+
+ if (xcode_binary_path.Exists()) {
+ return ret;
+ }
+ }
+ }
+ return FileSpec();
+}
+
+static FileSpec GetXcodeContentsPath() {
+ static FileSpec g_xcode_filespec;
+ static std::once_flag g_once_flag;
+ std::call_once(g_once_flag, []() {
+
+ FileSpec fspec;
+
+ // First get the program file spec. If lldb.so or LLDB.framework is running
+ // in a program and that program is Xcode, the path returned with be the
+ // path
+ // to Xcode.app/Contents/MacOS/Xcode, so this will be the correct Xcode to
+ // use.
+ fspec = HostInfo::GetProgramFileSpec();
+
+ if (fspec) {
+ // Ignore the current binary if it is python.
+ std::string basename_lower = fspec.GetFilename().GetCString();
+ std::transform(basename_lower.begin(), basename_lower.end(),
+ basename_lower.begin(), tolower);
+ if (basename_lower != "python") {
+ g_xcode_filespec = CheckPathForXcode(fspec);
+ }
+ }
+
+ // Next check DEVELOPER_DIR environment variable
+ if (!g_xcode_filespec) {
+ const char *developer_dir_env_var = getenv("DEVELOPER_DIR");
+ if (developer_dir_env_var && developer_dir_env_var[0]) {
+ g_xcode_filespec =
+ CheckPathForXcode(FileSpec(developer_dir_env_var, true));
+ }
+
+ // Fall back to using "xcrun" to find the selected Xcode
+ if (!g_xcode_filespec) {
+ int status = 0;
+ int signo = 0;
+ std::string output;
+ const char *command = "/usr/bin/xcode-select -p";
+ lldb_private::Error error = Host::RunShellCommand(
+ command, // shell command to run
+ NULL, // current working directory
+ &status, // Put the exit status of the process in here
+ &signo, // Put the signal that caused the process to exit in here
+ &output, // Get the output from the command and place it in this
+ // string
+ 3); // Timeout in seconds to wait for shell program to finish
+ if (status == 0 && !output.empty()) {
+ size_t first_non_newline = output.find_last_not_of("\r\n");
+ if (first_non_newline != std::string::npos) {
+ output.erase(first_non_newline + 1);
+ }
+ output.append("/..");
+
+ g_xcode_filespec = CheckPathForXcode(FileSpec(output.c_str(), false));
+ }
+ }
+ }
+ });
+
+ return g_xcode_filespec;
+}
+
+bool PlatformDarwin::SDKSupportsModules(SDKType sdk_type, uint32_t major,
+ uint32_t minor, uint32_t micro) {
+ switch (sdk_type) {
+ case SDKType::MacOSX:
+ if (major > 10 || (major == 10 && minor >= 10))
+ return true;
+ break;
+ case SDKType::iPhoneOS:
+ case SDKType::iPhoneSimulator:
+ if (major >= 8)
+ return true;
+ break;
+ }
+
+ return false;
+}
+
+bool PlatformDarwin::SDKSupportsModules(SDKType desired_type,
+ const FileSpec &sdk_path) {
+ ConstString last_path_component = sdk_path.GetLastPathComponent();
+
+ if (last_path_component) {
+ const llvm::StringRef sdk_name = last_path_component.GetStringRef();
+
+ llvm::StringRef version_part;
+
+ if (sdk_name.startswith(sdk_strings[(int)desired_type])) {
+ version_part =
+ sdk_name.drop_front(strlen(sdk_strings[(int)desired_type]));
+ } else {
+ return false;
+ }
+
+ const size_t major_dot_offset = version_part.find('.');
+ if (major_dot_offset == llvm::StringRef::npos)
+ return false;
+
+ const llvm::StringRef major_version =
+ version_part.slice(0, major_dot_offset);
+ const llvm::StringRef minor_part =
+ version_part.drop_front(major_dot_offset + 1);
+
+ const size_t minor_dot_offset = minor_part.find('.');
+ if (minor_dot_offset == llvm::StringRef::npos)
+ return false;
+
+ const llvm::StringRef minor_version = minor_part.slice(0, minor_dot_offset);
+
+ unsigned int major = 0;
+ unsigned int minor = 0;
+ unsigned int micro = 0;
+
+ if (major_version.getAsInteger(10, major))
+ return false;
- return bp_sp;
-}
+ if (minor_version.getAsInteger(10, minor))
+ return false;
+ return SDKSupportsModules(desired_type, major, minor, micro);
+ }
-int32_t
-PlatformDarwin::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
-{
- const FileSpec &shell = launch_info.GetShell();
- if (!shell)
- return 1;
-
- std::string shell_string = shell.GetPath();
- const char *shell_name = strrchr (shell_string.c_str(), '/');
- if (shell_name == NULL)
- shell_name = shell_string.c_str();
- else
- shell_name++;
-
- if (strcmp (shell_name, "sh") == 0)
- {
- // /bin/sh re-exec's itself as /bin/bash requiring another resume.
- // But it only does this if the COMMAND_MODE environment variable
- // is set to "legacy".
- const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector();
- if (envp != NULL)
- {
- for (int i = 0; envp[i] != NULL; i++)
- {
- if (strcmp (envp[i], "COMMAND_MODE=legacy" ) == 0)
- return 2;
- }
- }
- return 1;
- }
- else if (strcmp (shell_name, "csh") == 0
- || strcmp (shell_name, "tcsh") == 0
- || strcmp (shell_name, "zsh") == 0)
- {
- // csh and tcsh always seem to re-exec themselves.
- return 2;
- }
- else
- return 1;
-}
-
-void
-PlatformDarwin::CalculateTrapHandlerSymbolNames ()
-{
- m_trap_handlers.push_back (ConstString ("_sigtramp"));
+ return false;
}
+FileSpec::EnumerateDirectoryResult
+PlatformDarwin::DirectoryEnumerator(void *baton, FileSpec::FileType file_type,
+ const FileSpec &spec) {
+ SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
-static const char *const sdk_strings[] = {
- "MacOSX",
- "iPhoneSimulator",
- "iPhoneOS",
-};
+ if (SDKSupportsModules(enumerator_info->sdk_type, spec)) {
+ enumerator_info->found_path = spec;
+ return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
+ }
-static FileSpec
-CheckPathForXcode(const FileSpec &fspec)
-{
- if (fspec.Exists())
- {
- const char substr[] = ".app/Contents/";
-
- std::string path_to_shlib = fspec.GetPath();
- size_t pos = path_to_shlib.rfind(substr);
- if (pos != std::string::npos)
- {
- path_to_shlib.erase(pos + strlen(substr));
- FileSpec ret (path_to_shlib.c_str(), false);
-
- FileSpec xcode_binary_path = ret;
- xcode_binary_path.AppendPathComponent("MacOS");
- xcode_binary_path.AppendPathComponent("Xcode");
-
- if (xcode_binary_path.Exists())
- {
- return ret;
- }
- }
- }
- return FileSpec();
+ return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
}
-static FileSpec
-GetXcodeContentsPath ()
-{
- static FileSpec g_xcode_filespec;
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
-
-
- FileSpec fspec;
-
- // First get the program file spec. If lldb.so or LLDB.framework is running
- // in a program and that program is Xcode, the path returned with be the path
- // to Xcode.app/Contents/MacOS/Xcode, so this will be the correct Xcode to use.
- fspec = HostInfo::GetProgramFileSpec();
-
- if (fspec)
- {
- // Ignore the current binary if it is python.
- std::string basename_lower = fspec.GetFilename ().GetCString ();
- std::transform(basename_lower.begin (), basename_lower.end (), basename_lower.begin (), tolower);
- if (basename_lower != "python")
- {
- g_xcode_filespec = CheckPathForXcode(fspec);
- }
- }
+FileSpec PlatformDarwin::FindSDKInXcodeForModules(SDKType sdk_type,
+ const FileSpec &sdks_spec) {
+ // Look inside Xcode for the required installed iOS SDK version
- // Next check DEVELOPER_DIR environment variable
- if (!g_xcode_filespec)
- {
- const char *developer_dir_env_var = getenv("DEVELOPER_DIR");
- if (developer_dir_env_var && developer_dir_env_var[0])
- {
- g_xcode_filespec = CheckPathForXcode(FileSpec(developer_dir_env_var, true));
- }
+ if (!sdks_spec.IsDirectory())
+ return FileSpec();
- // Fall back to using "xcrun" to find the selected Xcode
- if (!g_xcode_filespec)
- {
- int status = 0;
- int signo = 0;
- std::string output;
- const char *command = "/usr/bin/xcode-select -p";
- lldb_private::Error error = Host::RunShellCommand (command, // shell command to run
- NULL, // current working directory
- &status, // Put the exit status of the process in here
- &signo, // Put the signal that caused the process to exit in here
- &output, // Get the output from the command and place it in this string
- 3); // Timeout in seconds to wait for shell program to finish
- if (status == 0 && !output.empty())
- {
- size_t first_non_newline = output.find_last_not_of("\r\n");
- if (first_non_newline != std::string::npos)
- {
- output.erase(first_non_newline+1);
- }
- output.append("/..");
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = true; // include symlinks
- g_xcode_filespec = CheckPathForXcode(FileSpec(output.c_str(), false));
- }
- }
- }
- });
-
- return g_xcode_filespec;
-}
+ SDKEnumeratorInfo enumerator_info;
-bool
-PlatformDarwin::SDKSupportsModules (SDKType sdk_type, uint32_t major, uint32_t minor, uint32_t micro)
-{
- switch (sdk_type)
- {
- case SDKType::MacOSX:
- if (major > 10 || (major == 10 && minor >= 10))
- return true;
- break;
- case SDKType::iPhoneOS:
- case SDKType::iPhoneSimulator:
- if (major >= 8)
- return true;
- break;
- }
-
- return false;
-}
+ enumerator_info.sdk_type = sdk_type;
-bool
-PlatformDarwin::SDKSupportsModules (SDKType desired_type, const FileSpec &sdk_path)
-{
- ConstString last_path_component = sdk_path.GetLastPathComponent();
-
- if (last_path_component)
- {
- const llvm::StringRef sdk_name = last_path_component.GetStringRef();
-
- llvm::StringRef version_part;
-
- if (sdk_name.startswith(sdk_strings[(int)desired_type]))
- {
- version_part = sdk_name.drop_front(strlen(sdk_strings[(int)desired_type]));
- }
- else
- {
- return false;
- }
-
- const size_t major_dot_offset = version_part.find('.');
- if (major_dot_offset == llvm::StringRef::npos)
- return false;
-
- const llvm::StringRef major_version = version_part.slice(0, major_dot_offset);
- const llvm::StringRef minor_part = version_part.drop_front(major_dot_offset + 1);
-
- const size_t minor_dot_offset = minor_part.find('.');
- if (minor_dot_offset == llvm::StringRef::npos)
- return false;
-
- const llvm::StringRef minor_version = minor_part.slice(0, minor_dot_offset);
-
- unsigned int major = 0;
- unsigned int minor = 0;
- unsigned int micro = 0;
-
- if (major_version.getAsInteger(10, major))
- return false;
-
- if (minor_version.getAsInteger(10, minor))
- return false;
-
- return SDKSupportsModules(desired_type, major, minor, micro);
- }
-
- return false;
-}
+ FileSpec::EnumerateDirectory(sdks_spec.GetPath().c_str(), find_directories,
+ find_files, find_other, DirectoryEnumerator,
+ &enumerator_info);
-FileSpec::EnumerateDirectoryResult
-PlatformDarwin::DirectoryEnumerator(void *baton,
- FileSpec::FileType file_type,
- const FileSpec &spec)
-{
- SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo*>(baton);
-
- if (SDKSupportsModules(enumerator_info->sdk_type, spec))
- {
- enumerator_info->found_path = spec;
- return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
- }
-
- return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
-}
-
-FileSpec
-PlatformDarwin::FindSDKInXcodeForModules (SDKType sdk_type,
- const FileSpec &sdks_spec)
-{
- // Look inside Xcode for the required installed iOS SDK version
-
- if (!sdks_spec.IsDirectory())
- return FileSpec();
-
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = true; // include symlinks
-
- SDKEnumeratorInfo enumerator_info;
-
- enumerator_info.sdk_type = sdk_type;
-
- FileSpec::EnumerateDirectory(sdks_spec.GetPath().c_str(),
- find_directories,
- find_files,
- find_other,
- DirectoryEnumerator,
- &enumerator_info);
-
- if (enumerator_info.found_path.IsDirectory())
- return enumerator_info.found_path;
- else
- return FileSpec();
-}
-
-FileSpec
-PlatformDarwin::GetSDKDirectoryForModules (SDKType sdk_type)
-{
- switch (sdk_type)
- {
- case SDKType::MacOSX:
- case SDKType::iPhoneSimulator:
- case SDKType::iPhoneOS:
- break;
- }
-
- FileSpec sdks_spec = GetXcodeContentsPath();
- sdks_spec.AppendPathComponent("Developer");
- sdks_spec.AppendPathComponent("Platforms");
-
- switch (sdk_type)
- {
- case SDKType::MacOSX:
- sdks_spec.AppendPathComponent("MacOSX.platform");
- break;
- case SDKType::iPhoneSimulator:
- sdks_spec.AppendPathComponent("iPhoneSimulator.platform");
- break;
- case SDKType::iPhoneOS:
- sdks_spec.AppendPathComponent("iPhoneOS.platform");
- break;
- }
-
- sdks_spec.AppendPathComponent("Developer");
- sdks_spec.AppendPathComponent("SDKs");
-
- if (sdk_type == SDKType::MacOSX)
- {
- uint32_t major = 0;
- uint32_t minor = 0;
- uint32_t micro = 0;
-
- if (HostInfo::GetOSVersion(major, minor, micro))
- {
- if (SDKSupportsModules(SDKType::MacOSX, major, minor, micro))
- {
- // We slightly prefer the exact SDK for this machine. See if it is there.
-
- FileSpec native_sdk_spec = sdks_spec;
- StreamString native_sdk_name;
- native_sdk_name.Printf("MacOSX%u.%u.sdk", major, minor);
- native_sdk_spec.AppendPathComponent(native_sdk_name.GetString().c_str());
-
- if (native_sdk_spec.Exists())
- {
- return native_sdk_spec;
- }
- }
- }
- }
-
- return FindSDKInXcodeForModules(sdk_type, sdks_spec);
+ if (enumerator_info.found_path.IsDirectory())
+ return enumerator_info.found_path;
+ else
+ return FileSpec();
}
-void
-PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std::vector<std::string> &options, SDKType sdk_type)
-{
- const std::vector<std::string> apple_arguments =
- {
- "-x", "objective-c++",
- "-fobjc-arc",
- "-fblocks",
- "-D_ISO646_H",
- "-D__ISO646_H"
- };
-
- options.insert(options.end(),
- apple_arguments.begin(),
- apple_arguments.end());
-
- StreamString minimum_version_option;
- uint32_t versions[3] = { 0, 0, 0 };
- bool use_current_os_version = false;
- switch (sdk_type)
- {
- case SDKType::iPhoneOS:
-#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
- use_current_os_version = true;
+FileSpec PlatformDarwin::GetSDKDirectoryForModules(SDKType sdk_type) {
+ switch (sdk_type) {
+ case SDKType::MacOSX:
+ case SDKType::iPhoneSimulator:
+ case SDKType::iPhoneOS:
+ break;
+ }
+
+ FileSpec sdks_spec = GetXcodeContentsPath();
+ sdks_spec.AppendPathComponent("Developer");
+ sdks_spec.AppendPathComponent("Platforms");
+
+ switch (sdk_type) {
+ case SDKType::MacOSX:
+ sdks_spec.AppendPathComponent("MacOSX.platform");
+ break;
+ case SDKType::iPhoneSimulator:
+ sdks_spec.AppendPathComponent("iPhoneSimulator.platform");
+ break;
+ case SDKType::iPhoneOS:
+ sdks_spec.AppendPathComponent("iPhoneOS.platform");
+ break;
+ }
+
+ sdks_spec.AppendPathComponent("Developer");
+ sdks_spec.AppendPathComponent("SDKs");
+
+ if (sdk_type == SDKType::MacOSX) {
+ uint32_t major = 0;
+ uint32_t minor = 0;
+ uint32_t micro = 0;
+
+ if (HostInfo::GetOSVersion(major, minor, micro)) {
+ if (SDKSupportsModules(SDKType::MacOSX, major, minor, micro)) {
+ // We slightly prefer the exact SDK for this machine. See if it is
+ // there.
+
+ FileSpec native_sdk_spec = sdks_spec;
+ StreamString native_sdk_name;
+ native_sdk_name.Printf("MacOSX%u.%u.sdk", major, minor);
+ native_sdk_spec.AppendPathComponent(
+ native_sdk_name.GetString().c_str());
+
+ if (native_sdk_spec.Exists()) {
+ return native_sdk_spec;
+ }
+ }
+ }
+ }
+
+ return FindSDKInXcodeForModules(sdk_type, sdks_spec);
+}
+
+void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ Target *target, std::vector<std::string> &options, SDKType sdk_type) {
+ const std::vector<std::string> apple_arguments = {
+ "-x", "objective-c++", "-fobjc-arc",
+ "-fblocks", "-D_ISO646_H", "-D__ISO646_H"};
+
+ options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
+
+ StreamString minimum_version_option;
+ uint32_t versions[3] = {0, 0, 0};
+ bool use_current_os_version = false;
+ switch (sdk_type) {
+ case SDKType::iPhoneOS:
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+ use_current_os_version = true;
#else
- use_current_os_version = false;
+ use_current_os_version = false;
#endif
- break;
-
- case SDKType::iPhoneSimulator:
- use_current_os_version = false;
- break;
+ break;
- case SDKType::MacOSX:
-#if defined (__i386__) || defined (__x86_64__)
- use_current_os_version = true;
+ case SDKType::iPhoneSimulator:
+ use_current_os_version = false;
+ break;
+
+ case SDKType::MacOSX:
+#if defined(__i386__) || defined(__x86_64__)
+ use_current_os_version = true;
#else
- use_current_os_version = false;
+ use_current_os_version = false;
#endif
- break;
- }
+ break;
+ }
- bool versions_valid = false;
- if (use_current_os_version)
- versions_valid = GetOSVersion(versions[0], versions[1], versions[2]);
- else if (target)
- {
- // Our OS doesn't match our executable so we need to get the min OS version from the object file
- ModuleSP exe_module_sp = target->GetExecutableModule();
- if (exe_module_sp)
- {
- ObjectFile *object_file = exe_module_sp->GetObjectFile();
- if (object_file)
- versions_valid = object_file->GetMinimumOSVersion(versions, 3) > 0;
- }
- }
- // Only add the version-min options if we got a version from somewhere
- if (versions_valid && versions[0] != UINT32_MAX)
- {
- // Make any invalid versions be zero if needed
- if (versions[1] == UINT32_MAX)
- versions[1] = 0;
- if (versions[2] == UINT32_MAX)
- versions[2] = 0;
-
- switch (sdk_type)
- {
- case SDKType::iPhoneOS:
- minimum_version_option.PutCString("-mios-version-min=");
- minimum_version_option.PutCString(clang::VersionTuple(versions[0], versions[1], versions[2]).getAsString().c_str());
- break;
- case SDKType::iPhoneSimulator:
- minimum_version_option.PutCString("-mios-simulator-version-min=");
- minimum_version_option.PutCString(clang::VersionTuple(versions[0], versions[1], versions[2]).getAsString().c_str());
- break;
- case SDKType::MacOSX:
- minimum_version_option.PutCString("-mmacosx-version-min=");
- minimum_version_option.PutCString(clang::VersionTuple(versions[0], versions[1], versions[2]).getAsString().c_str());
- }
- options.push_back(minimum_version_option.GetString());
- }
-
- FileSpec sysroot_spec;
- // Scope for mutex locker below
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- sysroot_spec = GetSDKDirectoryForModules(sdk_type);
- }
-
- if (sysroot_spec.IsDirectory())
- {
- options.push_back("-isysroot");
- options.push_back(sysroot_spec.GetPath());
- }
-}
-
-ConstString
-PlatformDarwin::GetFullNameForDylib (ConstString basename)
-{
- if (basename.IsEmpty())
- return basename;
-
- StreamString stream;
- stream.Printf("lib%s.dylib", basename.GetCString());
- return ConstString(stream.GetData());
-}
-
-bool
-PlatformDarwin::GetOSVersion (uint32_t &major,
- uint32_t &minor,
- uint32_t &update,
- Process *process)
-{
- if (process && strstr(GetPluginName().GetCString(), "-simulator"))
- {
- lldb_private::ProcessInstanceInfo proc_info;
- if (Host::GetProcessInfo(process->GetID(), proc_info))
- {
- Args &env = proc_info.GetEnvironmentEntries();
- const size_t n = env.GetArgumentCount();
- const llvm::StringRef k_runtime_version("SIMULATOR_RUNTIME_VERSION=");
- const llvm::StringRef k_dyld_root_path("DYLD_ROOT_PATH=");
- std::string dyld_root_path;
-
- for (size_t i=0; i<n; ++i)
- {
- const char *env_cstr = env.GetArgumentAtIndex(i);
- if (env_cstr)
- {
- llvm::StringRef env_str(env_cstr);
- if (env_str.startswith(k_runtime_version))
- {
- llvm::StringRef version_str(env_str.substr(k_runtime_version.size()));
- Args::StringToVersion (version_str.data(), major, minor, update);
- if (major != UINT32_MAX)
- return true;
- }
- else if (env_str.startswith(k_dyld_root_path))
- {
- dyld_root_path = env_str.substr(k_dyld_root_path.size()).str();
- }
- }
- }
+ bool versions_valid = false;
+ if (use_current_os_version)
+ versions_valid = GetOSVersion(versions[0], versions[1], versions[2]);
+ else if (target) {
+ // Our OS doesn't match our executable so we need to get the min OS version
+ // from the object file
+ ModuleSP exe_module_sp = target->GetExecutableModule();
+ if (exe_module_sp) {
+ ObjectFile *object_file = exe_module_sp->GetObjectFile();
+ if (object_file)
+ versions_valid = object_file->GetMinimumOSVersion(versions, 3) > 0;
+ }
+ }
+ // Only add the version-min options if we got a version from somewhere
+ if (versions_valid && versions[0] != UINT32_MAX) {
+ // Make any invalid versions be zero if needed
+ if (versions[1] == UINT32_MAX)
+ versions[1] = 0;
+ if (versions[2] == UINT32_MAX)
+ versions[2] = 0;
+
+ switch (sdk_type) {
+ case SDKType::iPhoneOS:
+ minimum_version_option.PutCString("-mios-version-min=");
+ minimum_version_option.PutCString(
+ clang::VersionTuple(versions[0], versions[1], versions[2])
+ .getAsString()
+ .c_str());
+ break;
+ case SDKType::iPhoneSimulator:
+ minimum_version_option.PutCString("-mios-simulator-version-min=");
+ minimum_version_option.PutCString(
+ clang::VersionTuple(versions[0], versions[1], versions[2])
+ .getAsString()
+ .c_str());
+ break;
+ case SDKType::MacOSX:
+ minimum_version_option.PutCString("-mmacosx-version-min=");
+ minimum_version_option.PutCString(
+ clang::VersionTuple(versions[0], versions[1], versions[2])
+ .getAsString()
+ .c_str());
+ }
+ options.push_back(minimum_version_option.GetString());
+ }
+
+ FileSpec sysroot_spec;
+ // Scope for mutex locker below
+ {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ sysroot_spec = GetSDKDirectoryForModules(sdk_type);
+ }
- if (!dyld_root_path.empty())
- {
- dyld_root_path += "/System/Library/CoreServices/SystemVersion.plist";
- ApplePropertyList system_version_plist(dyld_root_path.c_str());
- std::string product_version;
- if (system_version_plist.GetValueAsString("ProductVersion", product_version))
- {
- Args::StringToVersion (product_version.c_str(), major, minor, update);
- return major != UINT32_MAX;
- }
- }
+ if (sysroot_spec.IsDirectory()) {
+ options.push_back("-isysroot");
+ options.push_back(sysroot_spec.GetPath());
+ }
+}
+
+ConstString PlatformDarwin::GetFullNameForDylib(ConstString basename) {
+ if (basename.IsEmpty())
+ return basename;
+
+ StreamString stream;
+ stream.Printf("lib%s.dylib", basename.GetCString());
+ return ConstString(stream.GetData());
+}
+
+bool PlatformDarwin::GetOSVersion(uint32_t &major, uint32_t &minor,
+ uint32_t &update, Process *process) {
+ if (process && strstr(GetPluginName().GetCString(), "-simulator")) {
+ lldb_private::ProcessInstanceInfo proc_info;
+ if (Host::GetProcessInfo(process->GetID(), proc_info)) {
+ Args &env = proc_info.GetEnvironmentEntries();
+ const size_t n = env.GetArgumentCount();
+ const llvm::StringRef k_runtime_version("SIMULATOR_RUNTIME_VERSION=");
+ const llvm::StringRef k_dyld_root_path("DYLD_ROOT_PATH=");
+ std::string dyld_root_path;
+
+ for (size_t i = 0; i < n; ++i) {
+ const char *env_cstr = env.GetArgumentAtIndex(i);
+ if (env_cstr) {
+ llvm::StringRef env_str(env_cstr);
+ if (env_str.startswith(k_runtime_version)) {
+ llvm::StringRef version_str(
+ env_str.substr(k_runtime_version.size()));
+ Args::StringToVersion(version_str.data(), major, minor, update);
+ if (major != UINT32_MAX)
+ return true;
+ } else if (env_str.startswith(k_dyld_root_path)) {
+ dyld_root_path = env_str.substr(k_dyld_root_path.size()).str();
+ }
+ }
+ }
+
+ if (!dyld_root_path.empty()) {
+ dyld_root_path += "/System/Library/CoreServices/SystemVersion.plist";
+ ApplePropertyList system_version_plist(dyld_root_path.c_str());
+ std::string product_version;
+ if (system_version_plist.GetValueAsString("ProductVersion",
+ product_version)) {
+ Args::StringToVersion(product_version.c_str(), major, minor, update);
+ return major != UINT32_MAX;
+ }
+ }
+ }
+ // For simulator platforms, do NOT call back through
+ // Platform::GetOSVersion()
+ // as it might call Process::GetHostOSVersion() which we don't want as it
+ // will be
+ // incorrect
+ return false;
+ }
- }
- // For simulator platforms, do NOT call back through Platform::GetOSVersion()
- // as it might call Process::GetHostOSVersion() which we don't want as it will be
- // incorrect
- return false;
- }
-
- return Platform::GetOSVersion(major, minor, update, process);
-}
-
-lldb_private::FileSpec
-PlatformDarwin::LocateExecutable (const char *basename)
-{
- // A collection of SBFileSpec whose SBFileSpec.m_directory members are filled in with
- // any executable directories that should be searched.
- static std::vector<FileSpec> g_executable_dirs;
-
- // Find the global list of directories that we will search for
- // executables once so we don't keep doing the work over and over.
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
-
- // When locating executables, trust the DEVELOPER_DIR first if it is set
- FileSpec xcode_contents_dir = GetXcodeContentsPath();
- if (xcode_contents_dir)
- {
- FileSpec xcode_lldb_resources = xcode_contents_dir;
- xcode_lldb_resources.AppendPathComponent("SharedFrameworks");
- xcode_lldb_resources.AppendPathComponent("LLDB.framework");
- xcode_lldb_resources.AppendPathComponent("Resources");
- if (xcode_lldb_resources.Exists())
- {
- FileSpec dir;
- dir.GetDirectory().SetCString(xcode_lldb_resources.GetPath().c_str());
- g_executable_dirs.push_back(dir);
- }
- }
- });
+ return Platform::GetOSVersion(major, minor, update, process);
+}
- // Now search the global list of executable directories for the executable we
- // are looking for
- for (const auto &executable_dir : g_executable_dirs)
- {
- FileSpec executable_file;
- executable_file.GetDirectory() = executable_dir.GetDirectory();
- executable_file.GetFilename().SetCString(basename);
- if (executable_file.Exists())
- return executable_file;
- }
+lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) {
+ // A collection of SBFileSpec whose SBFileSpec.m_directory members are filled
+ // in with
+ // any executable directories that should be searched.
+ static std::vector<FileSpec> g_executable_dirs;
+
+ // Find the global list of directories that we will search for
+ // executables once so we don't keep doing the work over and over.
+ static std::once_flag g_once_flag;
+ std::call_once(g_once_flag, []() {
+
+ // When locating executables, trust the DEVELOPER_DIR first if it is set
+ FileSpec xcode_contents_dir = GetXcodeContentsPath();
+ if (xcode_contents_dir) {
+ FileSpec xcode_lldb_resources = xcode_contents_dir;
+ xcode_lldb_resources.AppendPathComponent("SharedFrameworks");
+ xcode_lldb_resources.AppendPathComponent("LLDB.framework");
+ xcode_lldb_resources.AppendPathComponent("Resources");
+ if (xcode_lldb_resources.Exists()) {
+ FileSpec dir;
+ dir.GetDirectory().SetCString(xcode_lldb_resources.GetPath().c_str());
+ g_executable_dirs.push_back(dir);
+ }
+ }
+ });
+
+ // Now search the global list of executable directories for the executable we
+ // are looking for
+ for (const auto &executable_dir : g_executable_dirs) {
+ FileSpec executable_file;
+ executable_file.GetDirectory() = executable_dir.GetDirectory();
+ executable_file.GetFilename().SetCString(basename);
+ if (executable_file.Exists())
+ return executable_file;
+ }
- return FileSpec();
+ return FileSpec();
}
lldb_private::Error
-PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info)
-{
- // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr
- // if the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't
- // require any specific value; rather, it just needs to exist).
- // We will set it here as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag
- // is not set. Xcode makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
- // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
- // specifically want it unset.
- const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
- auto &env_vars = launch_info.GetEnvironmentEntries();
- if (!env_vars.ContainsEnvironmentVariable(disable_env_var))
- {
- // We want to make sure that OS_ACTIVITY_DT_MODE is set so that
- // we get os_log and NSLog messages mirrored to the target process
- // stderr.
- if (!env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE"))
- env_vars.AppendArgument("OS_ACTIVITY_DT_MODE=enable");
- }
+PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) {
+ // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr
+ // if the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't
+ // require any specific value; rather, it just needs to exist).
+ // We will set it here as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag
+ // is not set. Xcode makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
+ // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
+ // specifically want it unset.
+ const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
+ auto &env_vars = launch_info.GetEnvironmentEntries();
+ if (!env_vars.ContainsEnvironmentVariable(disable_env_var)) {
+ // We want to make sure that OS_ACTIVITY_DT_MODE is set so that
+ // we get os_log and NSLog messages mirrored to the target process
+ // stderr.
+ if (!env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE"))
+ env_vars.AppendArgument("OS_ACTIVITY_DT_MODE=enable");
+ }
- // Let our parent class do the real launching.
- return PlatformPOSIX::LaunchProcess(launch_info);
+ // Let our parent class do the real launching.
+ return PlatformPOSIX::LaunchProcess(launch_info);
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Tue Sep 6 15:57:50 2016
@@ -16,144 +16,128 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
+#include "lldb/Host/FileSpec.h"
-class PlatformDarwin : public PlatformPOSIX
-{
+class PlatformDarwin : public PlatformPOSIX {
public:
- PlatformDarwin(bool is_host);
+ PlatformDarwin(bool is_host);
+
+ ~PlatformDarwin() override;
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ lldb_private::Error
+ ResolveSymbolFile(lldb_private::Target &target,
+ const lldb_private::ModuleSpec &sym_spec,
+ lldb_private::FileSpec &sym_file) override;
+
+ lldb_private::FileSpecList LocateExecutableScriptingResources(
+ lldb_private::Target *target, lldb_private::Module &module,
+ lldb_private::Stream *feedback_stream) override;
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ size_t GetSoftwareBreakpointTrapOpcode(
+ lldb_private::Target &target,
+ lldb_private::BreakpointSite *bp_site) override;
+
+ bool GetProcessInfo(lldb::pid_t pid,
+ lldb_private::ProcessInstanceInfo &proc_info) override;
+
+ lldb::BreakpointSP
+ SetThreadCreationBreakpoint(lldb_private::Target &target) override;
+
+ uint32_t
+ FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos) override;
+
+ bool ModuleIsExcludedForUnconstrainedSearches(
+ lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
+
+ bool ARMGetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch);
+
+ bool x86GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch);
- ~PlatformDarwin() override;
+ int32_t GetResumeCountForLaunchInfo(
+ lldb_private::ProcessLaunchInfo &launch_info) override;
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- lldb_private::Error
- ResolveSymbolFile (lldb_private::Target &target,
- const lldb_private::ModuleSpec &sym_spec,
- lldb_private::FileSpec &sym_file) override;
-
- lldb_private::FileSpecList
- LocateExecutableScriptingResources (lldb_private::Target *target,
- lldb_private::Module &module,
- lldb_private::Stream* feedback_stream) override;
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- size_t
- GetSoftwareBreakpointTrapOpcode (lldb_private::Target &target,
- lldb_private::BreakpointSite *bp_site) override;
-
- bool
- GetProcessInfo (lldb::pid_t pid,
- lldb_private::ProcessInstanceInfo &proc_info) override;
-
- lldb::BreakpointSP
- SetThreadCreationBreakpoint (lldb_private::Target &target) override;
-
- uint32_t
- FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
- bool
- ModuleIsExcludedForUnconstrainedSearches(lldb_private::Target &target,
- const lldb::ModuleSP &module_sp) override;
-
- bool
- ARMGetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
-
- bool
- x86GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
-
- int32_t
- GetResumeCountForLaunchInfo (lldb_private::ProcessLaunchInfo &launch_info) override;
-
- void
- CalculateTrapHandlerSymbolNames () override;
-
- bool
- GetOSVersion (uint32_t &major,
- uint32_t &minor,
- uint32_t &update,
- lldb_private::Process *process = nullptr) override;
-
- bool
- SupportsModules () override { return true; }
-
- lldb_private::ConstString
- GetFullNameForDylib (lldb_private::ConstString basename) override;
+ void CalculateTrapHandlerSymbolNames() override;
- lldb_private::FileSpec
- LocateExecutable (const char *basename) override;
+ bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update,
+ lldb_private::Process *process = nullptr) override;
- lldb_private::Error
- LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
+ bool SupportsModules() override { return true; }
+
+ lldb_private::ConstString
+ GetFullNameForDylib(lldb_private::ConstString basename) override;
+
+ lldb_private::FileSpec LocateExecutable(const char *basename) override;
+
+ lldb_private::Error
+ LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
protected:
- void
- ReadLibdispatchOffsetsAddress (lldb_private::Process *process);
+ void ReadLibdispatchOffsetsAddress(lldb_private::Process *process);
+
+ void ReadLibdispatchOffsets(lldb_private::Process *process);
+
+ virtual lldb_private::Error GetSharedModuleWithLocalCache(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr);
+
+ enum class SDKType {
+ MacOSX = 0,
+ iPhoneSimulator,
+ iPhoneOS,
+ };
+
+ static bool SDKSupportsModules(SDKType sdk_type, uint32_t major,
+ uint32_t minor, uint32_t micro);
+
+ static bool SDKSupportsModules(SDKType desired_type,
+ const lldb_private::FileSpec &sdk_path);
+
+ struct SDKEnumeratorInfo {
+ lldb_private::FileSpec found_path;
+ SDKType sdk_type;
+ };
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ DirectoryEnumerator(void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &spec);
+
+ static lldb_private::FileSpec
+ FindSDKInXcodeForModules(SDKType sdk_type,
+ const lldb_private::FileSpec &sdks_spec);
+
+ static lldb_private::FileSpec
+ GetSDKDirectoryForModules(PlatformDarwin::SDKType sdk_type);
+
+ void
+ AddClangModuleCompilationOptionsForSDKType(lldb_private::Target *target,
+ std::vector<std::string> &options,
+ SDKType sdk_type);
+
+ std::string m_developer_directory;
- void
- ReadLibdispatchOffsets (lldb_private::Process *process);
+ const char *GetDeveloperDirectory();
- virtual lldb_private::Error
- GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr);
-
- enum class SDKType {
- MacOSX = 0,
- iPhoneSimulator,
- iPhoneOS,
- };
-
- static bool
- SDKSupportsModules (SDKType sdk_type, uint32_t major, uint32_t minor, uint32_t micro);
-
- static bool
- SDKSupportsModules (SDKType desired_type, const lldb_private::FileSpec &sdk_path);
-
- struct SDKEnumeratorInfo {
- lldb_private::FileSpec found_path;
- SDKType sdk_type;
- };
-
- static lldb_private::FileSpec::EnumerateDirectoryResult
- DirectoryEnumerator(void *baton,
- lldb_private::FileSpec::FileType file_type,
- const lldb_private::FileSpec &spec);
-
- static lldb_private::FileSpec
- FindSDKInXcodeForModules (SDKType sdk_type,
- const lldb_private::FileSpec &sdks_spec);
-
- static lldb_private::FileSpec
- GetSDKDirectoryForModules (PlatformDarwin::SDKType sdk_type);
-
- void
- AddClangModuleCompilationOptionsForSDKType (lldb_private::Target *target, std::vector<std::string> &options, SDKType sdk_type);
-
- std::string m_developer_directory;
-
- const char *
- GetDeveloperDirectory();
-
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformDarwin);
+ DISALLOW_COPY_AND_ASSIGN(PlatformDarwin);
};
#endif // liblldb_PlatformDarwin_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- PlatformDarwinKernel.cpp -----------------------------------*- C++ -*-===//
+//===-- PlatformDarwinKernel.cpp -----------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -9,8 +10,8 @@
#include "PlatformDarwinKernel.h"
-#if defined (__APPLE__) // This Plugin uses the Mac-specific source/Host/macosx/cfcpp utilities
-
+#if defined(__APPLE__) // This Plugin uses the Mac-specific
+ // source/Host/macosx/cfcpp utilities
// C Includes
// C++ Includes
@@ -50,255 +51,223 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformDarwinKernel::Initialize ()
-{
- PlatformDarwin::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformDarwinKernel::GetPluginNameStatic(),
- PlatformDarwinKernel::GetDescriptionStatic(),
- PlatformDarwinKernel::CreateInstance,
- PlatformDarwinKernel::DebuggerInitialize);
- }
-}
+void PlatformDarwinKernel::Initialize() {
+ PlatformDarwin::Initialize();
-void
-PlatformDarwinKernel::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformDarwinKernel::CreateInstance);
- }
- }
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(PlatformDarwinKernel::GetPluginNameStatic(),
+ PlatformDarwinKernel::GetDescriptionStatic(),
+ PlatformDarwinKernel::CreateInstance,
+ PlatformDarwinKernel::DebuggerInitialize);
+ }
+}
+
+void PlatformDarwinKernel::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformDarwinKernel::CreateInstance);
+ }
+ }
+
+ PlatformDarwin::Terminate();
+}
+
+PlatformSP PlatformDarwinKernel::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- PlatformDarwin::Terminate ();
-}
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
-PlatformSP
-PlatformDarwinKernel::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+ log->Printf("PlatformDarwinKernel::%s(force=%s, arch={%s,%s})",
+ __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ // This is a special plugin that we don't want to activate just based on an
+ // ArchSpec for normal
+ // userland debugging. It is only useful in kernel debug sessions and the
+ // DynamicLoaderDarwinPlugin
+ // (or a user doing 'platform select') will force the creation of this
+ // Platform plugin.
+ if (force == false) {
if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
-
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
-
- log->Printf ("PlatformDarwinKernel::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
-
- // This is a special plugin that we don't want to activate just based on an ArchSpec for normal
- // userland debugging. It is only useful in kernel debug sessions and the DynamicLoaderDarwinPlugin
- // (or a user doing 'platform select') will force the creation of this Platform plugin.
- if (force == false)
- {
- if (log)
- log->Printf ("PlatformDarwinKernel::%s() aborting creation of platform because force == false", __FUNCTION__);
- return PlatformSP();
- }
-
- bool create = force;
- LazyBool is_ios_debug_session = eLazyBoolCalculate;
-
- if (create == false && arch && arch->IsValid())
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getVendor())
- {
- case llvm::Triple::Apple:
- create = true;
- break;
-
- // Only accept "unknown" for vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
- default:
- break;
- }
-
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::Darwin:
- case llvm::Triple::MacOSX:
- case llvm::Triple::IOS:
- case llvm::Triple::WatchOS:
- case llvm::Triple::TvOS:
- break;
- // Only accept "vendor" for vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
- default:
- create = false;
- break;
- }
- }
- }
- if (arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- is_ios_debug_session = eLazyBoolNo;
- break;
- case llvm::Triple::arm:
- case llvm::Triple::aarch64:
- case llvm::Triple::thumb:
- is_ios_debug_session = eLazyBoolYes;
- break;
- default:
- is_ios_debug_session = eLazyBoolCalculate;
- break;
- }
- }
- if (create)
- {
- if (log)
- log->Printf ("PlatformDarwinKernel::%s() creating platform", __FUNCTION__);
+ log->Printf("PlatformDarwinKernel::%s() aborting creation of platform "
+ "because force == false",
+ __FUNCTION__);
+ return PlatformSP();
+ }
- return PlatformSP(new PlatformDarwinKernel (is_ios_debug_session));
- }
+ bool create = force;
+ LazyBool is_ios_debug_session = eLazyBoolCalculate;
+ if (create == false && arch && arch->IsValid()) {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor()) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
+
+ // Only accept "unknown" for vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
+ default:
+ break;
+ }
+
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::Darwin:
+ case llvm::Triple::MacOSX:
+ case llvm::Triple::IOS:
+ case llvm::Triple::WatchOS:
+ case llvm::Triple::TvOS:
+ break;
+ // Only accept "vendor" for vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
+ default:
+ create = false;
+ break;
+ }
+ }
+ }
+ if (arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ is_ios_debug_session = eLazyBoolNo;
+ break;
+ case llvm::Triple::arm:
+ case llvm::Triple::aarch64:
+ case llvm::Triple::thumb:
+ is_ios_debug_session = eLazyBoolYes;
+ break;
+ default:
+ is_ios_debug_session = eLazyBoolCalculate;
+ break;
+ }
+ }
+ if (create) {
if (log)
- log->Printf ("PlatformDarwinKernel::%s() aborting creation of platform", __FUNCTION__);
+ log->Printf("PlatformDarwinKernel::%s() creating platform", __FUNCTION__);
- return PlatformSP();
-}
+ return PlatformSP(new PlatformDarwinKernel(is_ios_debug_session));
+ }
+ if (log)
+ log->Printf("PlatformDarwinKernel::%s() aborting creation of platform",
+ __FUNCTION__);
-lldb_private::ConstString
-PlatformDarwinKernel::GetPluginNameStatic ()
-{
- static ConstString g_name("darwin-kernel");
- return g_name;
+ return PlatformSP();
}
-const char *
-PlatformDarwinKernel::GetDescriptionStatic()
-{
- return "Darwin Kernel platform plug-in.";
+lldb_private::ConstString PlatformDarwinKernel::GetPluginNameStatic() {
+ static ConstString g_name("darwin-kernel");
+ return g_name;
+}
+
+const char *PlatformDarwinKernel::GetDescriptionStatic() {
+ return "Darwin Kernel platform plug-in.";
}
//------------------------------------------------------------------
/// Code to handle the PlatformDarwinKernel settings
//------------------------------------------------------------------
-static PropertyDefinition
-g_properties[] =
-{
- { "search-locally-for-kexts" , OptionValue::eTypeBoolean, true, true, NULL, NULL, "Automatically search for kexts on the local system when doing kernel debugging." },
- { "kext-directories", OptionValue::eTypeFileSpecList, false, 0, NULL, NULL, "Directories/KDKs to search for kexts in when starting a kernel debug session." },
- { NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
-};
-
-enum {
- ePropertySearchForKexts = 0,
- ePropertyKextDirectories
-};
-
+static PropertyDefinition g_properties[] = {
+ {"search-locally-for-kexts", OptionValue::eTypeBoolean, true, true, NULL,
+ NULL, "Automatically search for kexts on the local system when doing "
+ "kernel debugging."},
+ {"kext-directories", OptionValue::eTypeFileSpecList, false, 0, NULL, NULL,
+ "Directories/KDKs to search for kexts in when starting a kernel debug "
+ "session."},
+ {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}};
+enum { ePropertySearchForKexts = 0, ePropertyKextDirectories };
-class PlatformDarwinKernelProperties : public Properties
-{
+class PlatformDarwinKernelProperties : public Properties {
public:
-
- static ConstString &
- GetSettingName ()
- {
- static ConstString g_setting_name("darwin-kernel");
- return g_setting_name;
- }
-
- PlatformDarwinKernelProperties() :
- Properties ()
- {
- m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
- m_collection_sp->Initialize(g_properties);
- }
-
- virtual
- ~PlatformDarwinKernelProperties()
- {
- }
-
- bool
- GetSearchForKexts() const
- {
- const uint32_t idx = ePropertySearchForKexts;
- return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
- }
-
- FileSpecList &
- GetKextDirectories() const
- {
- const uint32_t idx = ePropertyKextDirectories;
- OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
- assert(option_value);
- return option_value->GetCurrentValue();
- }
+ static ConstString &GetSettingName() {
+ static ConstString g_setting_name("darwin-kernel");
+ return g_setting_name;
+ }
+
+ PlatformDarwinKernelProperties() : Properties() {
+ m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ virtual ~PlatformDarwinKernelProperties() {}
+
+ bool GetSearchForKexts() const {
+ const uint32_t idx = ePropertySearchForKexts;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ NULL, idx, g_properties[idx].default_uint_value != 0);
+ }
+
+ FileSpecList &GetKextDirectories() const {
+ const uint32_t idx = ePropertyKextDirectories;
+ OptionValueFileSpecList *option_value =
+ m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(
+ NULL, false, idx);
+ assert(option_value);
+ return option_value->GetCurrentValue();
+ }
};
-typedef std::shared_ptr<PlatformDarwinKernelProperties> PlatformDarwinKernelPropertiesSP;
+typedef std::shared_ptr<PlatformDarwinKernelProperties>
+ PlatformDarwinKernelPropertiesSP;
-static const PlatformDarwinKernelPropertiesSP &
-GetGlobalProperties()
-{
- static PlatformDarwinKernelPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp.reset (new PlatformDarwinKernelProperties ());
- return g_settings_sp;
-}
-
-void
-PlatformDarwinKernel::DebuggerInitialize (lldb_private::Debugger &debugger)
-{
- if (!PluginManager::GetSettingForPlatformPlugin (debugger, PlatformDarwinKernelProperties::GetSettingName()))
- {
- const bool is_global_setting = true;
- PluginManager::CreateSettingForPlatformPlugin (debugger,
- GetGlobalProperties()->GetValueProperties(),
- ConstString ("Properties for the PlatformDarwinKernel plug-in."),
- is_global_setting);
- }
+static const PlatformDarwinKernelPropertiesSP &GetGlobalProperties() {
+ static PlatformDarwinKernelPropertiesSP g_settings_sp;
+ if (!g_settings_sp)
+ g_settings_sp.reset(new PlatformDarwinKernelProperties());
+ return g_settings_sp;
+}
+
+void PlatformDarwinKernel::DebuggerInitialize(
+ lldb_private::Debugger &debugger) {
+ if (!PluginManager::GetSettingForPlatformPlugin(
+ debugger, PlatformDarwinKernelProperties::GetSettingName())) {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForPlatformPlugin(
+ debugger, GetGlobalProperties()->GetValueProperties(),
+ ConstString("Properties for the PlatformDarwinKernel plug-in."),
+ is_global_setting);
+ }
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformDarwinKernel::PlatformDarwinKernel (lldb_private::LazyBool is_ios_debug_session) :
- PlatformDarwin (false), // This is a remote platform
- m_name_to_kext_path_map_with_dsyms(),
- m_name_to_kext_path_map_without_dsyms(),
- m_search_directories(),
- m_search_directories_no_recursing(),
- m_kernel_binaries_with_dsyms(),
- m_kernel_binaries_without_dsyms(),
- m_ios_debug_session(is_ios_debug_session)
+PlatformDarwinKernel::PlatformDarwinKernel(
+ lldb_private::LazyBool is_ios_debug_session)
+ : PlatformDarwin(false), // This is a remote platform
+ m_name_to_kext_path_map_with_dsyms(),
+ m_name_to_kext_path_map_without_dsyms(), m_search_directories(),
+ m_search_directories_no_recursing(), m_kernel_binaries_with_dsyms(),
+ m_kernel_binaries_without_dsyms(),
+ m_ios_debug_session(is_ios_debug_session)
{
- if (GetGlobalProperties()->GetSearchForKexts())
- {
- CollectKextAndKernelDirectories ();
- SearchForKextsAndKernelsRecursively ();
- }
+ if (GetGlobalProperties()->GetSearchForKexts()) {
+ CollectKextAndKernelDirectories();
+ SearchForKextsAndKernelsRecursively();
+ }
}
//------------------------------------------------------------------
@@ -307,350 +276,308 @@ PlatformDarwinKernel::PlatformDarwinKern
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformDarwinKernel::~PlatformDarwinKernel()
-{
-}
-
-
-void
-PlatformDarwinKernel::GetStatus (Stream &strm)
-{
- Platform::GetStatus (strm);
- strm.Printf (" Debug session type: ");
- if (m_ios_debug_session == eLazyBoolYes)
- strm.Printf ("iOS kernel debugging\n");
- else if (m_ios_debug_session == eLazyBoolNo)
- strm.Printf ("Mac OS X kernel debugging\n");
- else
- strm.Printf ("unknown kernel debugging\n");
-
- strm.Printf ("Directories searched recursively:\n");
- const uint32_t num_kext_dirs = m_search_directories.size();
- for (uint32_t i=0; i<num_kext_dirs; ++i)
- {
- strm.Printf ("[%d] %s\n", i, m_search_directories[i].GetPath().c_str());
- }
-
- strm.Printf ("Directories not searched recursively:\n");
- const uint32_t num_kext_dirs_no_recursion = m_search_directories_no_recursing.size();
- for (uint32_t i = 0; i < num_kext_dirs_no_recursion; i++)
- {
- strm.Printf ("[%d] %s\n", i, m_search_directories_no_recursing[i].GetPath().c_str());
- }
-
- strm.Printf (" Number of kexts with dSYMs indexed: %d\n", (int) m_name_to_kext_path_map_with_dsyms.size());
- strm.Printf (" Number of kexts without dSYMs indexed: %d\n", (int) m_name_to_kext_path_map_without_dsyms.size());
- strm.Printf (" Number of Kernel binaries with dSYMs indexed: %d\n", (int) m_kernel_binaries_with_dsyms.size());
- strm.Printf (" Number of Kernel binaries without dSYMs indexed: %d\n", (int) m_kernel_binaries_without_dsyms.size());
-
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- log->Printf("\nkexts with dSYMs");
- for (auto pos : m_name_to_kext_path_map_with_dsyms)
- {
- log->Printf ("%s", pos.second.GetPath().c_str());
- }
- log->Printf("\nkexts without dSYMs");
+PlatformDarwinKernel::~PlatformDarwinKernel() {}
- for (auto pos : m_name_to_kext_path_map_without_dsyms)
- {
- log->Printf ("%s", pos.second.GetPath().c_str());
- }
- log->Printf("\nkernels with dSYMS");
- for (auto fs : m_kernel_binaries_with_dsyms)
- {
- log->Printf ("%s", fs.GetPath().c_str());
- }
- log->Printf("\nkernels without dSYMS");
- for (auto fs : m_kernel_binaries_without_dsyms)
- {
- log->Printf ("%s", fs.GetPath().c_str());
- }
- log->Printf("\n");
+void PlatformDarwinKernel::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+ strm.Printf(" Debug session type: ");
+ if (m_ios_debug_session == eLazyBoolYes)
+ strm.Printf("iOS kernel debugging\n");
+ else if (m_ios_debug_session == eLazyBoolNo)
+ strm.Printf("Mac OS X kernel debugging\n");
+ else
+ strm.Printf("unknown kernel debugging\n");
+
+ strm.Printf("Directories searched recursively:\n");
+ const uint32_t num_kext_dirs = m_search_directories.size();
+ for (uint32_t i = 0; i < num_kext_dirs; ++i) {
+ strm.Printf("[%d] %s\n", i, m_search_directories[i].GetPath().c_str());
+ }
+
+ strm.Printf("Directories not searched recursively:\n");
+ const uint32_t num_kext_dirs_no_recursion =
+ m_search_directories_no_recursing.size();
+ for (uint32_t i = 0; i < num_kext_dirs_no_recursion; i++) {
+ strm.Printf("[%d] %s\n", i,
+ m_search_directories_no_recursing[i].GetPath().c_str());
+ }
+
+ strm.Printf(" Number of kexts with dSYMs indexed: %d\n",
+ (int)m_name_to_kext_path_map_with_dsyms.size());
+ strm.Printf(" Number of kexts without dSYMs indexed: %d\n",
+ (int)m_name_to_kext_path_map_without_dsyms.size());
+ strm.Printf(" Number of Kernel binaries with dSYMs indexed: %d\n",
+ (int)m_kernel_binaries_with_dsyms.size());
+ strm.Printf(" Number of Kernel binaries without dSYMs indexed: %d\n",
+ (int)m_kernel_binaries_without_dsyms.size());
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ log->Printf("\nkexts with dSYMs");
+ for (auto pos : m_name_to_kext_path_map_with_dsyms) {
+ log->Printf("%s", pos.second.GetPath().c_str());
+ }
+ log->Printf("\nkexts without dSYMs");
+
+ for (auto pos : m_name_to_kext_path_map_without_dsyms) {
+ log->Printf("%s", pos.second.GetPath().c_str());
+ }
+ log->Printf("\nkernels with dSYMS");
+ for (auto fs : m_kernel_binaries_with_dsyms) {
+ log->Printf("%s", fs.GetPath().c_str());
+ }
+ log->Printf("\nkernels without dSYMS");
+ for (auto fs : m_kernel_binaries_without_dsyms) {
+ log->Printf("%s", fs.GetPath().c_str());
}
+ log->Printf("\n");
+ }
}
// Populate the m_search_directories vector with directories we should search
// for kernel & kext binaries.
-void
-PlatformDarwinKernel::CollectKextAndKernelDirectories ()
-{
- // Differentiate between "ios debug session" and "mac debug session" so we don't index
- // kext bundles that won't be used in this debug session. If this is an ios kext debug
- // session, looking in /System/Library/Extensions is a waste of stat()s, for example.
-
- // DeveloperDirectory is something like "/Applications/Xcode.app/Contents/Developer"
- std::string developer_dir = GetDeveloperDirectory();
- if (developer_dir.empty())
- developer_dir = "/Applications/Xcode.app/Contents/Developer";
-
- if (m_ios_debug_session != eLazyBoolNo)
- {
- AddSDKSubdirsToSearchPaths (developer_dir + "/Platforms/iPhoneOS.platform/Developer/SDKs");
- AddSDKSubdirsToSearchPaths (developer_dir + "/Platforms/AppleTVOS.platform/Developer/SDKs");
- AddSDKSubdirsToSearchPaths (developer_dir + "/Platforms/WatchOS.platform/Developer/SDKs");
- }
- if (m_ios_debug_session != eLazyBoolYes)
- {
- AddSDKSubdirsToSearchPaths (developer_dir + "/Platforms/MacOSX.platform/Developer/SDKs");
- }
-
- AddSDKSubdirsToSearchPaths ("/Volumes/KernelDebugKit");
- AddSDKSubdirsToSearchPaths ("/AppleInternal/Developer/KDKs");
- // The KDKs distributed from Apple installed on external
- // developer systems may be in directories like
- // /Library/Developer/KDKs/KDK_10.10_14A298i.kdk
- AddSDKSubdirsToSearchPaths ("/Library/Developer/KDKs");
-
- if (m_ios_debug_session != eLazyBoolNo)
- {
- }
- if (m_ios_debug_session != eLazyBoolYes)
- {
- AddRootSubdirsToSearchPaths (this, "/");
- }
-
-
- GetUserSpecifiedDirectoriesToSearch ();
-
- // Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols
- FileSpec possible_dir (developer_dir + "/../Symbols", true);
- if (possible_dir.Exists() && possible_dir.IsDirectory())
- m_search_directories.push_back (possible_dir);
-
- // Add simple directory of the current working directory
- m_search_directories_no_recursing.push_back (FileSpec (".", true));
-}
-
-void
-PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch ()
-{
- FileSpecList user_dirs(GetGlobalProperties()->GetKextDirectories());
- std::vector<FileSpec> possible_sdk_dirs;
-
- const uint32_t user_dirs_count = user_dirs.GetSize();
- for (uint32_t i = 0; i < user_dirs_count; i++)
- {
- FileSpec dir = user_dirs.GetFileSpecAtIndex (i);
- dir.ResolvePath();
- if (dir.Exists() && dir.IsDirectory())
- {
- m_search_directories.push_back (dir);
- }
- }
-}
-
-void
-PlatformDarwinKernel::AddRootSubdirsToSearchPaths (PlatformDarwinKernel *thisp, const std::string &dir)
-{
- const char *subdirs[] = {
- "/System/Library/Extensions",
- "/Library/Extensions",
- "/System/Library/Kernels",
- "/System/Library/Extensions/KDK", // this one probably only exist in /AppleInternal/Developer/KDKs/*.kdk/...
- nullptr
- };
- for (int i = 0; subdirs[i] != nullptr; i++)
- {
- FileSpec testdir (dir + subdirs[i], true);
- if (testdir.Exists() && testdir.IsDirectory())
- thisp->m_search_directories.push_back (testdir);
- }
-
- // Look for kernel binaries in the top level directory, without any recursion
- thisp->m_search_directories_no_recursing.push_back (FileSpec (dir + "/", false));
+void PlatformDarwinKernel::CollectKextAndKernelDirectories() {
+ // Differentiate between "ios debug session" and "mac debug session" so we
+ // don't index
+ // kext bundles that won't be used in this debug session. If this is an ios
+ // kext debug
+ // session, looking in /System/Library/Extensions is a waste of stat()s, for
+ // example.
+
+ // DeveloperDirectory is something like
+ // "/Applications/Xcode.app/Contents/Developer"
+ std::string developer_dir = GetDeveloperDirectory();
+ if (developer_dir.empty())
+ developer_dir = "/Applications/Xcode.app/Contents/Developer";
+
+ if (m_ios_debug_session != eLazyBoolNo) {
+ AddSDKSubdirsToSearchPaths(developer_dir +
+ "/Platforms/iPhoneOS.platform/Developer/SDKs");
+ AddSDKSubdirsToSearchPaths(developer_dir +
+ "/Platforms/AppleTVOS.platform/Developer/SDKs");
+ AddSDKSubdirsToSearchPaths(developer_dir +
+ "/Platforms/WatchOS.platform/Developer/SDKs");
+ }
+ if (m_ios_debug_session != eLazyBoolYes) {
+ AddSDKSubdirsToSearchPaths(developer_dir +
+ "/Platforms/MacOSX.platform/Developer/SDKs");
+ }
+
+ AddSDKSubdirsToSearchPaths("/Volumes/KernelDebugKit");
+ AddSDKSubdirsToSearchPaths("/AppleInternal/Developer/KDKs");
+ // The KDKs distributed from Apple installed on external
+ // developer systems may be in directories like
+ // /Library/Developer/KDKs/KDK_10.10_14A298i.kdk
+ AddSDKSubdirsToSearchPaths("/Library/Developer/KDKs");
+
+ if (m_ios_debug_session != eLazyBoolNo) {
+ }
+ if (m_ios_debug_session != eLazyBoolYes) {
+ AddRootSubdirsToSearchPaths(this, "/");
+ }
+
+ GetUserSpecifiedDirectoriesToSearch();
+
+ // Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols
+ FileSpec possible_dir(developer_dir + "/../Symbols", true);
+ if (possible_dir.Exists() && possible_dir.IsDirectory())
+ m_search_directories.push_back(possible_dir);
+
+ // Add simple directory of the current working directory
+ m_search_directories_no_recursing.push_back(FileSpec(".", true));
+}
+
+void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() {
+ FileSpecList user_dirs(GetGlobalProperties()->GetKextDirectories());
+ std::vector<FileSpec> possible_sdk_dirs;
+
+ const uint32_t user_dirs_count = user_dirs.GetSize();
+ for (uint32_t i = 0; i < user_dirs_count; i++) {
+ FileSpec dir = user_dirs.GetFileSpecAtIndex(i);
+ dir.ResolvePath();
+ if (dir.Exists() && dir.IsDirectory()) {
+ m_search_directories.push_back(dir);
+ }
+ }
+}
+
+void PlatformDarwinKernel::AddRootSubdirsToSearchPaths(
+ PlatformDarwinKernel *thisp, const std::string &dir) {
+ const char *subdirs[] = {
+ "/System/Library/Extensions", "/Library/Extensions",
+ "/System/Library/Kernels",
+ "/System/Library/Extensions/KDK", // this one probably only exist in
+ // /AppleInternal/Developer/KDKs/*.kdk/...
+ nullptr};
+ for (int i = 0; subdirs[i] != nullptr; i++) {
+ FileSpec testdir(dir + subdirs[i], true);
+ if (testdir.Exists() && testdir.IsDirectory())
+ thisp->m_search_directories.push_back(testdir);
+ }
+
+ // Look for kernel binaries in the top level directory, without any recursion
+ thisp->m_search_directories_no_recursing.push_back(
+ FileSpec(dir + "/", false));
}
// Given a directory path dir, look for any subdirs named *.kdk and *.sdk
-void
-PlatformDarwinKernel::AddSDKSubdirsToSearchPaths (const std::string &dir)
-{
- // Look for *.kdk and *.sdk in dir
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = false;
- FileSpec::EnumerateDirectory (dir.c_str(),
- find_directories,
- find_files,
- find_other,
- FindKDKandSDKDirectoriesInDirectory,
- this);
+void PlatformDarwinKernel::AddSDKSubdirsToSearchPaths(const std::string &dir) {
+ // Look for *.kdk and *.sdk in dir
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = false;
+ FileSpec::EnumerateDirectory(dir.c_str(), find_directories, find_files,
+ find_other, FindKDKandSDKDirectoriesInDirectory,
+ this);
}
// Helper function to find *.sdk and *.kdk directories in a given directory.
FileSpec::EnumerateDirectoryResult
-PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec)
-{
- static ConstString g_sdk_suffix = ConstString ("sdk");
- static ConstString g_kdk_suffix = ConstString ("kdk");
-
- PlatformDarwinKernel *thisp = (PlatformDarwinKernel *) baton;
- if (file_type == FileSpec::eFileTypeDirectory
- && (file_spec.GetFileNameExtension() == g_sdk_suffix
- || file_spec.GetFileNameExtension() == g_kdk_suffix))
- {
- AddRootSubdirsToSearchPaths (thisp, file_spec.GetPath());
- }
- return FileSpec::eEnumerateDirectoryResultNext;
+PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ static ConstString g_sdk_suffix = ConstString("sdk");
+ static ConstString g_kdk_suffix = ConstString("kdk");
+
+ PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
+ if (file_type == FileSpec::eFileTypeDirectory &&
+ (file_spec.GetFileNameExtension() == g_sdk_suffix ||
+ file_spec.GetFileNameExtension() == g_kdk_suffix)) {
+ AddRootSubdirsToSearchPaths(thisp, file_spec.GetPath());
+ }
+ return FileSpec::eEnumerateDirectoryResultNext;
}
// Recursively search trough m_search_directories looking for
// kext and kernel binaries, adding files found to the appropriate
// lists.
-void
-PlatformDarwinKernel::SearchForKextsAndKernelsRecursively ()
-{
- const uint32_t num_dirs = m_search_directories.size();
- for (uint32_t i = 0; i < num_dirs; i++)
- {
- const FileSpec &dir = m_search_directories[i];
- const bool find_directories = true;
- const bool find_files = true;
- const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s.
- FileSpec::EnumerateDirectory (dir.GetPath().c_str(),
- find_directories,
- find_files,
- find_other,
- GetKernelsAndKextsInDirectoryWithRecursion,
- this);
- }
- const uint32_t num_dirs_no_recurse = m_search_directories_no_recursing.size();
- for (uint32_t i = 0; i < num_dirs_no_recurse; i++)
- {
- const FileSpec &dir = m_search_directories_no_recursing[i];
- const bool find_directories = true;
- const bool find_files = true;
- const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s.
- FileSpec::EnumerateDirectory (dir.GetPath().c_str(),
- find_directories,
- find_files,
- find_other,
- GetKernelsAndKextsInDirectoryNoRecursion,
- this);
- }
-
+void PlatformDarwinKernel::SearchForKextsAndKernelsRecursively() {
+ const uint32_t num_dirs = m_search_directories.size();
+ for (uint32_t i = 0; i < num_dirs; i++) {
+ const FileSpec &dir = m_search_directories[i];
+ const bool find_directories = true;
+ const bool find_files = true;
+ const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s.
+ FileSpec::EnumerateDirectory(
+ dir.GetPath().c_str(), find_directories, find_files, find_other,
+ GetKernelsAndKextsInDirectoryWithRecursion, this);
+ }
+ const uint32_t num_dirs_no_recurse = m_search_directories_no_recursing.size();
+ for (uint32_t i = 0; i < num_dirs_no_recurse; i++) {
+ const FileSpec &dir = m_search_directories_no_recursing[i];
+ const bool find_directories = true;
+ const bool find_files = true;
+ const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s.
+ FileSpec::EnumerateDirectory(
+ dir.GetPath().c_str(), find_directories, find_files, find_other,
+ GetKernelsAndKextsInDirectoryNoRecursion, this);
+ }
}
-// We're only doing a filename match here. We won't try opening the file to see if it's really
-// a kernel or not until we need to find a kernel of a given UUID. There's no cheap way to find
-// the UUID of a file (or if it's a Mach-O binary at all) without creating a whole Module for
+// We're only doing a filename match here. We won't try opening the file to see
+// if it's really
+// a kernel or not until we need to find a kernel of a given UUID. There's no
+// cheap way to find
+// the UUID of a file (or if it's a Mach-O binary at all) without creating a
+// whole Module for
// the file and throwing it away if it's not wanted.
-//
+//
// Recurse into any subdirectories found.
FileSpec::EnumerateDirectoryResult
-PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec)
-{
- return GetKernelsAndKextsInDirectoryHelper (baton, file_type, file_spec, true);
+PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ return GetKernelsAndKextsInDirectoryHelper(baton, file_type, file_spec, true);
}
FileSpec::EnumerateDirectoryResult
-PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec)
-{
- return GetKernelsAndKextsInDirectoryHelper (baton, file_type, file_spec, false);
+PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ return GetKernelsAndKextsInDirectoryHelper(baton, file_type, file_spec,
+ false);
}
FileSpec::EnumerateDirectoryResult
-PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec,
- bool recurse)
-{
- static ConstString g_kext_suffix = ConstString ("kext");
- static ConstString g_dsym_suffix = ConstString ("dSYM");
- static ConstString g_bundle_suffix = ConstString ("Bundle");
- ConstString file_spec_extension = file_spec.GetFileNameExtension();
-
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf ("PlatformDarwinKernel examining %s", file_spec.GetPath().c_str());
-
- PlatformDarwinKernel *thisp = (PlatformDarwinKernel *) baton;
- if (file_type == FileSpec::eFileTypeRegular || file_type == FileSpec::eFileTypeSymbolicLink)
- {
- ConstString filename = file_spec.GetFilename();
- if ((strncmp (filename.GetCString(), "kernel", 6) == 0 || strncmp (filename.GetCString(), "mach", 4) == 0)
- && file_spec_extension != g_dsym_suffix)
- {
- if (KernelHasdSYMSibling (file_spec))
- thisp->m_kernel_binaries_with_dsyms.push_back (file_spec);
- else
- thisp->m_kernel_binaries_without_dsyms.push_back (file_spec);
- return FileSpec::eEnumerateDirectoryResultNext;
- }
- }
- else if (file_type == FileSpec::eFileTypeDirectory && file_spec_extension == g_kext_suffix)
- {
- AddKextToMap (thisp, file_spec);
- // Look to see if there is a PlugIns subdir with more kexts
- FileSpec contents_plugins (file_spec.GetPath() + "/Contents/PlugIns", false);
- std::string search_here_too;
- if (contents_plugins.Exists() && contents_plugins.IsDirectory())
- {
- search_here_too = contents_plugins.GetPath();
- }
- else
- {
- FileSpec plugins (file_spec.GetPath() + "/PlugIns", false);
- if (plugins.Exists() && plugins.IsDirectory())
- {
- search_here_too = plugins.GetPath();
- }
- }
-
- if (!search_here_too.empty())
- {
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = false;
- FileSpec::EnumerateDirectory (search_here_too.c_str(),
- find_directories,
- find_files,
- find_other,
- recurse ? GetKernelsAndKextsInDirectoryWithRecursion : GetKernelsAndKextsInDirectoryNoRecursion,
- baton);
- }
- return FileSpec::eEnumerateDirectoryResultNext;
- }
- // Don't recurse into dSYM/kext/bundle directories
- if (recurse
- && file_spec_extension != g_dsym_suffix
- && file_spec_extension != g_kext_suffix
- && file_spec_extension != g_bundle_suffix)
- {
- return FileSpec::eEnumerateDirectoryResultEnter;
- }
- else
- {
- return FileSpec::eEnumerateDirectoryResultNext;
+PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec,
+ bool recurse) {
+ static ConstString g_kext_suffix = ConstString("kext");
+ static ConstString g_dsym_suffix = ConstString("dSYM");
+ static ConstString g_bundle_suffix = ConstString("Bundle");
+ ConstString file_spec_extension = file_spec.GetFileNameExtension();
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("PlatformDarwinKernel examining %s",
+ file_spec.GetPath().c_str());
+
+ PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
+ if (file_type == FileSpec::eFileTypeRegular ||
+ file_type == FileSpec::eFileTypeSymbolicLink) {
+ ConstString filename = file_spec.GetFilename();
+ if ((strncmp(filename.GetCString(), "kernel", 6) == 0 ||
+ strncmp(filename.GetCString(), "mach", 4) == 0) &&
+ file_spec_extension != g_dsym_suffix) {
+ if (KernelHasdSYMSibling(file_spec))
+ thisp->m_kernel_binaries_with_dsyms.push_back(file_spec);
+ else
+ thisp->m_kernel_binaries_without_dsyms.push_back(file_spec);
+ return FileSpec::eEnumerateDirectoryResultNext;
+ }
+ } else if (file_type == FileSpec::eFileTypeDirectory &&
+ file_spec_extension == g_kext_suffix) {
+ AddKextToMap(thisp, file_spec);
+ // Look to see if there is a PlugIns subdir with more kexts
+ FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns", false);
+ std::string search_here_too;
+ if (contents_plugins.Exists() && contents_plugins.IsDirectory()) {
+ search_here_too = contents_plugins.GetPath();
+ } else {
+ FileSpec plugins(file_spec.GetPath() + "/PlugIns", false);
+ if (plugins.Exists() && plugins.IsDirectory()) {
+ search_here_too = plugins.GetPath();
+ }
+ }
+
+ if (!search_here_too.empty()) {
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = false;
+ FileSpec::EnumerateDirectory(
+ search_here_too.c_str(), find_directories, find_files, find_other,
+ recurse ? GetKernelsAndKextsInDirectoryWithRecursion
+ : GetKernelsAndKextsInDirectoryNoRecursion,
+ baton);
}
+ return FileSpec::eEnumerateDirectoryResultNext;
+ }
+ // Don't recurse into dSYM/kext/bundle directories
+ if (recurse && file_spec_extension != g_dsym_suffix &&
+ file_spec_extension != g_kext_suffix &&
+ file_spec_extension != g_bundle_suffix) {
+ return FileSpec::eEnumerateDirectoryResultEnter;
+ } else {
+ return FileSpec::eEnumerateDirectoryResultNext;
+ }
}
-void
-PlatformDarwinKernel::AddKextToMap (PlatformDarwinKernel *thisp, const FileSpec &file_spec)
-{
- CFCBundle bundle (file_spec.GetPath().c_str());
- CFStringRef bundle_id (bundle.GetIdentifier());
- if (bundle_id && CFGetTypeID (bundle_id) == CFStringGetTypeID ())
- {
- char bundle_id_buf[PATH_MAX];
- if (CFStringGetCString (bundle_id, bundle_id_buf, sizeof (bundle_id_buf), kCFStringEncodingUTF8))
- {
- ConstString bundle_conststr(bundle_id_buf);
- if (KextHasdSYMSibling (file_spec))
- thisp->m_name_to_kext_path_map_with_dsyms.insert(std::pair<ConstString, FileSpec>(bundle_conststr, file_spec));
- else
- thisp->m_name_to_kext_path_map_without_dsyms.insert(std::pair<ConstString, FileSpec>(bundle_conststr, file_spec));
- }
+void PlatformDarwinKernel::AddKextToMap(PlatformDarwinKernel *thisp,
+ const FileSpec &file_spec) {
+ CFCBundle bundle(file_spec.GetPath().c_str());
+ CFStringRef bundle_id(bundle.GetIdentifier());
+ if (bundle_id && CFGetTypeID(bundle_id) == CFStringGetTypeID()) {
+ char bundle_id_buf[PATH_MAX];
+ if (CFStringGetCString(bundle_id, bundle_id_buf, sizeof(bundle_id_buf),
+ kCFStringEncodingUTF8)) {
+ ConstString bundle_conststr(bundle_id_buf);
+ if (KextHasdSYMSibling(file_spec))
+ thisp->m_name_to_kext_path_map_with_dsyms.insert(
+ std::pair<ConstString, FileSpec>(bundle_conststr, file_spec));
+ else
+ thisp->m_name_to_kext_path_map_without_dsyms.insert(
+ std::pair<ConstString, FileSpec>(bundle_conststr, file_spec));
}
+ }
}
// Given a FileSpec of /dir/dir/foo.kext
@@ -658,261 +585,243 @@ PlatformDarwinKernel::AddKextToMap (Plat
// /dir/dir/foo.kext.dSYM
// /dir/dir/foo.kext/Contents/MacOS/foo.dSYM
// /dir/dir/foo.kext/foo.dSYM
-bool
-PlatformDarwinKernel::KextHasdSYMSibling (const FileSpec &kext_bundle_filepath)
-{
- FileSpec dsym_fspec = kext_bundle_filepath;
- std::string filename = dsym_fspec.GetFilename().AsCString();
- filename += ".dSYM";
- dsym_fspec.GetFilename() = ConstString (filename);
- if (dsym_fspec.Exists() && dsym_fspec.IsDirectory())
- {
- return true;
- }
- // Should probably get the CFBundleExecutable here or call CFBundleCopyExecutableURL
-
- // Look for a deep bundle foramt
- ConstString executable_name = kext_bundle_filepath.GetFileNameStrippingExtension();
- std::string deep_bundle_str = kext_bundle_filepath.GetPath() + "/Contents/MacOS/";
- deep_bundle_str += executable_name.AsCString();
- deep_bundle_str += ".dSYM";
- dsym_fspec.SetFile (deep_bundle_str, true);
- if (dsym_fspec.Exists() && dsym_fspec.IsDirectory())
- {
- return true;
- }
-
- // look for a shallow bundle format
- //
- std::string shallow_bundle_str = kext_bundle_filepath.GetPath() + "/";
- shallow_bundle_str += executable_name.AsCString();
- shallow_bundle_str += ".dSYM";
- dsym_fspec.SetFile (shallow_bundle_str, true);
- if (dsym_fspec.Exists() && dsym_fspec.IsDirectory())
- {
- return true;
- }
- return false;
+bool PlatformDarwinKernel::KextHasdSYMSibling(
+ const FileSpec &kext_bundle_filepath) {
+ FileSpec dsym_fspec = kext_bundle_filepath;
+ std::string filename = dsym_fspec.GetFilename().AsCString();
+ filename += ".dSYM";
+ dsym_fspec.GetFilename() = ConstString(filename);
+ if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
+ return true;
+ }
+ // Should probably get the CFBundleExecutable here or call
+ // CFBundleCopyExecutableURL
+
+ // Look for a deep bundle foramt
+ ConstString executable_name =
+ kext_bundle_filepath.GetFileNameStrippingExtension();
+ std::string deep_bundle_str =
+ kext_bundle_filepath.GetPath() + "/Contents/MacOS/";
+ deep_bundle_str += executable_name.AsCString();
+ deep_bundle_str += ".dSYM";
+ dsym_fspec.SetFile(deep_bundle_str, true);
+ if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
+ return true;
+ }
+
+ // look for a shallow bundle format
+ //
+ std::string shallow_bundle_str = kext_bundle_filepath.GetPath() + "/";
+ shallow_bundle_str += executable_name.AsCString();
+ shallow_bundle_str += ".dSYM";
+ dsym_fspec.SetFile(shallow_bundle_str, true);
+ if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
+ return true;
+ }
+ return false;
}
// Given a FileSpec of /dir/dir/mach.development.t7004
// Return true if a dSYM exists next to it:
// /dir/dir/mach.development.t7004.dSYM
-bool
-PlatformDarwinKernel::KernelHasdSYMSibling (const FileSpec &kernel_binary)
-{
- FileSpec kernel_dsym = kernel_binary;
- std::string filename = kernel_binary.GetFilename().AsCString();
- filename += ".dSYM";
- kernel_dsym.GetFilename() = ConstString (filename);
- if (kernel_dsym.Exists() && kernel_dsym.IsDirectory())
- {
- return true;
- }
- return false;
-}
-
-
-Error
-PlatformDarwinKernel::GetSharedModule (const ModuleSpec &module_spec,
- Process *process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- Error error;
- module_sp.reset();
- const FileSpec &platform_file = module_spec.GetFileSpec();
-
- // Treat the file's path as a kext bundle ID (e.g. "com.apple.driver.AppleIRController") and search our kext index.
- std::string kext_bundle_id = platform_file.GetPath();
- if (!kext_bundle_id.empty())
- {
- ConstString kext_bundle_cs(kext_bundle_id.c_str());
-
- // First look through the kext bundles that had a dsym next to them
- if (m_name_to_kext_path_map_with_dsyms.count(kext_bundle_cs) > 0)
- {
- for (BundleIDToKextIterator it = m_name_to_kext_path_map_with_dsyms.begin (); it != m_name_to_kext_path_map_with_dsyms.end (); ++it)
- {
- if (it->first == kext_bundle_cs)
- {
- error = ExamineKextForMatchingUUID (it->second, module_spec.GetUUID(), module_spec.GetArchitecture(), module_sp);
- if (module_sp.get())
- {
- return error;
- }
- }
- }
- }
-
- // Second look through the kext binarys without dSYMs
- if (m_name_to_kext_path_map_without_dsyms.count(kext_bundle_cs) > 0)
- {
- for (BundleIDToKextIterator it = m_name_to_kext_path_map_without_dsyms.begin (); it != m_name_to_kext_path_map_without_dsyms.end (); ++it)
- {
- if (it->first == kext_bundle_cs)
- {
- error = ExamineKextForMatchingUUID (it->second, module_spec.GetUUID(), module_spec.GetArchitecture(), module_sp);
- if (module_sp.get())
- {
- return error;
- }
- }
+bool PlatformDarwinKernel::KernelHasdSYMSibling(const FileSpec &kernel_binary) {
+ FileSpec kernel_dsym = kernel_binary;
+ std::string filename = kernel_binary.GetFilename().AsCString();
+ filename += ".dSYM";
+ kernel_dsym.GetFilename() = ConstString(filename);
+ if (kernel_dsym.Exists() && kernel_dsym.IsDirectory()) {
+ return true;
+ }
+ return false;
+}
+
+Error PlatformDarwinKernel::GetSharedModule(
+ const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
+ Error error;
+ module_sp.reset();
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+
+ // Treat the file's path as a kext bundle ID (e.g.
+ // "com.apple.driver.AppleIRController") and search our kext index.
+ std::string kext_bundle_id = platform_file.GetPath();
+ if (!kext_bundle_id.empty()) {
+ ConstString kext_bundle_cs(kext_bundle_id.c_str());
+
+ // First look through the kext bundles that had a dsym next to them
+ if (m_name_to_kext_path_map_with_dsyms.count(kext_bundle_cs) > 0) {
+ for (BundleIDToKextIterator it =
+ m_name_to_kext_path_map_with_dsyms.begin();
+ it != m_name_to_kext_path_map_with_dsyms.end(); ++it) {
+ if (it->first == kext_bundle_cs) {
+ error = ExamineKextForMatchingUUID(it->second, module_spec.GetUUID(),
+ module_spec.GetArchitecture(),
+ module_sp);
+ if (module_sp.get()) {
+ return error;
+ }
+ }
+ }
+ }
+
+ // Second look through the kext binarys without dSYMs
+ if (m_name_to_kext_path_map_without_dsyms.count(kext_bundle_cs) > 0) {
+ for (BundleIDToKextIterator it =
+ m_name_to_kext_path_map_without_dsyms.begin();
+ it != m_name_to_kext_path_map_without_dsyms.end(); ++it) {
+ if (it->first == kext_bundle_cs) {
+ error = ExamineKextForMatchingUUID(it->second, module_spec.GetUUID(),
+ module_spec.GetArchitecture(),
+ module_sp);
+ if (module_sp.get()) {
+ return error;
+ }
+ }
+ }
+ }
+ }
+
+ if (kext_bundle_id.compare("mach_kernel") == 0 &&
+ module_spec.GetUUID().IsValid()) {
+ // First try all kernel binaries that have a dSYM next to them
+ for (auto possible_kernel : m_kernel_binaries_with_dsyms) {
+ if (possible_kernel.Exists()) {
+ ModuleSpec kern_spec(possible_kernel);
+ kern_spec.GetUUID() = module_spec.GetUUID();
+ ModuleSP module_sp(new Module(kern_spec));
+ if (module_sp && module_sp->GetObjectFile() &&
+ module_sp->MatchesModuleSpec(kern_spec)) {
+ // module_sp is an actual kernel binary we want to add.
+ if (process) {
+ process->GetTarget().GetImages().AppendIfNeeded(module_sp);
+ error.Clear();
+ return error;
+ } else {
+ error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL,
+ NULL, NULL);
+ if (module_sp && module_sp->GetObjectFile() &&
+ module_sp->GetObjectFile()->GetType() !=
+ ObjectFile::Type::eTypeCoreFile) {
+ return error;
}
+ module_sp.reset();
+ }
}
-
+ }
}
-
- if (kext_bundle_id.compare("mach_kernel") == 0 && module_spec.GetUUID().IsValid())
- {
- // First try all kernel binaries that have a dSYM next to them
- for (auto possible_kernel : m_kernel_binaries_with_dsyms)
- {
- if (possible_kernel.Exists())
- {
- ModuleSpec kern_spec (possible_kernel);
- kern_spec.GetUUID() = module_spec.GetUUID();
- ModuleSP module_sp (new Module (kern_spec));
- if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (kern_spec))
- {
- // module_sp is an actual kernel binary we want to add.
- if (process)
- {
- process->GetTarget().GetImages().AppendIfNeeded (module_sp);
- error.Clear();
- return error;
- }
- else
- {
- error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL);
- if (module_sp
- && module_sp->GetObjectFile()
- && module_sp->GetObjectFile()->GetType() != ObjectFile::Type::eTypeCoreFile)
- {
- return error;
- }
- module_sp.reset();
- }
- }
- }
- }
- // Second try all kernel binaries that don't have a dSYM
- for (auto possible_kernel : m_kernel_binaries_without_dsyms)
- {
- if (possible_kernel.Exists())
- {
- ModuleSpec kern_spec (possible_kernel);
- kern_spec.GetUUID() = module_spec.GetUUID();
- ModuleSP module_sp (new Module (kern_spec));
- if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (kern_spec))
- {
- // module_sp is an actual kernel binary we want to add.
- if (process)
- {
- process->GetTarget().GetImages().AppendIfNeeded (module_sp);
- error.Clear();
- return error;
- }
- else
- {
- error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL);
- if (module_sp
- && module_sp->GetObjectFile()
- && module_sp->GetObjectFile()->GetType() != ObjectFile::Type::eTypeCoreFile)
- {
- return error;
- }
- module_sp.reset();
- }
- }
+ // Second try all kernel binaries that don't have a dSYM
+ for (auto possible_kernel : m_kernel_binaries_without_dsyms) {
+ if (possible_kernel.Exists()) {
+ ModuleSpec kern_spec(possible_kernel);
+ kern_spec.GetUUID() = module_spec.GetUUID();
+ ModuleSP module_sp(new Module(kern_spec));
+ if (module_sp && module_sp->GetObjectFile() &&
+ module_sp->MatchesModuleSpec(kern_spec)) {
+ // module_sp is an actual kernel binary we want to add.
+ if (process) {
+ process->GetTarget().GetImages().AppendIfNeeded(module_sp);
+ error.Clear();
+ return error;
+ } else {
+ error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL,
+ NULL, NULL);
+ if (module_sp && module_sp->GetObjectFile() &&
+ module_sp->GetObjectFile()->GetType() !=
+ ObjectFile::Type::eTypeCoreFile) {
+ return error;
}
+ module_sp.reset();
+ }
}
+ }
}
+ }
- // Else fall back to treating the file's path as an actual file path - defer to PlatformDarwin's GetSharedModule.
- return PlatformDarwin::GetSharedModule (module_spec, process, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
-}
-
-Error
-PlatformDarwinKernel::ExamineKextForMatchingUUID (const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid, const ArchSpec &arch, ModuleSP &exe_module_sp)
-{
- Error error;
- FileSpec exe_file = kext_bundle_path;
- Host::ResolveExecutableInBundle (exe_file);
- if (exe_file.Exists())
- {
- ModuleSpec exe_spec (exe_file);
- exe_spec.GetUUID() = uuid;
- if (!uuid.IsValid())
- {
- exe_spec.GetArchitecture() = arch;
- }
-
- // First try to create a ModuleSP with the file / arch and see if the UUID matches.
- // If that fails (this exec file doesn't have the correct uuid), don't call GetSharedModule
- // (which may call in to the DebugSymbols framework and therefore can be slow.)
- ModuleSP module_sp (new Module (exe_spec));
- if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (exe_spec))
- {
- error = ModuleList::GetSharedModule (exe_spec, exe_module_sp, NULL, NULL, NULL);
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- {
- return error;
- }
- }
- exe_module_sp.reset();
- }
- return error;
-}
-
-bool
-PlatformDarwinKernel::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
-#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
- return ARMGetSupportedArchitectureAtIndex (idx, arch);
+ // Else fall back to treating the file's path as an actual file path - defer
+ // to PlatformDarwin's GetSharedModule.
+ return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+}
+
+Error PlatformDarwinKernel::ExamineKextForMatchingUUID(
+ const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid,
+ const ArchSpec &arch, ModuleSP &exe_module_sp) {
+ Error error;
+ FileSpec exe_file = kext_bundle_path;
+ Host::ResolveExecutableInBundle(exe_file);
+ if (exe_file.Exists()) {
+ ModuleSpec exe_spec(exe_file);
+ exe_spec.GetUUID() = uuid;
+ if (!uuid.IsValid()) {
+ exe_spec.GetArchitecture() = arch;
+ }
+
+ // First try to create a ModuleSP with the file / arch and see if the UUID
+ // matches.
+ // If that fails (this exec file doesn't have the correct uuid), don't call
+ // GetSharedModule
+ // (which may call in to the DebugSymbols framework and therefore can be
+ // slow.)
+ ModuleSP module_sp(new Module(exe_spec));
+ if (module_sp && module_sp->GetObjectFile() &&
+ module_sp->MatchesModuleSpec(exe_spec)) {
+ error = ModuleList::GetSharedModule(exe_spec, exe_module_sp, NULL, NULL,
+ NULL);
+ if (exe_module_sp && exe_module_sp->GetObjectFile()) {
+ return error;
+ }
+ }
+ exe_module_sp.reset();
+ }
+ return error;
+}
+
+bool PlatformDarwinKernel::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+ return ARMGetSupportedArchitectureAtIndex(idx, arch);
#else
- return x86GetSupportedArchitectureAtIndex (idx, arch);
+ return x86GetSupportedArchitectureAtIndex(idx, arch);
#endif
}
-void
-PlatformDarwinKernel::CalculateTrapHandlerSymbolNames ()
-{
- m_trap_handlers.push_back(ConstString ("trap_from_kernel"));
- m_trap_handlers.push_back(ConstString ("hndl_machine_check"));
- m_trap_handlers.push_back(ConstString ("hndl_double_fault"));
- m_trap_handlers.push_back(ConstString ("hndl_allintrs"));
- m_trap_handlers.push_back(ConstString ("hndl_alltraps"));
- m_trap_handlers.push_back(ConstString ("interrupt"));
- m_trap_handlers.push_back(ConstString ("fleh_prefabt"));
- m_trap_handlers.push_back(ConstString ("ExceptionVectorsBase"));
- m_trap_handlers.push_back(ConstString ("ExceptionVectorsTable"));
- m_trap_handlers.push_back(ConstString ("fleh_undef"));
- m_trap_handlers.push_back(ConstString ("fleh_dataabt"));
- m_trap_handlers.push_back(ConstString ("fleh_irq"));
- m_trap_handlers.push_back(ConstString ("fleh_decirq"));
- m_trap_handlers.push_back(ConstString ("fleh_fiq_generic"));
- m_trap_handlers.push_back(ConstString ("fleh_dec"));
-
+void PlatformDarwinKernel::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("trap_from_kernel"));
+ m_trap_handlers.push_back(ConstString("hndl_machine_check"));
+ m_trap_handlers.push_back(ConstString("hndl_double_fault"));
+ m_trap_handlers.push_back(ConstString("hndl_allintrs"));
+ m_trap_handlers.push_back(ConstString("hndl_alltraps"));
+ m_trap_handlers.push_back(ConstString("interrupt"));
+ m_trap_handlers.push_back(ConstString("fleh_prefabt"));
+ m_trap_handlers.push_back(ConstString("ExceptionVectorsBase"));
+ m_trap_handlers.push_back(ConstString("ExceptionVectorsTable"));
+ m_trap_handlers.push_back(ConstString("fleh_undef"));
+ m_trap_handlers.push_back(ConstString("fleh_dataabt"));
+ m_trap_handlers.push_back(ConstString("fleh_irq"));
+ m_trap_handlers.push_back(ConstString("fleh_decirq"));
+ m_trap_handlers.push_back(ConstString("fleh_fiq_generic"));
+ m_trap_handlers.push_back(ConstString("fleh_dec"));
}
-#else // __APPLE__
+#else // __APPLE__
// Since DynamicLoaderDarwinKernel is compiled in for all systems, and relies on
-// PlatformDarwinKernel for the plug-in name, we compile just the plug-in name in
-// here to avoid issues. We are tracking an internal bug to resolve this issue by
-// either not compiling in DynamicLoaderDarwinKernel for non-apple builds, or to make
-// PlatformDarwinKernel build on all systems. PlatformDarwinKernel is currently not
+// PlatformDarwinKernel for the plug-in name, we compile just the plug-in name
+// in
+// here to avoid issues. We are tracking an internal bug to resolve this issue
+// by
+// either not compiling in DynamicLoaderDarwinKernel for non-apple builds, or to
+// make
+// PlatformDarwinKernel build on all systems. PlatformDarwinKernel is currently
+// not
// compiled on other platforms due to the use of the Mac-specific
// source/Host/macosx/cfcpp utilities.
-lldb_private::ConstString
-PlatformDarwinKernel::GetPluginNameStatic ()
-{
- static lldb_private::ConstString g_name("darwin-kernel");
- return g_name;
+lldb_private::ConstString PlatformDarwinKernel::GetPluginNameStatic() {
+ static lldb_private::ConstString g_name("darwin-kernel");
+ return g_name;
}
#endif // __APPLE__
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h Tue Sep 6 15:57:50 2016
@@ -12,8 +12,8 @@
#include "lldb/Core/ConstString.h"
-#if defined (__APPLE__) // This Plugin uses the Mac-specific source/Host/macosx/cfcpp utilities
-
+#if defined(__APPLE__) // This Plugin uses the Mac-specific
+ // source/Host/macosx/cfcpp utilities
// C Includes
// C++ Includes
@@ -23,175 +23,186 @@
// Project includes
#include "PlatformDarwin.h"
-class PlatformDarwinKernel : public PlatformDarwin
-{
+class PlatformDarwinKernel : public PlatformDarwin {
public:
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- DebuggerInitialize (lldb_private::Debugger &debugger);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
- PlatformDarwinKernel (lldb_private::LazyBool is_ios_debug_session);
-
- virtual
- ~PlatformDarwinKernel();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process *process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- bool
- SupportsModules() override { return false; }
-
- void
- CalculateTrapHandlerSymbolNames () override;
-
-protected:
-
- // Map from kext bundle ID ("com.apple.filesystems.exfat") to FileSpec for the kext bundle on
- // the host ("/System/Library/Extensions/exfat.kext/Contents/Info.plist").
- typedef std::multimap<lldb_private::ConstString, lldb_private::FileSpec> BundleIDToKextMap;
- typedef BundleIDToKextMap::iterator BundleIDToKextIterator;
+ static void DebuggerInitialize(lldb_private::Debugger &debugger);
- typedef std::vector<lldb_private::FileSpec> KernelBinaryCollection;
-
- // Array of directories that were searched for kext bundles (used only for reporting to user)
- typedef std::vector<lldb_private::FileSpec> DirectoriesSearchedCollection;
- typedef DirectoriesSearchedCollection::iterator DirectoriesSearchedIterator;
+ static void Initialize();
+ static void Terminate();
- // Populate m_search_directories and m_search_directories_no_recursing vectors of directories
- void
- CollectKextAndKernelDirectories ();
+ static lldb_private::ConstString GetPluginNameStatic();
- void
- GetUserSpecifiedDirectoriesToSearch ();
+ static const char *GetDescriptionStatic();
- static void
- AddRootSubdirsToSearchPaths (PlatformDarwinKernel *thisp, const std::string &dir);
-
- void
- AddSDKSubdirsToSearchPaths (const std::string &dir);
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ PlatformDarwinKernel(lldb_private::LazyBool is_ios_debug_session);
- static lldb_private::FileSpec::EnumerateDirectoryResult
- FindKDKandSDKDirectoriesInDirectory (void *baton, lldb_private::FileSpec::FileType file_type, const lldb_private::FileSpec &file_spec);
+ virtual ~PlatformDarwinKernel();
- void
- SearchForKextsAndKernelsRecursively ();
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
- static lldb_private::FileSpec::EnumerateDirectoryResult
- GetKernelsAndKextsInDirectoryWithRecursion (void *baton, lldb_private::FileSpec::FileType file_type, const lldb_private::FileSpec &file_spec);
+ uint32_t GetPluginVersion() override { return 1; }
- static lldb_private::FileSpec::EnumerateDirectoryResult
- GetKernelsAndKextsInDirectoryNoRecursion (void *baton, lldb_private::FileSpec::FileType file_type, const lldb_private::FileSpec &file_spec);
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ const char *GetDescription() override { return GetDescriptionStatic(); }
- static lldb_private::FileSpec::EnumerateDirectoryResult
- GetKernelsAndKextsInDirectoryHelper (void *baton, lldb_private::FileSpec::FileType file_type, const lldb_private::FileSpec &file_spec, bool recurse);
+ void GetStatus(lldb_private::Stream &strm) override;
- static void
- AddKextToMap (PlatformDarwinKernel *thisp, const lldb_private::FileSpec &file_spec);
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
- // Returns true if there is a .dSYM bundle next to the kext, or next to the binary inside the kext.
- static bool
- KextHasdSYMSibling (const lldb_private::FileSpec &kext_bundle_filepath);
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
- // Returns true if there is a .dSYM bundle next to the kernel
- static bool
- KernelHasdSYMSibling (const lldb_private::FileSpec &kext_bundle_filepath);
+ bool SupportsModules() override { return false; }
- lldb_private::Error
- ExamineKextForMatchingUUID (const lldb_private::FileSpec &kext_bundle_path, const lldb_private::UUID &uuid, const lldb_private::ArchSpec &arch, lldb::ModuleSP &exe_module_sp);
+ void CalculateTrapHandlerSymbolNames() override;
- // Most of the ivars are assembled under FileSpec::EnumerateDirectory calls where the
- // function being called for each file/directory must be static. We'll pass a this pointer
- // as a baton and access the ivars directly. Toss-up whether this should just be a struct
- // at this point.
+protected:
+ // Map from kext bundle ID ("com.apple.filesystems.exfat") to FileSpec for the
+ // kext bundle on
+ // the host ("/System/Library/Extensions/exfat.kext/Contents/Info.plist").
+ typedef std::multimap<lldb_private::ConstString, lldb_private::FileSpec>
+ BundleIDToKextMap;
+ typedef BundleIDToKextMap::iterator BundleIDToKextIterator;
+
+ typedef std::vector<lldb_private::FileSpec> KernelBinaryCollection;
+
+ // Array of directories that were searched for kext bundles (used only for
+ // reporting to user)
+ typedef std::vector<lldb_private::FileSpec> DirectoriesSearchedCollection;
+ typedef DirectoriesSearchedCollection::iterator DirectoriesSearchedIterator;
+
+ // Populate m_search_directories and m_search_directories_no_recursing vectors
+ // of directories
+ void CollectKextAndKernelDirectories();
+
+ void GetUserSpecifiedDirectoriesToSearch();
+
+ static void AddRootSubdirsToSearchPaths(PlatformDarwinKernel *thisp,
+ const std::string &dir);
+
+ void AddSDKSubdirsToSearchPaths(const std::string &dir);
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ FindKDKandSDKDirectoriesInDirectory(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec);
+
+ void SearchForKextsAndKernelsRecursively();
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ GetKernelsAndKextsInDirectoryWithRecursion(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec);
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ GetKernelsAndKextsInDirectoryNoRecursion(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec);
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ GetKernelsAndKextsInDirectoryHelper(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec, bool recurse);
+
+ static void AddKextToMap(PlatformDarwinKernel *thisp,
+ const lldb_private::FileSpec &file_spec);
+
+ // Returns true if there is a .dSYM bundle next to the kext, or next to the
+ // binary inside the kext.
+ static bool
+ KextHasdSYMSibling(const lldb_private::FileSpec &kext_bundle_filepath);
+
+ // Returns true if there is a .dSYM bundle next to the kernel
+ static bool
+ KernelHasdSYMSibling(const lldb_private::FileSpec &kext_bundle_filepath);
+
+ lldb_private::Error
+ ExamineKextForMatchingUUID(const lldb_private::FileSpec &kext_bundle_path,
+ const lldb_private::UUID &uuid,
+ const lldb_private::ArchSpec &arch,
+ lldb::ModuleSP &exe_module_sp);
+
+ // Most of the ivars are assembled under FileSpec::EnumerateDirectory calls
+ // where the
+ // function being called for each file/directory must be static. We'll pass a
+ // this pointer
+ // as a baton and access the ivars directly. Toss-up whether this should just
+ // be a struct
+ // at this point.
public:
+ BundleIDToKextMap m_name_to_kext_path_map_with_dsyms; // multimap of
+ // CFBundleID to
+ // FileSpec on local
+ // filesystem, kexts
+ // with dSYMs next to
+ // them
+ BundleIDToKextMap m_name_to_kext_path_map_without_dsyms; // multimap of
+ // CFBundleID to
+ // FileSpec on local
+ // filesystem, kexts
+ // without dSYMs next
+ // to them
+ DirectoriesSearchedCollection
+ m_search_directories; // list of directories we search for kexts/kernels
+ DirectoriesSearchedCollection
+ m_search_directories_no_recursing; // list of directories we search for
+ // kexts/kernels, no recursion
+ KernelBinaryCollection m_kernel_binaries_with_dsyms; // list of kernel
+ // binaries we found on
+ // local filesystem,
+ // without dSYMs next to
+ // them
+ KernelBinaryCollection m_kernel_binaries_without_dsyms; // list of kernel
+ // binaries we found
+ // on local
+ // filesystem, with
+ // dSYMs next to them
+ lldb_private::LazyBool m_ios_debug_session;
- BundleIDToKextMap m_name_to_kext_path_map_with_dsyms; // multimap of CFBundleID to FileSpec on local filesystem, kexts with dSYMs next to them
- BundleIDToKextMap m_name_to_kext_path_map_without_dsyms; // multimap of CFBundleID to FileSpec on local filesystem, kexts without dSYMs next to them
- DirectoriesSearchedCollection m_search_directories; // list of directories we search for kexts/kernels
- DirectoriesSearchedCollection m_search_directories_no_recursing; // list of directories we search for kexts/kernels, no recursion
- KernelBinaryCollection m_kernel_binaries_with_dsyms; // list of kernel binaries we found on local filesystem, without dSYMs next to them
- KernelBinaryCollection m_kernel_binaries_without_dsyms; // list of kernel binaries we found on local filesystem, with dSYMs next to them
- lldb_private::LazyBool m_ios_debug_session;
-
- DISALLOW_COPY_AND_ASSIGN (PlatformDarwinKernel);
-
+ DISALLOW_COPY_AND_ASSIGN(PlatformDarwinKernel);
};
-#else // __APPLE__
+#else // __APPLE__
// Since DynamicLoaderDarwinKernel is compiled in for all systems, and relies on
-// PlatformDarwinKernel for the plug-in name, we compile just the plug-in name in
-// here to avoid issues. We are tracking an internal bug to resolve this issue by
-// either not compiling in DynamicLoaderDarwinKernel for non-apple builds, or to make
-// PlatformDarwinKernel build on all systems. PlatformDarwinKernel is currently not
+// PlatformDarwinKernel for the plug-in name, we compile just the plug-in name
+// in
+// here to avoid issues. We are tracking an internal bug to resolve this issue
+// by
+// either not compiling in DynamicLoaderDarwinKernel for non-apple builds, or to
+// make
+// PlatformDarwinKernel build on all systems. PlatformDarwinKernel is currently
+// not
// compiled on other platforms due to the use of the Mac-specific
// source/Host/macosx/cfcpp utilities.
-class PlatformDarwinKernel
-{
- static lldb_private::ConstString
- GetPluginNameStatic ();
+class PlatformDarwinKernel {
+ static lldb_private::ConstString GetPluginNameStatic();
};
-#endif // __APPLE__
+#endif // __APPLE__
-#endif // liblldb_PlatformDarwinKernel_h_
+#endif // liblldb_PlatformDarwinKernel_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Tue Sep 6 15:57:50 2016
@@ -17,8 +17,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
@@ -35,150 +35,128 @@
using namespace lldb;
using namespace lldb_private;
-
+
static uint32_t g_initialize_count = 0;
-void
-PlatformMacOSX::Initialize ()
-{
- PlatformDarwin::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
-#if defined (__APPLE__)
- PlatformSP default_platform_sp (new PlatformMacOSX(true));
- default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
- Platform::SetHostPlatform (default_platform_sp);
-#endif
- PluginManager::RegisterPlugin (PlatformMacOSX::GetPluginNameStatic(false),
- PlatformMacOSX::GetDescriptionStatic(false),
- PlatformMacOSX::CreateInstance);
- }
+void PlatformMacOSX::Initialize() {
+ PlatformDarwin::Initialize();
+ if (g_initialize_count++ == 0) {
+#if defined(__APPLE__)
+ PlatformSP default_platform_sp(new PlatformMacOSX(true));
+ default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+ Platform::SetHostPlatform(default_platform_sp);
+#endif
+ PluginManager::RegisterPlugin(PlatformMacOSX::GetPluginNameStatic(false),
+ PlatformMacOSX::GetDescriptionStatic(false),
+ PlatformMacOSX::CreateInstance);
+ }
}
-void
-PlatformMacOSX::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformMacOSX::CreateInstance);
- }
+void PlatformMacOSX::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformMacOSX::CreateInstance);
}
+ }
- PlatformDarwin::Terminate ();
+ PlatformDarwin::Terminate();
}
-PlatformSP
-PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
+PlatformSP PlatformMacOSX::CreateInstance(bool force, const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
- log->Printf ("PlatformMacOSX::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
+ log->Printf("PlatformMacOSX::%s(force=%s, arch={%s,%s})", __FUNCTION__,
+ force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ // The only time we create an instance is when we are creating a remote
+ // macosx platform
+ const bool is_host = false;
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor()) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
- // The only time we create an instance is when we are creating a remote
- // macosx platform
- const bool is_host = false;
-
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getVendor())
- {
- case llvm::Triple::Apple:
- create = true;
- break;
-
#if defined(__APPLE__)
- // Only accept "unknown" for vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
-
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::Darwin: // Deprecated, but still support Darwin for historical reasons
- case llvm::Triple::MacOSX:
- break;
+ default:
+ break;
+ }
+
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
+ // historical reasons
+ case llvm::Triple::MacOSX:
+ break;
#if defined(__APPLE__)
- // Only accept "vendor" for vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
+ // Only accept "vendor" for vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
#endif
- default:
- create = false;
- break;
- }
- }
- }
- if (create)
- {
- if (log)
- log->Printf ("PlatformMacOSX::%s() creating platform", __FUNCTION__);
- return PlatformSP(new PlatformMacOSX (is_host));
+ default:
+ create = false;
+ break;
+ }
}
-
+ }
+ if (create) {
if (log)
- log->Printf ("PlatformMacOSX::%s() aborting creation of platform", __FUNCTION__);
-
- return PlatformSP();
-}
-
-lldb_private::ConstString
-PlatformMacOSX::GetPluginNameStatic (bool is_host)
-{
- if (is_host)
- {
- static ConstString g_host_name(Platform::GetHostPlatformName ());
- return g_host_name;
- }
- else
- {
- static ConstString g_remote_name("remote-macosx");
- return g_remote_name;
- }
-}
-
-const char *
-PlatformMacOSX::GetDescriptionStatic (bool is_host)
-{
- if (is_host)
- return "Local Mac OS X user platform plug-in.";
- else
- return "Remote Mac OS X user platform plug-in.";
+ log->Printf("PlatformMacOSX::%s() creating platform", __FUNCTION__);
+ return PlatformSP(new PlatformMacOSX(is_host));
+ }
+
+ if (log)
+ log->Printf("PlatformMacOSX::%s() aborting creation of platform",
+ __FUNCTION__);
+
+ return PlatformSP();
+}
+
+lldb_private::ConstString PlatformMacOSX::GetPluginNameStatic(bool is_host) {
+ if (is_host) {
+ static ConstString g_host_name(Platform::GetHostPlatformName());
+ return g_host_name;
+ } else {
+ static ConstString g_remote_name("remote-macosx");
+ return g_remote_name;
+ }
+}
+
+const char *PlatformMacOSX::GetDescriptionStatic(bool is_host) {
+ if (is_host)
+ return "Local Mac OS X user platform plug-in.";
+ else
+ return "Remote Mac OS X user platform plug-in.";
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformMacOSX::PlatformMacOSX (bool is_host) :
- PlatformDarwin (is_host)
-{
-}
+PlatformMacOSX::PlatformMacOSX(bool is_host) : PlatformDarwin(is_host) {}
//------------------------------------------------------------------
/// Destructor.
@@ -186,201 +164,181 @@ PlatformMacOSX::PlatformMacOSX (bool is_
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformMacOSX::~PlatformMacOSX()
-{
-}
+PlatformMacOSX::~PlatformMacOSX() {}
-ConstString
-PlatformMacOSX::GetSDKDirectory (lldb_private::Target &target)
-{
- ModuleSP exe_module_sp (target.GetExecutableModule());
- if (exe_module_sp)
- {
- ObjectFile *objfile = exe_module_sp->GetObjectFile();
- if (objfile)
- {
- std::string xcode_contents_path;
- std::string default_xcode_sdk;
- FileSpec fspec;
- uint32_t versions[2];
- if (objfile->GetSDKVersion(versions, sizeof(versions)))
- {
- if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, fspec))
- {
- std::string path;
- xcode_contents_path = fspec.GetPath();
- size_t pos = xcode_contents_path.find("/Xcode.app/Contents/");
- if (pos != std::string::npos)
- {
- // LLDB.framework is inside an Xcode app bundle, we can locate the SDK from here
- xcode_contents_path.erase(pos + strlen("/Xcode.app/Contents/"));
- }
- else
- {
- xcode_contents_path.clear();
- // Use the selected Xcode
- int status = 0;
- int signo = 0;
- std::string output;
- const char *command = "xcrun -sdk macosx --show-sdk-path";
- lldb_private::Error error = RunShellCommand (command, // shell command to run
- NULL, // current working directory
- &status, // Put the exit status of the process in here
- &signo, // Put the signal that caused the process to exit in here
- &output, // Get the output from the command and place it in this string
- 3); // Timeout in seconds to wait for shell program to finish
- if (status == 0 && !output.empty())
- {
- size_t first_non_newline = output.find_last_not_of("\r\n");
- if (first_non_newline != std::string::npos)
- output.erase(first_non_newline+1);
- default_xcode_sdk = output;
-
- pos = default_xcode_sdk.find("/Xcode.app/Contents/");
- if (pos != std::string::npos)
- xcode_contents_path = default_xcode_sdk.substr(0, pos + strlen("/Xcode.app/Contents/"));
- }
- }
- }
-
- if (!xcode_contents_path.empty())
- {
- StreamString sdk_path;
- sdk_path.Printf("%sDeveloper/Platforms/MacOSX.platform/Developer/SDKs/MacOSX%u.%u.sdk", xcode_contents_path.c_str(), versions[0], versions[1]);
- fspec.SetFile(sdk_path.GetString().c_str(), false);
- if (fspec.Exists())
- return ConstString(sdk_path.GetString().c_str());
- }
-
- if (!default_xcode_sdk.empty())
- {
- fspec.SetFile(default_xcode_sdk.c_str(), false);
- if (fspec.Exists())
- return ConstString(default_xcode_sdk.c_str());
- }
+ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) {
+ ModuleSP exe_module_sp(target.GetExecutableModule());
+ if (exe_module_sp) {
+ ObjectFile *objfile = exe_module_sp->GetObjectFile();
+ if (objfile) {
+ std::string xcode_contents_path;
+ std::string default_xcode_sdk;
+ FileSpec fspec;
+ uint32_t versions[2];
+ if (objfile->GetSDKVersion(versions, sizeof(versions))) {
+ if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, fspec)) {
+ std::string path;
+ xcode_contents_path = fspec.GetPath();
+ size_t pos = xcode_contents_path.find("/Xcode.app/Contents/");
+ if (pos != std::string::npos) {
+ // LLDB.framework is inside an Xcode app bundle, we can locate the
+ // SDK from here
+ xcode_contents_path.erase(pos + strlen("/Xcode.app/Contents/"));
+ } else {
+ xcode_contents_path.clear();
+ // Use the selected Xcode
+ int status = 0;
+ int signo = 0;
+ std::string output;
+ const char *command = "xcrun -sdk macosx --show-sdk-path";
+ lldb_private::Error error = RunShellCommand(
+ command, // shell command to run
+ NULL, // current working directory
+ &status, // Put the exit status of the process in here
+ &signo, // Put the signal that caused the process to exit in
+ // here
+ &output, // Get the output from the command and place it in this
+ // string
+ 3); // Timeout in seconds to wait for shell program to finish
+ if (status == 0 && !output.empty()) {
+ size_t first_non_newline = output.find_last_not_of("\r\n");
+ if (first_non_newline != std::string::npos)
+ output.erase(first_non_newline + 1);
+ default_xcode_sdk = output;
+
+ pos = default_xcode_sdk.find("/Xcode.app/Contents/");
+ if (pos != std::string::npos)
+ xcode_contents_path = default_xcode_sdk.substr(
+ 0, pos + strlen("/Xcode.app/Contents/"));
}
+ }
}
- }
- return ConstString();
-}
+ if (!xcode_contents_path.empty()) {
+ StreamString sdk_path;
+ sdk_path.Printf("%sDeveloper/Platforms/MacOSX.platform/Developer/"
+ "SDKs/MacOSX%u.%u.sdk",
+ xcode_contents_path.c_str(), versions[0],
+ versions[1]);
+ fspec.SetFile(sdk_path.GetString().c_str(), false);
+ if (fspec.Exists())
+ return ConstString(sdk_path.GetString().c_str());
+ }
-Error
-PlatformMacOSX::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- if (IsRemote())
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
+ if (!default_xcode_sdk.empty()) {
+ fspec.SetFile(default_xcode_sdk.c_str(), false);
+ if (fspec.Exists())
+ return ConstString(default_xcode_sdk.c_str());
+ }
+ }
}
+ }
+ return ConstString();
+}
- // Default to the local case
- local_file = platform_file;
- return Error();
+Error PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+ }
+
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
}
lldb_private::Error
-PlatformMacOSX::GetFileWithUUID (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file)
-{
- if (IsRemote() && m_remote_platform_sp)
- {
- std::string local_os_build;
+PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file) {
+ if (IsRemote() && m_remote_platform_sp) {
+ std::string local_os_build;
#if !defined(__linux__)
- HostInfo::GetOSBuildString(local_os_build);
+ HostInfo::GetOSBuildString(local_os_build);
#endif
- std::string remote_os_build;
- m_remote_platform_sp->GetOSBuildString(remote_os_build);
- if (local_os_build.compare(remote_os_build) == 0)
- {
- // same OS version: the local file is good enough
- local_file = platform_file;
- return Error();
- }
- else
- {
- // try to find the file in the cache
- std::string cache_path(GetLocalCacheDirectory());
- std::string module_path (platform_file.GetPath());
- cache_path.append(module_path);
- FileSpec module_cache_spec(cache_path.c_str(),false);
- if (module_cache_spec.Exists())
- {
- local_file = module_cache_spec;
- return Error();
- }
- // bring in the remote module file
- FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent();
- // try to make the local directory first
- Error err =
- FileSystem::MakeDirectory(module_cache_folder, eFilePermissionsDirectoryDefault);
- if (err.Fail())
- return err;
- err = GetFile(platform_file, module_cache_spec);
- if (err.Fail())
- return err;
- if (module_cache_spec.Exists())
- {
- local_file = module_cache_spec;
- return Error();
- }
- else
- return Error("unable to obtain valid module file");
- }
- }
- local_file = platform_file;
- return Error();
-}
-
-bool
-PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
-#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
- return ARMGetSupportedArchitectureAtIndex (idx, arch);
+ std::string remote_os_build;
+ m_remote_platform_sp->GetOSBuildString(remote_os_build);
+ if (local_os_build.compare(remote_os_build) == 0) {
+ // same OS version: the local file is good enough
+ local_file = platform_file;
+ return Error();
+ } else {
+ // try to find the file in the cache
+ std::string cache_path(GetLocalCacheDirectory());
+ std::string module_path(platform_file.GetPath());
+ cache_path.append(module_path);
+ FileSpec module_cache_spec(cache_path.c_str(), false);
+ if (module_cache_spec.Exists()) {
+ local_file = module_cache_spec;
+ return Error();
+ }
+ // bring in the remote module file
+ FileSpec module_cache_folder =
+ module_cache_spec.CopyByRemovingLastPathComponent();
+ // try to make the local directory first
+ Error err = FileSystem::MakeDirectory(module_cache_folder,
+ eFilePermissionsDirectoryDefault);
+ if (err.Fail())
+ return err;
+ err = GetFile(platform_file, module_cache_spec);
+ if (err.Fail())
+ return err;
+ if (module_cache_spec.Exists()) {
+ local_file = module_cache_spec;
+ return Error();
+ } else
+ return Error("unable to obtain valid module file");
+ }
+ }
+ local_file = platform_file;
+ return Error();
+}
+
+bool PlatformMacOSX::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+ return ARMGetSupportedArchitectureAtIndex(idx, arch);
#else
- return x86GetSupportedArchitectureAtIndex (idx, arch);
+ return x86GetSupportedArchitectureAtIndex(idx, arch);
#endif
}
-lldb_private::Error
-PlatformMacOSX::GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- Error error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
-
- if (module_sp)
- {
- if (module_spec.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64h)
- {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile == NULL)
- {
- // We didn't find an x86_64h slice, fall back to a x86_64 slice
- ModuleSpec module_spec_x86_64 (module_spec);
- module_spec_x86_64.GetArchitecture() = ArchSpec("x86_64-apple-macosx");
- lldb::ModuleSP x86_64_module_sp;
- lldb::ModuleSP old_x86_64_module_sp;
- bool did_create = false;
- Error x86_64_error = GetSharedModuleWithLocalCache(module_spec_x86_64, x86_64_module_sp, module_search_paths_ptr, &old_x86_64_module_sp, &did_create);
- if (x86_64_module_sp && x86_64_module_sp->GetObjectFile())
- {
- module_sp = x86_64_module_sp;
- if (old_module_sp_ptr)
- *old_module_sp_ptr = old_x86_64_module_sp;
- if (did_create_ptr)
- *did_create_ptr = did_create;
- return x86_64_error;
- }
- }
+lldb_private::Error PlatformMacOSX::GetSharedModule(
+ const lldb_private::ModuleSpec &module_spec, Process *process,
+ lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
+ Error error = GetSharedModuleWithLocalCache(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr);
+
+ if (module_sp) {
+ if (module_spec.GetArchitecture().GetCore() ==
+ ArchSpec::eCore_x86_64_x86_64h) {
+ ObjectFile *objfile = module_sp->GetObjectFile();
+ if (objfile == NULL) {
+ // We didn't find an x86_64h slice, fall back to a x86_64 slice
+ ModuleSpec module_spec_x86_64(module_spec);
+ module_spec_x86_64.GetArchitecture() = ArchSpec("x86_64-apple-macosx");
+ lldb::ModuleSP x86_64_module_sp;
+ lldb::ModuleSP old_x86_64_module_sp;
+ bool did_create = false;
+ Error x86_64_error = GetSharedModuleWithLocalCache(
+ module_spec_x86_64, x86_64_module_sp, module_search_paths_ptr,
+ &old_x86_64_module_sp, &did_create);
+ if (x86_64_module_sp && x86_64_module_sp->GetObjectFile()) {
+ module_sp = x86_64_module_sp;
+ if (old_module_sp_ptr)
+ *old_module_sp_ptr = old_x86_64_module_sp;
+ if (did_create_ptr)
+ *did_create_ptr = did_create;
+ return x86_64_error;
}
+ }
}
- return error;
+ }
+ return error;
}
-
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Tue Sep 6 15:57:50 2016
@@ -16,89 +16,76 @@
// Project includes
#include "PlatformDarwin.h"
-class PlatformMacOSX : public PlatformDarwin
-{
+class PlatformMacOSX : public PlatformDarwin {
public:
- PlatformMacOSX(bool is_host);
+ PlatformMacOSX(bool is_host);
- ~PlatformMacOSX() override;
+ ~PlatformMacOSX() override;
- //------------------------------------------------------------
- // Class functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic (bool is_host);
-
- static const char *
- GetDescriptionStatic(bool is_host);
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic (IsHost());
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic (IsHost());
- }
-
- lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetFile (const lldb_private::FileSpec& source,
- const lldb_private::FileSpec& destination) override
- {
- return PlatformDarwin::GetFile (source,destination);
- }
-
- lldb_private::Error
- GetFileWithUUID (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file) override;
-
- bool GetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch) override;
-
- lldb_private::ConstString GetSDKDirectory(lldb_private::Target &target) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::MacOSX);
- }
+ //------------------------------------------------------------
+ // Class functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic(bool is_host);
+
+ static const char *GetDescriptionStatic(bool is_host);
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic(IsHost());
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ const char *GetDescription() override {
+ return GetDescriptionStatic(IsHost());
+ }
+
+ lldb_private::Error GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetFile(const lldb_private::FileSpec &source,
+ const lldb_private::FileSpec &destination) override {
+ return PlatformDarwin::GetFile(source, destination);
+ }
+
+ lldb_private::Error
+ GetFileWithUUID(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ lldb_private::ConstString
+ GetSDKDirectory(lldb_private::Target &target) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::MacOSX);
+ }
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformMacOSX);
+ DISALLOW_COPY_AND_ASSIGN(PlatformMacOSX);
};
#endif // liblldb_PlatformMacOSX_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp Tue Sep 6 15:57:50 2016
@@ -36,38 +36,27 @@ using namespace lldb_private;
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformRemoteAppleTV::PlatformRemoteAppleTV () :
- PlatformDarwin (false), // This is a remote platform
- m_sdk_directory_infos(),
- m_device_support_directory(),
- m_device_support_directory_for_os_version (),
- m_build_update(),
- m_last_module_sdk_idx (UINT32_MAX),
- m_connected_module_sdk_idx (UINT32_MAX)
-{
-}
-
-PlatformRemoteAppleTV::SDKDirectoryInfo::SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir) :
- directory(sdk_dir),
- build(),
- version_major(0),
- version_minor(0),
- version_update(0),
- user_cached(false)
-{
- const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
- const char *pos = Args::StringToVersion (dirname_cstr,
- version_major,
- version_minor,
- version_update);
-
- if (pos && pos[0] == ' ' && pos[1] == '(')
- {
- const char *build_start = pos + 2;
- const char *end_paren = strchr (build_start, ')');
- if (end_paren && build_start < end_paren)
- build.SetCStringWithLength(build_start, end_paren - build_start);
- }
+PlatformRemoteAppleTV::PlatformRemoteAppleTV()
+ : PlatformDarwin(false), // This is a remote platform
+ m_sdk_directory_infos(), m_device_support_directory(),
+ m_device_support_directory_for_os_version(), m_build_update(),
+ m_last_module_sdk_idx(UINT32_MAX),
+ m_connected_module_sdk_idx(UINT32_MAX) {}
+
+PlatformRemoteAppleTV::SDKDirectoryInfo::SDKDirectoryInfo(
+ const lldb_private::FileSpec &sdk_dir)
+ : directory(sdk_dir), build(), version_major(0), version_minor(0),
+ version_update(0), user_cached(false) {
+ const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
+ const char *pos = Args::StringToVersion(dirname_cstr, version_major,
+ version_minor, version_update);
+
+ if (pos && pos[0] == ' ' && pos[1] == '(') {
+ const char *build_start = pos + 2;
+ const char *end_paren = strchr(build_start, ')');
+ if (end_paren && build_start < end_paren)
+ build.SetCStringWithLength(build_start, end_paren - build_start);
+ }
}
//------------------------------------------------------------------
@@ -78,924 +67,834 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformRemoteAppleTV::Initialize ()
-{
- PlatformDarwin::Initialize ();
+void PlatformRemoteAppleTV::Initialize() {
+ PlatformDarwin::Initialize();
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformRemoteAppleTV::GetPluginNameStatic(),
- PlatformRemoteAppleTV::GetDescriptionStatic(),
- PlatformRemoteAppleTV::CreateInstance);
- }
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(PlatformRemoteAppleTV::GetPluginNameStatic(),
+ PlatformRemoteAppleTV::GetDescriptionStatic(),
+ PlatformRemoteAppleTV::CreateInstance);
+ }
}
-void
-PlatformRemoteAppleTV::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformRemoteAppleTV::CreateInstance);
- }
+void PlatformRemoteAppleTV::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformRemoteAppleTV::CreateInstance);
}
+ }
- PlatformDarwin::Terminate ();
+ PlatformDarwin::Terminate();
}
-PlatformSP
-PlatformRemoteAppleTV::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
-
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+PlatformSP PlatformRemoteAppleTV::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- log->Printf ("PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
- bool create = force;
- if (!create && arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::arm:
- case llvm::Triple::aarch64:
- case llvm::Triple::thumb:
- {
- const llvm::Triple &triple = arch->GetTriple();
- llvm::Triple::VendorType vendor = triple.getVendor();
- switch (vendor)
- {
- case llvm::Triple::Apple:
- create = true;
- break;
+ log->Printf("PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})",
+ __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (!create && arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::aarch64:
+ case llvm::Triple::thumb: {
+ const llvm::Triple &triple = arch->GetTriple();
+ llvm::Triple::VendorType vendor = triple.getVendor();
+ switch (vendor) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
#if defined(__APPLE__)
- // Only accept "unknown" for the vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for the vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::TvOS: // This is the right triple value for Apple TV debugging
- break;
-
- default:
- create = false;
- break;
- }
- }
- }
- break;
+ default:
+ break;
+ }
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::TvOS: // This is the right triple value for Apple TV
+ // debugging
+ break;
+
default:
- break;
+ create = false;
+ break;
}
+ }
+ } break;
+ default:
+ break;
}
+ }
- if (create)
- {
- if (log)
- log->Printf ("PlatformRemoteAppleTV::%s() creating platform", __FUNCTION__);
+ if (create) {
+ if (log)
+ log->Printf("PlatformRemoteAppleTV::%s() creating platform",
+ __FUNCTION__);
- return lldb::PlatformSP(new PlatformRemoteAppleTV ());
- }
+ return lldb::PlatformSP(new PlatformRemoteAppleTV());
+ }
- if (log)
- log->Printf ("PlatformRemoteAppleTV::%s() aborting creation of platform", __FUNCTION__);
+ if (log)
+ log->Printf("PlatformRemoteAppleTV::%s() aborting creation of platform",
+ __FUNCTION__);
- return lldb::PlatformSP();
+ return lldb::PlatformSP();
}
-lldb_private::ConstString
-PlatformRemoteAppleTV::GetPluginNameStatic ()
-{
- static ConstString g_name("remote-tvos");
- return g_name;
+lldb_private::ConstString PlatformRemoteAppleTV::GetPluginNameStatic() {
+ static ConstString g_name("remote-tvos");
+ return g_name;
}
-const char *
-PlatformRemoteAppleTV::GetDescriptionStatic()
-{
- return "Remote Apple TV platform plug-in.";
+const char *PlatformRemoteAppleTV::GetDescriptionStatic() {
+ return "Remote Apple TV platform plug-in.";
}
-void
-PlatformRemoteAppleTV::GetStatus (Stream &strm)
-{
- Platform::GetStatus (strm);
- const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
- if (sdk_directory)
- strm.Printf (" SDK Path: \"%s\"\n", sdk_directory);
- else
- strm.PutCString (" SDK Path: error: unable to locate SDK\n");
-
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- strm.Printf (" SDK Roots: [%2u] \"%s\"\n",
- i,
- sdk_dir_info.directory.GetPath().c_str());
- }
+void PlatformRemoteAppleTV::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+ const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
+ if (sdk_directory)
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ else
+ strm.PutCString(" SDK Path: error: unable to locate SDK\n");
+
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ strm.Printf(" SDK Roots: [%2u] \"%s\"\n", i,
+ sdk_dir_info.directory.GetPath().c_str());
+ }
}
-Error
-PlatformRemoteAppleTV::ResolveExecutable (const ModuleSpec &ms,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- ModuleSpec resolved_module_spec(ms);
-
- // Resolve any executable within a bundle on MacOSX
- // TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid())
- {
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp,
- nullptr,
- nullptr,
- nullptr);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact ARM slice wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp,
- nullptr,
- nullptr,
- nullptr);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
+Error PlatformRemoteAppleTV::ResolveExecutable(
+ const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
- return error;
-}
+ ModuleSpec resolved_module_spec(ms);
-FileSpec::EnumerateDirectoryResult
-PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec)
-{
- ((PlatformRemoteAppleTV::SDKDirectoryInfoCollection *)baton)->push_back(PlatformRemoteAppleTV::SDKDirectoryInfo(file_spec));
- return FileSpec::eEnumerateDirectoryResultNext;
-}
-
-bool
-PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded()
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (m_sdk_directory_infos.empty())
- {
- const char *device_support_dir = GetDeviceSupportDirectory();
- if (log)
- {
- log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir);
- }
- if (device_support_dir)
- {
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = false;
-
- SDKDirectoryInfoCollection builtin_sdk_directory_infos;
- FileSpec::EnumerateDirectory (m_device_support_directory.c_str(),
- find_directories,
- find_files,
- find_other,
- GetContainedFilesIntoVectorOfStringsCallback,
- &builtin_sdk_directory_infos);
-
- // Only add SDK directories that have symbols in them, some SDKs only contain
- // developer disk images and no symbols, so they aren't useful to us.
- FileSpec sdk_symbols_symlink_fspec;
- for (const auto &sdk_directory_info : builtin_sdk_directory_infos)
- {
- sdk_symbols_symlink_fspec = sdk_directory_info.directory;
- sdk_symbols_symlink_fspec.AppendPathComponent("Symbols.Internal");
- if (sdk_symbols_symlink_fspec.Exists())
- {
- m_sdk_directory_infos.push_back(sdk_directory_info);
- if (log)
- {
- log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
- }
- }
- else
- {
- sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols");
- if (sdk_symbols_symlink_fspec.Exists())
- m_sdk_directory_infos.push_back(sdk_directory_info);
- if (log)
- {
- log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
- }
- }
- }
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one
+ // ourselves
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
- const uint32_t num_installed = m_sdk_directory_infos.size();
- FileSpec local_sdk_cache("~/Library/Developer/Xcode/tvOS DeviceSupport", true);
- if (!local_sdk_cache.Exists())
- {
- // Try looking for another possible name
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/Apple TVOS DeviceSupport", true);
- }
- if (!local_sdk_cache.Exists())
- {
- // Try looking for another possible name
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/AppleTVOS DeviceSupport", true);
- }
- if (!local_sdk_cache.Exists())
- {
- // Try looking for another possible name
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/AppleTV OS DeviceSupport", true);
- }
- if (!local_sdk_cache.Exists())
- {
- // Try looking for another possible name
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/Apple TV OS DeviceSupport", true);
- }
- if (local_sdk_cache.Exists())
- {
- if (log)
- {
- log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str());
- }
- char path[PATH_MAX];
- if (local_sdk_cache.GetPath(path, sizeof(path)))
- {
- FileSpec::EnumerateDirectory (path,
- find_directories,
- find_files,
- find_other,
- GetContainedFilesIntoVectorOfStringsCallback,
- &m_sdk_directory_infos);
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // First try for an exact match of major, minor and update
- for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
- {
- m_sdk_directory_infos[i].user_cached = true;
- if (log)
- {
- log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str());
- }
- }
- }
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ if (resolved_module_spec.GetArchitecture().IsValid() ||
+ resolved_module_spec.GetUUID().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ nullptr, nullptr, nullptr);
+
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ nullptr, nullptr, nullptr);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' does not exist",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+
+ return error;
+}
+
+FileSpec::EnumerateDirectoryResult
+PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ ((PlatformRemoteAppleTV::SDKDirectoryInfoCollection *)baton)
+ ->push_back(PlatformRemoteAppleTV::SDKDirectoryInfo(file_spec));
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+bool PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded() {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (m_sdk_directory_infos.empty()) {
+ const char *device_support_dir = GetDeviceSupportDirectory();
+ if (log) {
+ log->Printf("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded Got "
+ "DeviceSupport directory %s",
+ device_support_dir);
+ }
+ if (device_support_dir) {
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = false;
+
+ SDKDirectoryInfoCollection builtin_sdk_directory_infos;
+ FileSpec::EnumerateDirectory(m_device_support_directory.c_str(),
+ find_directories, find_files, find_other,
+ GetContainedFilesIntoVectorOfStringsCallback,
+ &builtin_sdk_directory_infos);
+
+ // Only add SDK directories that have symbols in them, some SDKs only
+ // contain
+ // developer disk images and no symbols, so they aren't useful to us.
+ FileSpec sdk_symbols_symlink_fspec;
+ for (const auto &sdk_directory_info : builtin_sdk_directory_infos) {
+ sdk_symbols_symlink_fspec = sdk_directory_info.directory;
+ sdk_symbols_symlink_fspec.AppendPathComponent("Symbols.Internal");
+ if (sdk_symbols_symlink_fspec.Exists()) {
+ m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log) {
+ log->Printf("PlatformRemoteAppleTV::"
+ "UpdateSDKDirectoryInfosIfNeeded added builtin SDK "
+ "directory %s",
+ sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
+ } else {
+ sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols");
+ if (sdk_symbols_symlink_fspec.Exists())
+ m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log) {
+ log->Printf("PlatformRemoteAppleTV::"
+ "UpdateSDKDirectoryInfosIfNeeded added builtin SDK "
+ "directory %s",
+ sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
+ }
+ }
+
+ const uint32_t num_installed = m_sdk_directory_infos.size();
+ FileSpec local_sdk_cache("~/Library/Developer/Xcode/tvOS DeviceSupport",
+ true);
+ if (!local_sdk_cache.Exists()) {
+ // Try looking for another possible name
+ local_sdk_cache = FileSpec(
+ "~/Library/Developer/Xcode/Apple TVOS DeviceSupport", true);
+ }
+ if (!local_sdk_cache.Exists()) {
+ // Try looking for another possible name
+ local_sdk_cache =
+ FileSpec("~/Library/Developer/Xcode/AppleTVOS DeviceSupport", true);
+ }
+ if (!local_sdk_cache.Exists()) {
+ // Try looking for another possible name
+ local_sdk_cache = FileSpec(
+ "~/Library/Developer/Xcode/AppleTV OS DeviceSupport", true);
+ }
+ if (!local_sdk_cache.Exists()) {
+ // Try looking for another possible name
+ local_sdk_cache = FileSpec(
+ "~/Library/Developer/Xcode/Apple TV OS DeviceSupport", true);
+ }
+ if (local_sdk_cache.Exists()) {
+ if (log) {
+ log->Printf("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded "
+ "searching %s for additional SDKs",
+ local_sdk_cache.GetPath().c_str());
+ }
+ char path[PATH_MAX];
+ if (local_sdk_cache.GetPath(path, sizeof(path))) {
+ FileSpec::EnumerateDirectory(
+ path, find_directories, find_files, find_other,
+ GetContainedFilesIntoVectorOfStringsCallback,
+ &m_sdk_directory_infos);
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // First try for an exact match of major, minor and update
+ for (uint32_t i = num_installed; i < num_sdk_infos; ++i) {
+ m_sdk_directory_infos[i].user_cached = true;
+ if (log) {
+ log->Printf("PlatformRemoteAppleTV::"
+ "UpdateSDKDirectoryInfosIfNeeded user SDK directory "
+ "%s",
+ m_sdk_directory_infos[i].directory.GetPath().c_str());
}
+ }
}
+ }
}
- return !m_sdk_directory_infos.empty();
+ }
+ return !m_sdk_directory_infos.empty();
}
const PlatformRemoteAppleTV::SDKDirectoryInfo *
-PlatformRemoteAppleTV::GetSDKDirectoryForCurrentOSVersion ()
-{
- uint32_t i;
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+PlatformRemoteAppleTV::GetSDKDirectoryForCurrentOSVersion() {
+ uint32_t i;
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // Check to see if the user specified a build string. If they did, then
- // be sure to match it.
- std::vector<bool> check_sdk_info(num_sdk_infos, true);
- ConstString build(m_sdk_build);
- if (build)
- {
- for (i=0; i<num_sdk_infos; ++i)
- check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
- }
-
- // If we are connected we can find the version of the OS the platform
- // us running on and select the right SDK
- uint32_t major, minor, update;
- if (GetOSVersion(major, minor, update))
- {
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- // First try for an exact match of major, minor and update
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major &&
- m_sdk_directory_infos[i].version_minor == minor &&
- m_sdk_directory_infos[i].version_update == update)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- // First try for an exact match of major and minor
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major &&
- m_sdk_directory_infos[i].version_minor == minor)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- // Lastly try to match of major version only..
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- }
- }
- else if (build)
- {
- // No version, just a build number, search for the first one that matches
- for (i=0; i<num_sdk_infos; ++i)
- if (check_sdk_info[i])
- return &m_sdk_directory_infos[i];
- }
+ // Check to see if the user specified a build string. If they did, then
+ // be sure to match it.
+ std::vector<bool> check_sdk_info(num_sdk_infos, true);
+ ConstString build(m_sdk_build);
+ if (build) {
+ for (i = 0; i < num_sdk_infos; ++i)
+ check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
}
- return nullptr;
-}
-const PlatformRemoteAppleTV::SDKDirectoryInfo *
-PlatformRemoteAppleTV::GetSDKDirectoryForLatestOSVersion ()
-{
- const PlatformRemoteAppleTV::SDKDirectoryInfo *result = nullptr;
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // If we are connected we can find the version of the OS the platform
+ // us running on and select the right SDK
+ uint32_t major, minor, update;
+ if (GetOSVersion(major, minor, update)) {
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
// First try for an exact match of major, minor and update
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- if (sdk_dir_info.version_major != UINT32_MAX)
- {
- if (result == nullptr || sdk_dir_info.version_major > result->version_major)
- {
- result = &sdk_dir_info;
- }
- else if (sdk_dir_info.version_major == result->version_major)
- {
- if (sdk_dir_info.version_minor > result->version_minor)
- {
- result = &sdk_dir_info;
- }
- else if (sdk_dir_info.version_minor == result->version_minor)
- {
- if (sdk_dir_info.version_update > result->version_update)
- {
- result = &sdk_dir_info;
- }
- }
- }
- }
- }
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major &&
+ m_sdk_directory_infos[i].version_minor == minor &&
+ m_sdk_directory_infos[i].version_update == update) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ // First try for an exact match of major and minor
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major &&
+ m_sdk_directory_infos[i].version_minor == minor) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ // Lastly try to match of major version only..
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ }
+ } else if (build) {
+ // No version, just a build number, search for the first one that matches
+ for (i = 0; i < num_sdk_infos; ++i)
+ if (check_sdk_info[i])
+ return &m_sdk_directory_infos[i];
}
- return result;
+ }
+ return nullptr;
}
-const char *
-PlatformRemoteAppleTV::GetDeviceSupportDirectory()
-{
- if (m_device_support_directory.empty())
- {
- const char *device_support_dir = GetDeveloperDirectory();
- if (device_support_dir)
- {
- m_device_support_directory.assign (device_support_dir);
- m_device_support_directory.append ("/Platforms/AppleTVOS.platform/DeviceSupport");
- }
- else
- {
- // 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_device_support_directory.assign (1, '\0');
- }
- }
- // We should have put a single NULL character into m_device_support_directory
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory.empty() == false);
- if (m_device_support_directory[0])
- return m_device_support_directory.c_str();
- return nullptr;
-}
-
-const char *
-PlatformRemoteAppleTV::GetDeviceSupportDirectoryForOSVersion()
-{
- if (m_sdk_sysroot)
- return m_sdk_sysroot.GetCString();
-
- if (m_device_support_directory_for_os_version.empty())
- {
- const PlatformRemoteAppleTV::SDKDirectoryInfo *sdk_dir_info = GetSDKDirectoryForCurrentOSVersion ();
- if (sdk_dir_info == nullptr)
- sdk_dir_info = GetSDKDirectoryForLatestOSVersion ();
- if (sdk_dir_info)
- {
- char path[PATH_MAX];
- if (sdk_dir_info->directory.GetPath(path, sizeof(path)))
- {
- m_device_support_directory_for_os_version = path;
- return m_device_support_directory_for_os_version.c_str();
- }
- }
- else
- {
- // 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_device_support_directory_for_os_version.assign (1, '\0');
- }
- }
- // We should have put a single NULL character into m_device_support_directory_for_os_version
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory_for_os_version.empty() == false);
- if (m_device_support_directory_for_os_version[0])
+const PlatformRemoteAppleTV::SDKDirectoryInfo *
+PlatformRemoteAppleTV::GetSDKDirectoryForLatestOSVersion() {
+ const PlatformRemoteAppleTV::SDKDirectoryInfo *result = nullptr;
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // First try for an exact match of major, minor and update
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (sdk_dir_info.version_major != UINT32_MAX) {
+ if (result == nullptr ||
+ sdk_dir_info.version_major > result->version_major) {
+ result = &sdk_dir_info;
+ } else if (sdk_dir_info.version_major == result->version_major) {
+ if (sdk_dir_info.version_minor > result->version_minor) {
+ result = &sdk_dir_info;
+ } else if (sdk_dir_info.version_minor == result->version_minor) {
+ if (sdk_dir_info.version_update > result->version_update) {
+ result = &sdk_dir_info;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+const char *PlatformRemoteAppleTV::GetDeviceSupportDirectory() {
+ if (m_device_support_directory.empty()) {
+ const char *device_support_dir = GetDeveloperDirectory();
+ if (device_support_dir) {
+ m_device_support_directory.assign(device_support_dir);
+ m_device_support_directory.append(
+ "/Platforms/AppleTVOS.platform/DeviceSupport");
+ } else {
+ // 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_device_support_directory.assign(1, '\0');
+ }
+ }
+ // We should have put a single NULL character into m_device_support_directory
+ // or it should have a valid path if the code gets here
+ assert(m_device_support_directory.empty() == false);
+ if (m_device_support_directory[0])
+ return m_device_support_directory.c_str();
+ return nullptr;
+}
+
+const char *PlatformRemoteAppleTV::GetDeviceSupportDirectoryForOSVersion() {
+ if (m_sdk_sysroot)
+ return m_sdk_sysroot.GetCString();
+
+ if (m_device_support_directory_for_os_version.empty()) {
+ const PlatformRemoteAppleTV::SDKDirectoryInfo *sdk_dir_info =
+ GetSDKDirectoryForCurrentOSVersion();
+ if (sdk_dir_info == nullptr)
+ sdk_dir_info = GetSDKDirectoryForLatestOSVersion();
+ if (sdk_dir_info) {
+ char path[PATH_MAX];
+ if (sdk_dir_info->directory.GetPath(path, sizeof(path))) {
+ m_device_support_directory_for_os_version = path;
return m_device_support_directory_for_os_version.c_str();
- return nullptr;
+ }
+ } else {
+ // 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_device_support_directory_for_os_version.assign(1, '\0');
+ }
+ }
+ // We should have put a single NULL character into
+ // m_device_support_directory_for_os_version
+ // or it should have a valid path if the code gets here
+ assert(m_device_support_directory_for_os_version.empty() == false);
+ if (m_device_support_directory_for_os_version[0])
+ return m_device_support_directory_for_os_version.c_str();
+ return nullptr;
}
uint32_t
-PlatformRemoteAppleTV::FindFileInAllSDKs (const char *platform_file_path,
- FileSpecList &file_list)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
- if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- lldb_private::FileSpec local_file;
- // First try for an exact match of major, minor and update
- for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path,
- sdk_idx,
- local_file))
- {
- file_list.Append(local_file);
- }
- }
- }
- return file_list.GetSize();
-}
-
-bool
-PlatformRemoteAppleTV::GetFileInSDK (const char *platform_file_path,
- uint32_t sdk_idx,
- lldb_private::FileSpec &local_file)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (sdk_idx < m_sdk_directory_infos.size())
- {
- std::string sdkroot_path = m_sdk_directory_infos[sdk_idx].directory.GetPath();
- if (!sdkroot_path.empty() && platform_file_path && platform_file_path[0])
- {
- // We may need to interpose "/Symbols/" or "/Symbols.Internal/" between the
- // SDK root directory and the file path.
-
- const char *paths_to_try[] = { "Symbols", "", "Symbols.Internal", nullptr };
- for (size_t i = 0; paths_to_try[i] != nullptr; i++)
- {
- local_file.SetFile (sdkroot_path.c_str(), false);
- if (paths_to_try[i][0] != '\0')
- local_file.AppendPathComponent (paths_to_try[i]);
- local_file.AppendPathComponent (platform_file_path);
- local_file.ResolvePath();
- if (local_file.Exists())
- {
- if (log)
- log->Printf ("Found a copy of %s in the SDK dir %s/%s", platform_file_path,
- sdkroot_path.c_str(),
- paths_to_try[i]);
- return true;
- }
- local_file.Clear();
- }
+PlatformRemoteAppleTV::FindFileInAllSDKs(const char *platform_file_path,
+ FileSpecList &file_list) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+ LIBLLDB_LOG_VERBOSE);
+ if (platform_file_path && platform_file_path[0] &&
+ UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ lldb_private::FileSpec local_file;
+ // First try for an exact match of major, minor and update
+ for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) {
+ file_list.Append(local_file);
+ }
+ }
+ }
+ return file_list.GetSize();
+}
+
+bool PlatformRemoteAppleTV::GetFileInSDK(const char *platform_file_path,
+ uint32_t sdk_idx,
+ lldb_private::FileSpec &local_file) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (sdk_idx < m_sdk_directory_infos.size()) {
+ std::string sdkroot_path =
+ m_sdk_directory_infos[sdk_idx].directory.GetPath();
+ if (!sdkroot_path.empty() && platform_file_path && platform_file_path[0]) {
+ // We may need to interpose "/Symbols/" or "/Symbols.Internal/" between
+ // the
+ // SDK root directory and the file path.
+
+ const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr};
+ for (size_t i = 0; paths_to_try[i] != nullptr; i++) {
+ local_file.SetFile(sdkroot_path.c_str(), false);
+ if (paths_to_try[i][0] != '\0')
+ local_file.AppendPathComponent(paths_to_try[i]);
+ local_file.AppendPathComponent(platform_file_path);
+ local_file.ResolvePath();
+ if (local_file.Exists()) {
+ if (log)
+ log->Printf("Found a copy of %s in the SDK dir %s/%s",
+ platform_file_path, sdkroot_path.c_str(),
+ paths_to_try[i]);
+ return true;
+ }
+ local_file.Clear();
+ }
+ }
+ }
+ return false;
+}
+
+Error PlatformRemoteAppleTV::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ Error error;
+ char platform_file_path[PATH_MAX];
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
+ char resolved_path[PATH_MAX];
+
+ const char *os_version_dir = GetDeviceSupportDirectoryForOSVersion();
+ if (os_version_dir) {
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir,
+ platform_file_path);
+
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf("Found a copy of %s in the DeviceSupport dir %s",
+ platform_file_path, os_version_dir);
}
- }
- return false;
-}
+ return error;
+ }
-Error
-PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- Error error;
- char platform_file_path[PATH_MAX];
- if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
- {
- char resolved_path[PATH_MAX];
-
- const char * os_version_dir = GetDeviceSupportDirectoryForOSVersion();
- if (os_version_dir)
- {
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir);
- }
- return error;
- }
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols.Internal/%s",
+ os_version_dir, platform_file_path);
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/Symbols.Internal/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir);
- }
- return error;
- }
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/Symbols/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir);
- }
- return error;
- }
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf(
+ "Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal",
+ platform_file_path, os_version_dir);
}
- local_file = platform_file;
- if (local_file.Exists())
- return error;
-
- error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
- platform_file_path,
- GetPluginName().GetCString());
- }
- else
- {
- error.SetErrorString ("invalid platform file argument");
+ return error;
+ }
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s",
+ os_version_dir, platform_file_path);
+
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf("Found a copy of %s in the DeviceSupport dir %s/Symbols",
+ platform_file_path, os_version_dir);
+ }
+ return error;
+ }
}
- return error;
-}
+ local_file = platform_file;
+ if (local_file.Exists())
+ return error;
+
+ error.SetErrorStringWithFormat(
+ "unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path, GetPluginName().GetCString());
+ } else {
+ error.SetErrorString("invalid platform file argument");
+ }
+ return error;
+}
+
+Error PlatformRemoteAppleTV::GetSharedModule(
+ const ModuleSpec &module_spec, lldb_private::Process *process,
+ ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
+ // For Apple TV, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+ LIBLLDB_LOG_VERBOSE);
-Error
-PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec,
- lldb_private::Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- // For Apple TV, the SDK files are all cached locally on the host
- // system. So first we ask for the file in the cached SDK,
- // then we attempt to get a shared module for the right architecture
- // with the right UUID.
- const FileSpec &platform_file = module_spec.GetFileSpec();
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
-
- Error error;
- char platform_file_path[PATH_MAX];
-
- if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
- {
- ModuleSpec platform_module_spec(module_spec);
+ Error error;
+ char platform_file_path[PATH_MAX];
- UpdateSDKDirectoryInfosIfNeeded();
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
+ ModuleSpec platform_module_spec(module_spec);
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ UpdateSDKDirectoryInfosIfNeeded();
- // If we are connected we migth be able to correctly deduce the SDK directory
- // using the OS build.
- const uint32_t connected_sdk_idx = GetConnectedSDKIndex ();
- if (connected_sdk_idx < num_sdk_infos)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable(platform_module_spec,
- module_sp,
- nullptr);
- if (module_sp)
- {
- m_last_module_sdk_idx = connected_sdk_idx;
- error.Clear();
- return error;
- }
- }
- }
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // Try the last SDK index if it is set as most files from an SDK
- // will tend to be valid in that same SDK.
- if (m_last_module_sdk_idx < num_sdk_infos)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable(platform_module_spec,
- module_sp,
- nullptr);
- if (module_sp)
- {
- error.Clear();
- return error;
- }
- }
- }
-
- // First try for an exact match of major, minor and update
- for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
- {
- if (m_last_module_sdk_idx == sdk_idx)
- {
- // Skip the last module SDK index if we already searched
- // it above
- continue;
- }
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec()))
- {
- //printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
-
- error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
- if (module_sp)
- {
- // Remember the index of the last SDK that we found a file
- // in in case the wrong SDK was selected.
- m_last_module_sdk_idx = sdk_idx;
- error.Clear();
- return error;
- }
- }
- }
- }
- // Not the module we are looking for... Nothing to see here...
- module_sp.reset();
+ // If we are connected we migth be able to correctly deduce the SDK
+ // directory
+ // using the OS build.
+ const uint32_t connected_sdk_idx = GetConnectedSDKIndex();
+ if (connected_sdk_idx < num_sdk_infos) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[connected_sdk_idx]
+ .directory.GetPath()
+ .c_str());
+ }
+ if (GetFileInSDK(platform_file_path, connected_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
+ if (module_sp) {
+ m_last_module_sdk_idx = connected_sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // Try the last SDK index if it is set as most files from an SDK
+ // will tend to be valid in that same SDK.
+ if (m_last_module_sdk_idx < num_sdk_infos) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[m_last_module_sdk_idx]
+ .directory.GetPath()
+ .c_str());
+ }
+ if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
+ if (module_sp) {
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // First try for an exact match of major, minor and update
+ for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
+ if (m_last_module_sdk_idx == sdk_idx) {
+ // Skip the last module SDK index if we already searched
+ // it above
+ continue;
+ }
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
+
+ error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
+ if (module_sp) {
+ // Remember the index of the last SDK that we found a file
+ // in in case the wrong SDK was selected.
+ m_last_module_sdk_idx = sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+ }
+ // Not the module we are looking for... Nothing to see here...
+ module_sp.reset();
+
+ // This may not be an SDK-related module. Try whether we can bring in the
+ // thing to our local cache.
+ error = GetSharedModuleWithLocalCache(module_spec, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ if (error.Success())
+ return error;
- // This may not be an SDK-related module. Try whether we can bring in the thing to our local cache.
- error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
- if (error.Success())
- return error;
+ // See if the file is present in any of the module_search_paths_ptr
+ // directories.
+ if (!module_sp && module_search_paths_ptr && platform_file) {
+ // create a vector of all the file / directory names in platform_file
+ // e.g. this might be
+ // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ //
+ // We'll need to look in the module_search_paths_ptr directories for
+ // both "UIFoundation" and "UIFoundation.framework" -- most likely the
+ // latter will be the one we find there.
+
+ FileSpec platform_pull_apart(platform_file);
+ std::vector<std::string> path_parts;
+ ConstString unix_root_dir("/");
+ while (true) {
+ ConstString part = platform_pull_apart.GetLastPathComponent();
+ platform_pull_apart.RemoveLastPathComponent();
+ if (part.IsEmpty() || part == unix_root_dir)
+ break;
+ path_parts.push_back(part.AsCString());
+ }
+ const size_t path_parts_size = path_parts.size();
- // See if the file is present in any of the module_search_paths_ptr directories.
- if (!module_sp && module_search_paths_ptr && platform_file)
- {
- // create a vector of all the file / directory names in platform_file
- // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i) {
+ // Create a new FileSpec with this module_search_paths_ptr
+ // plus just the filename ("UIFoundation"), then the parent
+ // dir plus filename ("UIFoundation.framework/UIFoundation")
+ // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
+
+ for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
+ FileSpec path_to_try(module_search_paths_ptr->GetFileSpecAtIndex(i));
+
+ // Add the components backwards. For
+ // .../PrivateFrameworks/UIFoundation.framework/UIFoundation
+ // path_parts is
+ // [0] UIFoundation
+ // [1] UIFoundation.framework
+ // [2] PrivateFrameworks
//
- // We'll need to look in the module_search_paths_ptr directories for
- // both "UIFoundation" and "UIFoundation.framework" -- most likely the
- // latter will be the one we find there.
-
- FileSpec platform_pull_apart (platform_file);
- std::vector<std::string> path_parts;
- ConstString unix_root_dir("/");
- while (true)
- {
- ConstString part = platform_pull_apart.GetLastPathComponent();
- platform_pull_apart.RemoveLastPathComponent();
- if (part.IsEmpty() || part == unix_root_dir)
- break;
- path_parts.push_back (part.AsCString());
- }
- const size_t path_parts_size = path_parts.size();
-
- size_t num_module_search_paths = module_search_paths_ptr->GetSize();
- for (size_t i = 0; i < num_module_search_paths; ++i)
- {
- // Create a new FileSpec with this module_search_paths_ptr
- // plus just the filename ("UIFoundation"), then the parent
- // dir plus filename ("UIFoundation.framework/UIFoundation")
- // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
-
- for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j)
- {
- FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i));
-
- // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation
- // path_parts is
- // [0] UIFoundation
- // [1] UIFoundation.framework
- // [2] PrivateFrameworks
- //
- // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka
- // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path.
-
- for (int k = j; k >= 0; --k)
- {
- path_to_try.AppendPathComponent (path_parts[k]);
- }
-
- if (path_to_try.Exists())
- {
- ModuleSpec new_module_spec (module_spec);
- new_module_spec.GetFileSpec() = path_to_try;
- Error new_error (Platform::GetSharedModule (new_module_spec,
- process,
- module_sp,
- NULL,
- old_module_sp_ptr,
- did_create_ptr));
-
- if (module_sp)
- {
- module_sp->SetPlatformFileSpec (path_to_try);
- return new_error;
- }
- }
- }
- }
+ // and if 'j' is 2, we want to append path_parts[1] and then
+ // path_parts[0], aka
+ // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr
+ // path.
+
+ for (int k = j; k >= 0; --k) {
+ path_to_try.AppendPathComponent(path_parts[k]);
+ }
+
+ if (path_to_try.Exists()) {
+ ModuleSpec new_module_spec(module_spec);
+ new_module_spec.GetFileSpec() = path_to_try;
+ Error new_error(Platform::GetSharedModule(
+ new_module_spec, process, module_sp, NULL, old_module_sp_ptr,
+ did_create_ptr));
+
+ if (module_sp) {
+ module_sp->SetPlatformFileSpec(path_to_try);
+ return new_error;
+ }
+ }
+ }
+ }
+ }
+
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr, always_create);
+
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
+
+ return error;
+}
+
+bool PlatformRemoteAppleTV::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ ArchSpec system_arch(GetSystemArchitecture());
+
+ const ArchSpec::Core system_core = system_arch.GetCore();
+ switch (system_core) {
+ default:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("arm64-apple-tvos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7s-apple-tvos");
+ return true;
+ case 2:
+ arch.SetTriple("armv7-apple-tvos");
+ return true;
+ case 3:
+ arch.SetTriple("thumbv7s-apple-tvos");
+ return true;
+ case 4:
+ arch.SetTriple("thumbv7-apple-tvos");
+ return true;
+ default:
+ break;
}
+ break;
- const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr,
- always_create);
-
- if (module_sp)
- module_sp->SetPlatformFileSpec(platform_file);
-
- return error;
-}
-
-bool
-PlatformRemoteAppleTV::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- ArchSpec system_arch (GetSystemArchitecture());
-
- const ArchSpec::Core system_core = system_arch.GetCore();
- switch (system_core)
- {
+ case ArchSpec::eCore_arm_arm64:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("arm64-apple-tvos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7s-apple-tvos");
+ return true;
+ case 2:
+ arch.SetTriple("armv7-apple-tvos");
+ return true;
+ case 3:
+ arch.SetTriple("thumbv7s-apple-tvos");
+ return true;
+ case 4:
+ arch.SetTriple("thumbv7-apple-tvos");
+ return true;
default:
- switch (idx)
- {
- case 0: arch.SetTriple ("arm64-apple-tvos"); return true;
- case 1: arch.SetTriple ("armv7s-apple-tvos"); return true;
- case 2: arch.SetTriple ("armv7-apple-tvos"); return true;
- case 3: arch.SetTriple ("thumbv7s-apple-tvos"); return true;
- case 4: arch.SetTriple ("thumbv7-apple-tvos"); return true;
- default: break;
- }
- break;
-
- case ArchSpec::eCore_arm_arm64:
- switch (idx)
- {
- case 0: arch.SetTriple ("arm64-apple-tvos"); return true;
- case 1: arch.SetTriple ("armv7s-apple-tvos"); return true;
- case 2: arch.SetTriple ("armv7-apple-tvos"); return true;
- case 3: arch.SetTriple ("thumbv7s-apple-tvos"); return true;
- case 4: arch.SetTriple ("thumbv7-apple-tvos"); return true;
- default: break;
- }
- break;
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7s:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7s-apple-tvos"); return true;
- case 1: arch.SetTriple ("armv7-apple-tvos"); return true;
- case 2: arch.SetTriple ("thumbv7s-apple-tvos"); return true;
- case 3: arch.SetTriple ("thumbv7-apple-tvos"); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7s:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7s-apple-tvos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7-apple-tvos");
+ return true;
+ case 2:
+ arch.SetTriple("thumbv7s-apple-tvos");
+ return true;
+ case 3:
+ arch.SetTriple("thumbv7-apple-tvos");
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7-apple-tvos"); return true;
- case 1: arch.SetTriple ("thumbv7-apple-tvos"); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7-apple-tvos");
+ return true;
+ case 1:
+ arch.SetTriple("thumbv7-apple-tvos");
+ return true;
+ default:
+ break;
}
- arch.Clear();
- return false;
+ break;
+ }
+ arch.Clear();
+ return false;
}
-uint32_t
-PlatformRemoteAppleTV::GetConnectedSDKIndex ()
-{
- if (IsConnected())
- {
- if (m_connected_module_sdk_idx == UINT32_MAX)
- {
- std::string build;
- if (GetRemoteOSBuildString(build))
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""), build.c_str()))
- {
- m_connected_module_sdk_idx = i;
- }
- }
- }
- }
- }
- else
- {
- m_connected_module_sdk_idx = UINT32_MAX;
- }
- return m_connected_module_sdk_idx;
+uint32_t PlatformRemoteAppleTV::GetConnectedSDKIndex() {
+ if (IsConnected()) {
+ if (m_connected_module_sdk_idx == UINT32_MAX) {
+ std::string build;
+ if (GetRemoteOSBuildString(build)) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""),
+ build.c_str())) {
+ m_connected_module_sdk_idx = i;
+ }
+ }
+ }
+ }
+ } else {
+ m_connected_module_sdk_idx = UINT32_MAX;
+ }
+ return m_connected_module_sdk_idx;
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h Tue Sep 6 15:57:50 2016
@@ -20,146 +20,117 @@
#include "PlatformDarwin.h"
-class PlatformRemoteAppleTV : public PlatformDarwin
-{
+class PlatformRemoteAppleTV : public PlatformDarwin {
public:
- PlatformRemoteAppleTV();
+ PlatformRemoteAppleTV();
- ~PlatformRemoteAppleTV() override = default;
+ ~PlatformRemoteAppleTV() override = default;
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- virtual lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneOS);
- }
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override { return GetDescriptionStatic(); }
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ virtual lldb_private::Error
+ GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::iPhoneOS);
+ }
protected:
- struct SDKDirectoryInfo
- {
- SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir_spec);
- lldb_private::FileSpec directory;
- lldb_private::ConstString build;
- uint32_t version_major;
- uint32_t version_minor;
- uint32_t version_update;
- bool user_cached;
- };
- typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
- SDKDirectoryInfoCollection m_sdk_directory_infos;
- std::string m_device_support_directory;
- std::string m_device_support_directory_for_os_version;
- std::string m_build_update;
- uint32_t m_last_module_sdk_idx;
- uint32_t m_connected_module_sdk_idx;
-
- bool
- UpdateSDKDirectoryInfosIfNeeded();
-
- const char *
- GetDeviceSupportDirectory();
-
- const char *
- GetDeviceSupportDirectoryForOSVersion();
-
- const SDKDirectoryInfo *
- GetSDKDirectoryForLatestOSVersion ();
-
- const SDKDirectoryInfo *
- GetSDKDirectoryForCurrentOSVersion ();
-
- static lldb_private::FileSpec::EnumerateDirectoryResult
- GetContainedFilesIntoVectorOfStringsCallback (void *baton,
- lldb_private::FileSpec::FileType file_type,
- const lldb_private::FileSpec &file_spec);
-
- uint32_t
- FindFileInAllSDKs (const char *platform_file_path,
- lldb_private::FileSpecList &file_list);
-
- bool
- GetFileInSDK (const char *platform_file_path,
- uint32_t sdk_idx,
- lldb_private::FileSpec &local_file);
-
- uint32_t
- FindFileInAllSDKs (const lldb_private::FileSpec &platform_file,
- lldb_private::FileSpecList &file_list);
+ struct SDKDirectoryInfo {
+ SDKDirectoryInfo(const lldb_private::FileSpec &sdk_dir_spec);
+ lldb_private::FileSpec directory;
+ lldb_private::ConstString build;
+ uint32_t version_major;
+ uint32_t version_minor;
+ uint32_t version_update;
+ bool user_cached;
+ };
+ typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
+ SDKDirectoryInfoCollection m_sdk_directory_infos;
+ std::string m_device_support_directory;
+ std::string m_device_support_directory_for_os_version;
+ std::string m_build_update;
+ uint32_t m_last_module_sdk_idx;
+ uint32_t m_connected_module_sdk_idx;
+
+ bool UpdateSDKDirectoryInfosIfNeeded();
+
+ const char *GetDeviceSupportDirectory();
+
+ const char *GetDeviceSupportDirectoryForOSVersion();
+
+ const SDKDirectoryInfo *GetSDKDirectoryForLatestOSVersion();
+
+ const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion();
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ GetContainedFilesIntoVectorOfStringsCallback(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec);
+
+ uint32_t FindFileInAllSDKs(const char *platform_file_path,
+ lldb_private::FileSpecList &file_list);
- uint32_t
- GetConnectedSDKIndex ();
+ bool GetFileInSDK(const char *platform_file_path, uint32_t sdk_idx,
+ lldb_private::FileSpec &local_file);
+
+ uint32_t FindFileInAllSDKs(const lldb_private::FileSpec &platform_file,
+ lldb_private::FileSpecList &file_list);
+
+ uint32_t GetConnectedSDKIndex();
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformRemoteAppleTV);
+ DISALLOW_COPY_AND_ASSIGN(PlatformRemoteAppleTV);
};
#endif // liblldb_PlatformRemoteAppleTV_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp Tue Sep 6 15:57:50 2016
@@ -36,38 +36,27 @@ using namespace lldb_private;
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformRemoteAppleWatch::PlatformRemoteAppleWatch () :
- PlatformDarwin (false), // This is a remote platform
- m_sdk_directory_infos(),
- m_device_support_directory(),
- m_device_support_directory_for_os_version (),
- m_build_update(),
- m_last_module_sdk_idx (UINT32_MAX),
- m_connected_module_sdk_idx (UINT32_MAX)
-{
-}
-
-PlatformRemoteAppleWatch::SDKDirectoryInfo::SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir) :
- directory(sdk_dir),
- build(),
- version_major(0),
- version_minor(0),
- version_update(0),
- user_cached(false)
-{
- const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
- const char *pos = Args::StringToVersion (dirname_cstr,
- version_major,
- version_minor,
- version_update);
-
- if (pos && pos[0] == ' ' && pos[1] == '(')
- {
- const char *build_start = pos + 2;
- const char *end_paren = strchr (build_start, ')');
- if (end_paren && build_start < end_paren)
- build.SetCStringWithLength(build_start, end_paren - build_start);
- }
+PlatformRemoteAppleWatch::PlatformRemoteAppleWatch()
+ : PlatformDarwin(false), // This is a remote platform
+ m_sdk_directory_infos(), m_device_support_directory(),
+ m_device_support_directory_for_os_version(), m_build_update(),
+ m_last_module_sdk_idx(UINT32_MAX),
+ m_connected_module_sdk_idx(UINT32_MAX) {}
+
+PlatformRemoteAppleWatch::SDKDirectoryInfo::SDKDirectoryInfo(
+ const lldb_private::FileSpec &sdk_dir)
+ : directory(sdk_dir), build(), version_major(0), version_minor(0),
+ version_update(0), user_cached(false) {
+ const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
+ const char *pos = Args::StringToVersion(dirname_cstr, version_major,
+ version_minor, version_update);
+
+ if (pos && pos[0] == ' ' && pos[1] == '(') {
+ const char *build_start = pos + 2;
+ const char *end_paren = strchr(build_start, ')');
+ if (end_paren && build_start < end_paren)
+ build.SetCStringWithLength(build_start, end_paren - build_start);
+ }
}
//------------------------------------------------------------------
@@ -78,957 +67,898 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformRemoteAppleWatch::Initialize ()
-{
- PlatformDarwin::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformRemoteAppleWatch::GetPluginNameStatic(),
- PlatformRemoteAppleWatch::GetDescriptionStatic(),
- PlatformRemoteAppleWatch::CreateInstance);
- }
-}
-
-void
-PlatformRemoteAppleWatch::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformRemoteAppleWatch::CreateInstance);
- }
- }
-
- PlatformDarwin::Terminate ();
-}
+void PlatformRemoteAppleWatch::Initialize() {
+ PlatformDarwin::Initialize();
-PlatformSP
-PlatformRemoteAppleWatch::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
-
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(
+ PlatformRemoteAppleWatch::GetPluginNameStatic(),
+ PlatformRemoteAppleWatch::GetDescriptionStatic(),
+ PlatformRemoteAppleWatch::CreateInstance);
+ }
+}
+
+void PlatformRemoteAppleWatch::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformRemoteAppleWatch::CreateInstance);
+ }
+ }
+
+ PlatformDarwin::Terminate();
+}
+
+PlatformSP PlatformRemoteAppleWatch::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- log->Printf ("PlatformRemoteAppleWatch::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
- bool create = force;
- if (!create && arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::arm:
- case llvm::Triple::aarch64:
- case llvm::Triple::thumb:
- {
- const llvm::Triple &triple = arch->GetTriple();
- llvm::Triple::VendorType vendor = triple.getVendor();
- switch (vendor)
- {
- case llvm::Triple::Apple:
- create = true;
- break;
+ log->Printf("PlatformRemoteAppleWatch::%s(force=%s, arch={%s,%s})",
+ __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (!create && arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::aarch64:
+ case llvm::Triple::thumb: {
+ const llvm::Triple &triple = arch->GetTriple();
+ llvm::Triple::VendorType vendor = triple.getVendor();
+ switch (vendor) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
#if defined(__APPLE__)
- // Only accept "unknown" for the vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for the vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::WatchOS: // This is the right triple value for Apple Watch debugging
- break;
-
- default:
- create = false;
- break;
- }
- }
- }
- break;
+ default:
+ break;
+ }
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::WatchOS: // This is the right triple value for Apple
+ // Watch debugging
+ break;
+
default:
- break;
+ create = false;
+ break;
}
+ }
+ } break;
+ default:
+ break;
}
+ }
-#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__) || defined(__aarch64__))
- // If lldb is running on a watch, this isn't a RemoteWatch environment; it's a local system environment.
- if (force == false)
- {
- create = false;
- }
+#if defined(__APPLE__) && \
+ (defined(__arm__) || defined(__arm64__) || defined(__aarch64__))
+ // If lldb is running on a watch, this isn't a RemoteWatch environment; it's a
+ // local system environment.
+ if (force == false) {
+ create = false;
+ }
#endif
- if (create)
- {
- if (log)
- log->Printf ("PlatformRemoteAppleWatch::%s() creating platform", __FUNCTION__);
+ if (create) {
+ if (log)
+ log->Printf("PlatformRemoteAppleWatch::%s() creating platform",
+ __FUNCTION__);
- return lldb::PlatformSP(new PlatformRemoteAppleWatch ());
- }
+ return lldb::PlatformSP(new PlatformRemoteAppleWatch());
+ }
- if (log)
- log->Printf ("PlatformRemoteAppleWatch::%s() aborting creation of platform", __FUNCTION__);
+ if (log)
+ log->Printf("PlatformRemoteAppleWatch::%s() aborting creation of platform",
+ __FUNCTION__);
- return lldb::PlatformSP();
+ return lldb::PlatformSP();
}
-lldb_private::ConstString
-PlatformRemoteAppleWatch::GetPluginNameStatic ()
-{
- static ConstString g_name("remote-watchos");
- return g_name;
+lldb_private::ConstString PlatformRemoteAppleWatch::GetPluginNameStatic() {
+ static ConstString g_name("remote-watchos");
+ return g_name;
}
-const char *
-PlatformRemoteAppleWatch::GetDescriptionStatic()
-{
- return "Remote Apple Watch platform plug-in.";
+const char *PlatformRemoteAppleWatch::GetDescriptionStatic() {
+ return "Remote Apple Watch platform plug-in.";
}
-void
-PlatformRemoteAppleWatch::GetStatus (Stream &strm)
-{
- Platform::GetStatus (strm);
- const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
- if (sdk_directory)
- strm.Printf (" SDK Path: \"%s\"\n", sdk_directory);
- else
- strm.PutCString (" SDK Path: error: unable to locate SDK\n");
-
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- strm.Printf (" SDK Roots: [%2u] \"%s\"\n",
- i,
- sdk_dir_info.directory.GetPath().c_str());
- }
+void PlatformRemoteAppleWatch::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+ const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
+ if (sdk_directory)
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ else
+ strm.PutCString(" SDK Path: error: unable to locate SDK\n");
+
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ strm.Printf(" SDK Roots: [%2u] \"%s\"\n", i,
+ sdk_dir_info.directory.GetPath().c_str());
+ }
}
-Error
-PlatformRemoteAppleWatch::ResolveExecutable (const ModuleSpec &ms,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- ModuleSpec resolved_module_spec(ms);
-
- // Resolve any executable within a bundle on MacOSX
- // TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid())
- {
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp,
- nullptr,
- nullptr,
- nullptr);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact ARM slice wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp,
- nullptr,
- nullptr,
- nullptr);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
+Error PlatformRemoteAppleWatch::ResolveExecutable(
+ const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
- return error;
-}
+ ModuleSpec resolved_module_spec(ms);
-FileSpec::EnumerateDirectoryResult
-PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec)
-{
- ((PlatformRemoteAppleWatch::SDKDirectoryInfoCollection *)baton)->push_back(PlatformRemoteAppleWatch::SDKDirectoryInfo(file_spec));
- return FileSpec::eEnumerateDirectoryResultNext;
-}
-
-bool
-PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (m_sdk_directory_infos.empty())
- {
- const char *device_support_dir = GetDeviceSupportDirectory();
- if (log)
- {
- log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir);
- }
- if (device_support_dir)
- {
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = false;
-
- SDKDirectoryInfoCollection builtin_sdk_directory_infos;
- FileSpec::EnumerateDirectory (m_device_support_directory.c_str(),
- find_directories,
- find_files,
- find_other,
- GetContainedFilesIntoVectorOfStringsCallback,
- &builtin_sdk_directory_infos);
-
- // Only add SDK directories that have symbols in them, some SDKs only contain
- // developer disk images and no symbols, so they aren't useful to us.
- FileSpec sdk_symbols_symlink_fspec;
- for (const auto &sdk_directory_info : builtin_sdk_directory_infos)
- {
- sdk_symbols_symlink_fspec = sdk_directory_info.directory;
- sdk_symbols_symlink_fspec.AppendPathComponent("Symbols.Internal");
- if (sdk_symbols_symlink_fspec.Exists())
- {
- m_sdk_directory_infos.push_back(sdk_directory_info);
- if (log)
- {
- log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
- }
- }
- else
- {
- sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols");
- if (sdk_symbols_symlink_fspec.Exists())
- m_sdk_directory_infos.push_back(sdk_directory_info);
- if (log)
- {
- log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
- }
- }
- }
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one
+ // ourselves
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
- const uint32_t num_installed = m_sdk_directory_infos.size();
- FileSpec local_sdk_cache("~/Library/Developer/Xcode/watchOS DeviceSupport", true);
- if (!local_sdk_cache.Exists())
- {
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/watch OS DeviceSupport", true);
- }
- if (!local_sdk_cache.Exists())
- {
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/WatchOS DeviceSupport", true);
- }
- if (!local_sdk_cache.Exists())
- {
- local_sdk_cache = FileSpec("~/Library/Developer/Xcode/Watch OS DeviceSupport", true);
- }
- if (local_sdk_cache.Exists())
- {
- if (log)
- {
- log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str());
- }
- char path[PATH_MAX];
- if (local_sdk_cache.GetPath(path, sizeof(path)))
- {
- FileSpec::EnumerateDirectory (path,
- find_directories,
- find_files,
- find_other,
- GetContainedFilesIntoVectorOfStringsCallback,
- &m_sdk_directory_infos);
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // First try for an exact match of major, minor and update
- for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
- {
- m_sdk_directory_infos[i].user_cached = true;
- if (log)
- {
- log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str());
- }
- }
- }
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ if (resolved_module_spec.GetArchitecture().IsValid() ||
+ resolved_module_spec.GetUUID().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ nullptr, nullptr, nullptr);
+
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ nullptr, nullptr, nullptr);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' does not exist",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+
+ return error;
+}
+
+FileSpec::EnumerateDirectoryResult
+PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ ((PlatformRemoteAppleWatch::SDKDirectoryInfoCollection *)baton)
+ ->push_back(PlatformRemoteAppleWatch::SDKDirectoryInfo(file_spec));
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+bool PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded() {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (m_sdk_directory_infos.empty()) {
+ const char *device_support_dir = GetDeviceSupportDirectory();
+ if (log) {
+ log->Printf("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded "
+ "Got DeviceSupport directory %s",
+ device_support_dir);
+ }
+ if (device_support_dir) {
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = false;
+
+ SDKDirectoryInfoCollection builtin_sdk_directory_infos;
+ FileSpec::EnumerateDirectory(m_device_support_directory.c_str(),
+ find_directories, find_files, find_other,
+ GetContainedFilesIntoVectorOfStringsCallback,
+ &builtin_sdk_directory_infos);
+
+ // Only add SDK directories that have symbols in them, some SDKs only
+ // contain
+ // developer disk images and no symbols, so they aren't useful to us.
+ FileSpec sdk_symbols_symlink_fspec;
+ for (const auto &sdk_directory_info : builtin_sdk_directory_infos) {
+ sdk_symbols_symlink_fspec = sdk_directory_info.directory;
+ sdk_symbols_symlink_fspec.AppendPathComponent("Symbols.Internal");
+ if (sdk_symbols_symlink_fspec.Exists()) {
+ m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log) {
+ log->Printf("PlatformRemoteAppleWatch::"
+ "UpdateSDKDirectoryInfosIfNeeded added builtin SDK "
+ "directory %s",
+ sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
+ } else {
+ sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols");
+ if (sdk_symbols_symlink_fspec.Exists())
+ m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log) {
+ log->Printf("PlatformRemoteAppleWatch::"
+ "UpdateSDKDirectoryInfosIfNeeded added builtin SDK "
+ "directory %s",
+ sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
+ }
+ }
+
+ const uint32_t num_installed = m_sdk_directory_infos.size();
+ FileSpec local_sdk_cache(
+ "~/Library/Developer/Xcode/watchOS DeviceSupport", true);
+ if (!local_sdk_cache.Exists()) {
+ local_sdk_cache =
+ FileSpec("~/Library/Developer/Xcode/watch OS DeviceSupport", true);
+ }
+ if (!local_sdk_cache.Exists()) {
+ local_sdk_cache =
+ FileSpec("~/Library/Developer/Xcode/WatchOS DeviceSupport", true);
+ }
+ if (!local_sdk_cache.Exists()) {
+ local_sdk_cache =
+ FileSpec("~/Library/Developer/Xcode/Watch OS DeviceSupport", true);
+ }
+ if (local_sdk_cache.Exists()) {
+ if (log) {
+ log->Printf("PlatformRemoteAppleWatch::"
+ "UpdateSDKDirectoryInfosIfNeeded searching %s for "
+ "additional SDKs",
+ local_sdk_cache.GetPath().c_str());
+ }
+ char path[PATH_MAX];
+ if (local_sdk_cache.GetPath(path, sizeof(path))) {
+ FileSpec::EnumerateDirectory(
+ path, find_directories, find_files, find_other,
+ GetContainedFilesIntoVectorOfStringsCallback,
+ &m_sdk_directory_infos);
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // First try for an exact match of major, minor and update
+ for (uint32_t i = num_installed; i < num_sdk_infos; ++i) {
+ m_sdk_directory_infos[i].user_cached = true;
+ if (log) {
+ log->Printf("PlatformRemoteAppleWatch::"
+ "UpdateSDKDirectoryInfosIfNeeded user SDK directory "
+ "%s",
+ m_sdk_directory_infos[i].directory.GetPath().c_str());
}
+ }
}
+ }
}
- return !m_sdk_directory_infos.empty();
+ }
+ return !m_sdk_directory_infos.empty();
}
const PlatformRemoteAppleWatch::SDKDirectoryInfo *
-PlatformRemoteAppleWatch::GetSDKDirectoryForCurrentOSVersion ()
-{
- uint32_t i;
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+PlatformRemoteAppleWatch::GetSDKDirectoryForCurrentOSVersion() {
+ uint32_t i;
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // Check to see if the user specified a build string. If they did, then
- // be sure to match it.
- std::vector<bool> check_sdk_info(num_sdk_infos, true);
- ConstString build(m_sdk_build);
- if (build)
- {
- for (i=0; i<num_sdk_infos; ++i)
- check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
- }
-
- // If we are connected we can find the version of the OS the platform
- // us running on and select the right SDK
- uint32_t major, minor, update;
- if (GetOSVersion(major, minor, update))
- {
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- // First try for an exact match of major, minor and update
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major &&
- m_sdk_directory_infos[i].version_minor == minor &&
- m_sdk_directory_infos[i].version_update == update)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- // First try for an exact match of major and minor
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major &&
- m_sdk_directory_infos[i].version_minor == minor)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- // Lastly try to match of major version only..
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- }
- }
- else if (build)
- {
- // No version, just a build number, search for the first one that matches
- for (i=0; i<num_sdk_infos; ++i)
- if (check_sdk_info[i])
- return &m_sdk_directory_infos[i];
- }
+ // Check to see if the user specified a build string. If they did, then
+ // be sure to match it.
+ std::vector<bool> check_sdk_info(num_sdk_infos, true);
+ ConstString build(m_sdk_build);
+ if (build) {
+ for (i = 0; i < num_sdk_infos; ++i)
+ check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
}
- return nullptr;
-}
-const PlatformRemoteAppleWatch::SDKDirectoryInfo *
-PlatformRemoteAppleWatch::GetSDKDirectoryForLatestOSVersion ()
-{
- const PlatformRemoteAppleWatch::SDKDirectoryInfo *result = nullptr;
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // If we are connected we can find the version of the OS the platform
+ // us running on and select the right SDK
+ uint32_t major, minor, update;
+ if (GetOSVersion(major, minor, update)) {
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
// First try for an exact match of major, minor and update
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- if (sdk_dir_info.version_major != UINT32_MAX)
- {
- if (result == nullptr || sdk_dir_info.version_major > result->version_major)
- {
- result = &sdk_dir_info;
- }
- else if (sdk_dir_info.version_major == result->version_major)
- {
- if (sdk_dir_info.version_minor > result->version_minor)
- {
- result = &sdk_dir_info;
- }
- else if (sdk_dir_info.version_minor == result->version_minor)
- {
- if (sdk_dir_info.version_update > result->version_update)
- {
- result = &sdk_dir_info;
- }
- }
- }
- }
- }
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major &&
+ m_sdk_directory_infos[i].version_minor == minor &&
+ m_sdk_directory_infos[i].version_update == update) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ // First try for an exact match of major and minor
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major &&
+ m_sdk_directory_infos[i].version_minor == minor) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ // Lastly try to match of major version only..
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ }
+ } else if (build) {
+ // No version, just a build number, search for the first one that matches
+ for (i = 0; i < num_sdk_infos; ++i)
+ if (check_sdk_info[i])
+ return &m_sdk_directory_infos[i];
}
- return result;
+ }
+ return nullptr;
}
-const char *
-PlatformRemoteAppleWatch::GetDeviceSupportDirectory()
-{
- if (m_device_support_directory.empty())
- {
- const char *device_support_dir = GetDeveloperDirectory();
- if (device_support_dir)
- {
- m_device_support_directory.assign (device_support_dir);
- m_device_support_directory.append ("/Platforms/watchOS.platform/DeviceSupport");
- FileSpec platform_device_support_dir (m_device_support_directory.c_str(), true);
- if (!platform_device_support_dir.Exists())
- {
- std::string alt_platform_dirname = device_support_dir;
- alt_platform_dirname.append ("/Platforms/WatchOS.platform/DeviceSupport");
- FileSpec alt_platform_device_support_dir (m_device_support_directory.c_str(), true);
- if (alt_platform_device_support_dir.Exists())
- {
- m_device_support_directory = alt_platform_dirname;
- }
- }
- }
- else
- {
- // 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_device_support_directory.assign (1, '\0');
- }
- }
- // We should have put a single NULL character into m_device_support_directory
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory.empty() == false);
- if (m_device_support_directory[0])
- return m_device_support_directory.c_str();
- return nullptr;
-}
-
-const char *
-PlatformRemoteAppleWatch::GetDeviceSupportDirectoryForOSVersion()
-{
- if (m_sdk_sysroot)
- return m_sdk_sysroot.GetCString();
-
- if (m_device_support_directory_for_os_version.empty())
- {
- const PlatformRemoteAppleWatch::SDKDirectoryInfo *sdk_dir_info = GetSDKDirectoryForCurrentOSVersion ();
- if (sdk_dir_info == nullptr)
- sdk_dir_info = GetSDKDirectoryForLatestOSVersion ();
- if (sdk_dir_info)
- {
- char path[PATH_MAX];
- if (sdk_dir_info->directory.GetPath(path, sizeof(path)))
- {
- m_device_support_directory_for_os_version = path;
- return m_device_support_directory_for_os_version.c_str();
- }
- }
- else
- {
- // 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_device_support_directory_for_os_version.assign (1, '\0');
- }
- }
- // We should have put a single NULL character into m_device_support_directory_for_os_version
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory_for_os_version.empty() == false);
- if (m_device_support_directory_for_os_version[0])
+const PlatformRemoteAppleWatch::SDKDirectoryInfo *
+PlatformRemoteAppleWatch::GetSDKDirectoryForLatestOSVersion() {
+ const PlatformRemoteAppleWatch::SDKDirectoryInfo *result = nullptr;
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // First try for an exact match of major, minor and update
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (sdk_dir_info.version_major != UINT32_MAX) {
+ if (result == nullptr ||
+ sdk_dir_info.version_major > result->version_major) {
+ result = &sdk_dir_info;
+ } else if (sdk_dir_info.version_major == result->version_major) {
+ if (sdk_dir_info.version_minor > result->version_minor) {
+ result = &sdk_dir_info;
+ } else if (sdk_dir_info.version_minor == result->version_minor) {
+ if (sdk_dir_info.version_update > result->version_update) {
+ result = &sdk_dir_info;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+const char *PlatformRemoteAppleWatch::GetDeviceSupportDirectory() {
+ if (m_device_support_directory.empty()) {
+ const char *device_support_dir = GetDeveloperDirectory();
+ if (device_support_dir) {
+ m_device_support_directory.assign(device_support_dir);
+ m_device_support_directory.append(
+ "/Platforms/watchOS.platform/DeviceSupport");
+ FileSpec platform_device_support_dir(m_device_support_directory.c_str(),
+ true);
+ if (!platform_device_support_dir.Exists()) {
+ std::string alt_platform_dirname = device_support_dir;
+ alt_platform_dirname.append(
+ "/Platforms/WatchOS.platform/DeviceSupport");
+ FileSpec alt_platform_device_support_dir(
+ m_device_support_directory.c_str(), true);
+ if (alt_platform_device_support_dir.Exists()) {
+ m_device_support_directory = alt_platform_dirname;
+ }
+ }
+ } else {
+ // 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_device_support_directory.assign(1, '\0');
+ }
+ }
+ // We should have put a single NULL character into m_device_support_directory
+ // or it should have a valid path if the code gets here
+ assert(m_device_support_directory.empty() == false);
+ if (m_device_support_directory[0])
+ return m_device_support_directory.c_str();
+ return nullptr;
+}
+
+const char *PlatformRemoteAppleWatch::GetDeviceSupportDirectoryForOSVersion() {
+ if (m_sdk_sysroot)
+ return m_sdk_sysroot.GetCString();
+
+ if (m_device_support_directory_for_os_version.empty()) {
+ const PlatformRemoteAppleWatch::SDKDirectoryInfo *sdk_dir_info =
+ GetSDKDirectoryForCurrentOSVersion();
+ if (sdk_dir_info == nullptr)
+ sdk_dir_info = GetSDKDirectoryForLatestOSVersion();
+ if (sdk_dir_info) {
+ char path[PATH_MAX];
+ if (sdk_dir_info->directory.GetPath(path, sizeof(path))) {
+ m_device_support_directory_for_os_version = path;
return m_device_support_directory_for_os_version.c_str();
- return nullptr;
+ }
+ } else {
+ // 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_device_support_directory_for_os_version.assign(1, '\0');
+ }
+ }
+ // We should have put a single NULL character into
+ // m_device_support_directory_for_os_version
+ // or it should have a valid path if the code gets here
+ assert(m_device_support_directory_for_os_version.empty() == false);
+ if (m_device_support_directory_for_os_version[0])
+ return m_device_support_directory_for_os_version.c_str();
+ return nullptr;
}
uint32_t
-PlatformRemoteAppleWatch::FindFileInAllSDKs (const char *platform_file_path,
- FileSpecList &file_list)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
- if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- lldb_private::FileSpec local_file;
- // First try for an exact match of major, minor and update
- for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path,
- sdk_idx,
- local_file))
- {
- file_list.Append(local_file);
- }
- }
- }
- return file_list.GetSize();
-}
-
-bool
-PlatformRemoteAppleWatch::GetFileInSDK (const char *platform_file_path,
- uint32_t sdk_idx,
- lldb_private::FileSpec &local_file)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (sdk_idx < m_sdk_directory_infos.size())
- {
- std::string sdkroot_path = m_sdk_directory_infos[sdk_idx].directory.GetPath();
- if (!sdkroot_path.empty() && platform_file_path && platform_file_path[0])
- {
- // We may need to interpose "/Symbols/" or "/Symbols.Internal/" between the
- // SDK root directory and the file path.
-
- const char *paths_to_try[] = { "Symbols", "", "Symbols.Internal", nullptr };
- for (size_t i = 0; paths_to_try[i] != nullptr; i++)
- {
- local_file.SetFile (sdkroot_path.c_str(), false);
- if (paths_to_try[i][0] != '\0')
- local_file.AppendPathComponent (paths_to_try[i]);
- local_file.AppendPathComponent (platform_file_path);
- local_file.ResolvePath();
- if (local_file.Exists())
- {
- if (log)
- log->Printf ("Found a copy of %s in the SDK dir %s/%s", platform_file_path,
- sdkroot_path.c_str(),
- paths_to_try[i]);
- return true;
- }
- local_file.Clear();
- }
+PlatformRemoteAppleWatch::FindFileInAllSDKs(const char *platform_file_path,
+ FileSpecList &file_list) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+ LIBLLDB_LOG_VERBOSE);
+ if (platform_file_path && platform_file_path[0] &&
+ UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ lldb_private::FileSpec local_file;
+ // First try for an exact match of major, minor and update
+ for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) {
+ file_list.Append(local_file);
+ }
+ }
+ }
+ return file_list.GetSize();
+}
+
+bool PlatformRemoteAppleWatch::GetFileInSDK(
+ const char *platform_file_path, uint32_t sdk_idx,
+ lldb_private::FileSpec &local_file) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (sdk_idx < m_sdk_directory_infos.size()) {
+ std::string sdkroot_path =
+ m_sdk_directory_infos[sdk_idx].directory.GetPath();
+ if (!sdkroot_path.empty() && platform_file_path && platform_file_path[0]) {
+ // We may need to interpose "/Symbols/" or "/Symbols.Internal/" between
+ // the
+ // SDK root directory and the file path.
+
+ const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr};
+ for (size_t i = 0; paths_to_try[i] != nullptr; i++) {
+ local_file.SetFile(sdkroot_path.c_str(), false);
+ if (paths_to_try[i][0] != '\0')
+ local_file.AppendPathComponent(paths_to_try[i]);
+ local_file.AppendPathComponent(platform_file_path);
+ local_file.ResolvePath();
+ if (local_file.Exists()) {
+ if (log)
+ log->Printf("Found a copy of %s in the SDK dir %s/%s",
+ platform_file_path, sdkroot_path.c_str(),
+ paths_to_try[i]);
+ return true;
+ }
+ local_file.Clear();
+ }
+ }
+ }
+ return false;
+}
+
+Error PlatformRemoteAppleWatch::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ Error error;
+ char platform_file_path[PATH_MAX];
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
+ char resolved_path[PATH_MAX];
+
+ const char *os_version_dir = GetDeviceSupportDirectoryForOSVersion();
+ if (os_version_dir) {
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir,
+ platform_file_path);
+
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf("Found a copy of %s in the DeviceSupport dir %s",
+ platform_file_path, os_version_dir);
}
- }
- return false;
-}
-
-Error
-PlatformRemoteAppleWatch::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- Error error;
- char platform_file_path[PATH_MAX];
- if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
- {
- char resolved_path[PATH_MAX];
-
- const char * os_version_dir = GetDeviceSupportDirectoryForOSVersion();
- if (os_version_dir)
- {
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir);
- }
- return error;
- }
+ return error;
+ }
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/Symbols.Internal/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir);
- }
- return error;
- }
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/Symbols/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir);
- }
- return error;
- }
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols.Internal/%s",
+ os_version_dir, platform_file_path);
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf(
+ "Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal",
+ platform_file_path, os_version_dir);
}
- local_file = platform_file;
- if (local_file.Exists())
- return error;
-
- error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
- platform_file_path,
- GetPluginName().GetCString());
- }
- else
- {
- error.SetErrorString ("invalid platform file argument");
+ return error;
+ }
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s",
+ os_version_dir, platform_file_path);
+
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf("Found a copy of %s in the DeviceSupport dir %s/Symbols",
+ platform_file_path, os_version_dir);
+ }
+ return error;
+ }
}
- return error;
-}
+ local_file = platform_file;
+ if (local_file.Exists())
+ return error;
+
+ error.SetErrorStringWithFormat(
+ "unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path, GetPluginName().GetCString());
+ } else {
+ error.SetErrorString("invalid platform file argument");
+ }
+ return error;
+}
+
+Error PlatformRemoteAppleWatch::GetSharedModule(
+ const ModuleSpec &module_spec, lldb_private::Process *process,
+ ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
+ ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
+ // For Apple Watch, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+ LIBLLDB_LOG_VERBOSE);
-Error
-PlatformRemoteAppleWatch::GetSharedModule (const ModuleSpec &module_spec,
- lldb_private::Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- // For Apple Watch, the SDK files are all cached locally on the host
- // system. So first we ask for the file in the cached SDK,
- // then we attempt to get a shared module for the right architecture
- // with the right UUID.
- const FileSpec &platform_file = module_spec.GetFileSpec();
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
-
- Error error;
- char platform_file_path[PATH_MAX];
-
- if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
- {
- ModuleSpec platform_module_spec(module_spec);
+ Error error;
+ char platform_file_path[PATH_MAX];
- UpdateSDKDirectoryInfosIfNeeded();
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
+ ModuleSpec platform_module_spec(module_spec);
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ UpdateSDKDirectoryInfosIfNeeded();
- // If we are connected we migth be able to correctly deduce the SDK directory
- // using the OS build.
- const uint32_t connected_sdk_idx = GetConnectedSDKIndex ();
- if (connected_sdk_idx < num_sdk_infos)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable(platform_module_spec,
- module_sp,
- nullptr);
- if (module_sp)
- {
- m_last_module_sdk_idx = connected_sdk_idx;
- error.Clear();
- return error;
- }
- }
- }
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // Try the last SDK index if it is set as most files from an SDK
- // will tend to be valid in that same SDK.
- if (m_last_module_sdk_idx < num_sdk_infos)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable(platform_module_spec,
- module_sp,
- nullptr);
- if (module_sp)
- {
- error.Clear();
- return error;
- }
- }
- }
-
- // First try for an exact match of major, minor and update
- for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
- {
- if (m_last_module_sdk_idx == sdk_idx)
- {
- // Skip the last module SDK index if we already searched
- // it above
- continue;
- }
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec()))
- {
- //printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
-
- error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
- if (module_sp)
- {
- // Remember the index of the last SDK that we found a file
- // in in case the wrong SDK was selected.
- m_last_module_sdk_idx = sdk_idx;
- error.Clear();
- return error;
- }
- }
- }
- }
- // Not the module we are looking for... Nothing to see here...
- module_sp.reset();
+ // If we are connected we migth be able to correctly deduce the SDK
+ // directory
+ // using the OS build.
+ const uint32_t connected_sdk_idx = GetConnectedSDKIndex();
+ if (connected_sdk_idx < num_sdk_infos) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[connected_sdk_idx]
+ .directory.GetPath()
+ .c_str());
+ }
+ if (GetFileInSDK(platform_file_path, connected_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
+ if (module_sp) {
+ m_last_module_sdk_idx = connected_sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // Try the last SDK index if it is set as most files from an SDK
+ // will tend to be valid in that same SDK.
+ if (m_last_module_sdk_idx < num_sdk_infos) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[m_last_module_sdk_idx]
+ .directory.GetPath()
+ .c_str());
+ }
+ if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
+ if (module_sp) {
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // First try for an exact match of major, minor and update
+ for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
+ if (m_last_module_sdk_idx == sdk_idx) {
+ // Skip the last module SDK index if we already searched
+ // it above
+ continue;
+ }
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
+
+ error = ResolveExecutable(platform_module_spec, module_sp, nullptr);
+ if (module_sp) {
+ // Remember the index of the last SDK that we found a file
+ // in in case the wrong SDK was selected.
+ m_last_module_sdk_idx = sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+ }
+ // Not the module we are looking for... Nothing to see here...
+ module_sp.reset();
+
+ // This may not be an SDK-related module. Try whether we can bring in the
+ // thing to our local cache.
+ error = GetSharedModuleWithLocalCache(module_spec, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ if (error.Success())
+ return error;
- // This may not be an SDK-related module. Try whether we can bring in the thing to our local cache.
- error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
- if (error.Success())
- return error;
+ // See if the file is present in any of the module_search_paths_ptr
+ // directories.
+ if (!module_sp && module_search_paths_ptr && platform_file) {
+ // create a vector of all the file / directory names in platform_file
+ // e.g. this might be
+ // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ //
+ // We'll need to look in the module_search_paths_ptr directories for
+ // both "UIFoundation" and "UIFoundation.framework" -- most likely the
+ // latter will be the one we find there.
+
+ FileSpec platform_pull_apart(platform_file);
+ std::vector<std::string> path_parts;
+ ConstString unix_root_dir("/");
+ while (true) {
+ ConstString part = platform_pull_apart.GetLastPathComponent();
+ platform_pull_apart.RemoveLastPathComponent();
+ if (part.IsEmpty() || part == unix_root_dir)
+ break;
+ path_parts.push_back(part.AsCString());
+ }
+ const size_t path_parts_size = path_parts.size();
- // See if the file is present in any of the module_search_paths_ptr directories.
- if (!module_sp && module_search_paths_ptr && platform_file)
- {
- // create a vector of all the file / directory names in platform_file
- // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i) {
+ // Create a new FileSpec with this module_search_paths_ptr
+ // plus just the filename ("UIFoundation"), then the parent
+ // dir plus filename ("UIFoundation.framework/UIFoundation")
+ // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
+
+ for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
+ FileSpec path_to_try(module_search_paths_ptr->GetFileSpecAtIndex(i));
+
+ // Add the components backwards. For
+ // .../PrivateFrameworks/UIFoundation.framework/UIFoundation
+ // path_parts is
+ // [0] UIFoundation
+ // [1] UIFoundation.framework
+ // [2] PrivateFrameworks
//
- // We'll need to look in the module_search_paths_ptr directories for
- // both "UIFoundation" and "UIFoundation.framework" -- most likely the
- // latter will be the one we find there.
-
- FileSpec platform_pull_apart (platform_file);
- std::vector<std::string> path_parts;
- ConstString unix_root_dir("/");
- while (true)
- {
- ConstString part = platform_pull_apart.GetLastPathComponent();
- platform_pull_apart.RemoveLastPathComponent();
- if (part.IsEmpty() || part == unix_root_dir)
- break;
- path_parts.push_back (part.AsCString());
- }
- const size_t path_parts_size = path_parts.size();
-
- size_t num_module_search_paths = module_search_paths_ptr->GetSize();
- for (size_t i = 0; i < num_module_search_paths; ++i)
- {
- // Create a new FileSpec with this module_search_paths_ptr
- // plus just the filename ("UIFoundation"), then the parent
- // dir plus filename ("UIFoundation.framework/UIFoundation")
- // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
-
- for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j)
- {
- FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i));
-
- // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation
- // path_parts is
- // [0] UIFoundation
- // [1] UIFoundation.framework
- // [2] PrivateFrameworks
- //
- // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka
- // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path.
-
- for (int k = j; k >= 0; --k)
- {
- path_to_try.AppendPathComponent (path_parts[k]);
- }
-
- if (path_to_try.Exists())
- {
- ModuleSpec new_module_spec (module_spec);
- new_module_spec.GetFileSpec() = path_to_try;
- Error new_error (Platform::GetSharedModule (new_module_spec,
- process,
- module_sp,
- NULL,
- old_module_sp_ptr,
- did_create_ptr));
-
- if (module_sp)
- {
- module_sp->SetPlatformFileSpec (path_to_try);
- return new_error;
- }
- }
- }
- }
+ // and if 'j' is 2, we want to append path_parts[1] and then
+ // path_parts[0], aka
+ // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr
+ // path.
+
+ for (int k = j; k >= 0; --k) {
+ path_to_try.AppendPathComponent(path_parts[k]);
+ }
+
+ if (path_to_try.Exists()) {
+ ModuleSpec new_module_spec(module_spec);
+ new_module_spec.GetFileSpec() = path_to_try;
+ Error new_error(Platform::GetSharedModule(
+ new_module_spec, process, module_sp, NULL, old_module_sp_ptr,
+ did_create_ptr));
+
+ if (module_sp) {
+ module_sp->SetPlatformFileSpec(path_to_try);
+ return new_error;
+ }
+ }
+ }
+ }
+ }
+
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr, always_create);
+
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
+
+ return error;
+}
+
+bool PlatformRemoteAppleWatch::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ ArchSpec system_arch(GetSystemArchitecture());
+
+ const ArchSpec::Core system_core = system_arch.GetCore();
+ switch (system_core) {
+ default:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("arm64-apple-watchos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7k-apple-watchos");
+ return true;
+ case 2:
+ arch.SetTriple("armv7s-apple-watchos");
+ return true;
+ case 3:
+ arch.SetTriple("armv7-apple-watchos");
+ return true;
+ case 4:
+ arch.SetTriple("thumbv7k-apple-watchos");
+ return true;
+ case 5:
+ arch.SetTriple("thumbv7-apple-watchos");
+ return true;
+ case 6:
+ arch.SetTriple("thumbv7s-apple-watchos");
+ return true;
+ default:
+ break;
}
+ break;
- const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr,
- always_create);
-
- if (module_sp)
- module_sp->SetPlatformFileSpec(platform_file);
-
- return error;
-}
-
-bool
-PlatformRemoteAppleWatch::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- ArchSpec system_arch (GetSystemArchitecture());
-
- const ArchSpec::Core system_core = system_arch.GetCore();
- switch (system_core)
- {
+ case ArchSpec::eCore_arm_arm64:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("arm64-apple-watchos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7k-apple-watchos");
+ return true;
+ case 2:
+ arch.SetTriple("armv7s-apple-watchos");
+ return true;
+ case 3:
+ arch.SetTriple("armv7-apple-watchos");
+ return true;
+ case 4:
+ arch.SetTriple("thumbv7k-apple-watchos");
+ return true;
+ case 5:
+ arch.SetTriple("thumbv7-apple-watchos");
+ return true;
+ case 6:
+ arch.SetTriple("thumbv7s-apple-watchos");
+ return true;
default:
- switch (idx)
- {
- case 0: arch.SetTriple ("arm64-apple-watchos"); return true;
- case 1: arch.SetTriple ("armv7k-apple-watchos"); return true;
- case 2: arch.SetTriple ("armv7s-apple-watchos"); return true;
- case 3: arch.SetTriple ("armv7-apple-watchos"); return true;
- case 4: arch.SetTriple ("thumbv7k-apple-watchos"); return true;
- case 5: arch.SetTriple ("thumbv7-apple-watchos"); return true;
- case 6: arch.SetTriple ("thumbv7s-apple-watchos"); return true;
- default: break;
- }
- break;
-
- case ArchSpec::eCore_arm_arm64:
- switch (idx)
- {
- case 0: arch.SetTriple ("arm64-apple-watchos"); return true;
- case 1: arch.SetTriple ("armv7k-apple-watchos"); return true;
- case 2: arch.SetTriple ("armv7s-apple-watchos"); return true;
- case 3: arch.SetTriple ("armv7-apple-watchos"); return true;
- case 4: arch.SetTriple ("thumbv7k-apple-watchos"); return true;
- case 5: arch.SetTriple ("thumbv7-apple-watchos"); return true;
- case 6: arch.SetTriple ("thumbv7s-apple-watchos"); return true;
- default: break;
- }
- break;
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7k:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7k-apple-watchos"); return true;
- case 1: arch.SetTriple ("armv7s-apple-watchos"); return true;
- case 2: arch.SetTriple ("armv7-apple-watchos"); return true;
- case 3: arch.SetTriple ("thumbv7k-apple-watchos"); return true;
- case 4: arch.SetTriple ("thumbv7-apple-watchos"); return true;
- case 5: arch.SetTriple ("thumbv7s-apple-watchos"); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7k:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7k-apple-watchos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7s-apple-watchos");
+ return true;
+ case 2:
+ arch.SetTriple("armv7-apple-watchos");
+ return true;
+ case 3:
+ arch.SetTriple("thumbv7k-apple-watchos");
+ return true;
+ case 4:
+ arch.SetTriple("thumbv7-apple-watchos");
+ return true;
+ case 5:
+ arch.SetTriple("thumbv7s-apple-watchos");
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7s:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7s-apple-watchos"); return true;
- case 1: arch.SetTriple ("armv7k-apple-watchos"); return true;
- case 2: arch.SetTriple ("armv7-apple-watchos"); return true;
- case 3: arch.SetTriple ("thumbv7k-apple-watchos"); return true;
- case 4: arch.SetTriple ("thumbv7-apple-watchos"); return true;
- case 5: arch.SetTriple ("thumbv7s-apple-watchos"); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7s:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7s-apple-watchos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7k-apple-watchos");
+ return true;
+ case 2:
+ arch.SetTriple("armv7-apple-watchos");
+ return true;
+ case 3:
+ arch.SetTriple("thumbv7k-apple-watchos");
+ return true;
+ case 4:
+ arch.SetTriple("thumbv7-apple-watchos");
+ return true;
+ case 5:
+ arch.SetTriple("thumbv7s-apple-watchos");
+ return true;
+ default:
+ break;
+ }
+ break;
- case ArchSpec::eCore_arm_armv7:
- switch (idx)
- {
- case 0: arch.SetTriple ("armv7-apple-watchos"); return true;
- case 1: arch.SetTriple ("armv7k-apple-watchos"); return true;
- case 2: arch.SetTriple ("thumbv7k-apple-watchos"); return true;
- case 3: arch.SetTriple ("thumbv7-apple-watchos"); return true;
- default: break;
- }
- break;
+ case ArchSpec::eCore_arm_armv7:
+ switch (idx) {
+ case 0:
+ arch.SetTriple("armv7-apple-watchos");
+ return true;
+ case 1:
+ arch.SetTriple("armv7k-apple-watchos");
+ return true;
+ case 2:
+ arch.SetTriple("thumbv7k-apple-watchos");
+ return true;
+ case 3:
+ arch.SetTriple("thumbv7-apple-watchos");
+ return true;
+ default:
+ break;
}
- arch.Clear();
- return false;
+ break;
+ }
+ arch.Clear();
+ return false;
}
-uint32_t
-PlatformRemoteAppleWatch::GetConnectedSDKIndex ()
-{
- if (IsConnected())
- {
- if (m_connected_module_sdk_idx == UINT32_MAX)
- {
- std::string build;
- if (GetRemoteOSBuildString(build))
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""), build.c_str()))
- {
- m_connected_module_sdk_idx = i;
- }
- }
- }
- }
- }
- else
- {
- m_connected_module_sdk_idx = UINT32_MAX;
- }
- return m_connected_module_sdk_idx;
+uint32_t PlatformRemoteAppleWatch::GetConnectedSDKIndex() {
+ if (IsConnected()) {
+ if (m_connected_module_sdk_idx == UINT32_MAX) {
+ std::string build;
+ if (GetRemoteOSBuildString(build)) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""),
+ build.c_str())) {
+ m_connected_module_sdk_idx = i;
+ }
+ }
+ }
+ }
+ } else {
+ m_connected_module_sdk_idx = UINT32_MAX;
+ }
+ return m_connected_module_sdk_idx;
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h Tue Sep 6 15:57:50 2016
@@ -21,147 +21,118 @@
#include "PlatformDarwin.h"
-class PlatformRemoteAppleWatch : public PlatformDarwin
-{
+class PlatformRemoteAppleWatch : public PlatformDarwin {
public:
- PlatformRemoteAppleWatch();
+ PlatformRemoteAppleWatch();
- ~PlatformRemoteAppleWatch() override = default;
+ ~PlatformRemoteAppleWatch() override = default;
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // Class Methods
- //------------------------------------------------------------
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- virtual lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneOS);
- }
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // Class Methods
+ //------------------------------------------------------------
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override { return GetDescriptionStatic(); }
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ virtual lldb_private::Error
+ GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::iPhoneOS);
+ }
protected:
- struct SDKDirectoryInfo
- {
- SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir_spec);
- lldb_private::FileSpec directory;
- lldb_private::ConstString build;
- uint32_t version_major;
- uint32_t version_minor;
- uint32_t version_update;
- bool user_cached;
- };
- typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
- SDKDirectoryInfoCollection m_sdk_directory_infos;
- std::string m_device_support_directory;
- std::string m_device_support_directory_for_os_version;
- std::string m_build_update;
- uint32_t m_last_module_sdk_idx;
- uint32_t m_connected_module_sdk_idx;
-
- bool
- UpdateSDKDirectoryInfosIfNeeded();
-
- const char *
- GetDeviceSupportDirectory();
-
- const char *
- GetDeviceSupportDirectoryForOSVersion();
-
- const SDKDirectoryInfo *
- GetSDKDirectoryForLatestOSVersion ();
-
- const SDKDirectoryInfo *
- GetSDKDirectoryForCurrentOSVersion ();
-
- static lldb_private::FileSpec::EnumerateDirectoryResult
- GetContainedFilesIntoVectorOfStringsCallback (void *baton,
- lldb_private::FileSpec::FileType file_type,
- const lldb_private::FileSpec &file_spec);
-
- uint32_t
- FindFileInAllSDKs (const char *platform_file_path,
- lldb_private::FileSpecList &file_list);
-
- bool
- GetFileInSDK (const char *platform_file_path,
- uint32_t sdk_idx,
- lldb_private::FileSpec &local_file);
-
- uint32_t
- FindFileInAllSDKs (const lldb_private::FileSpec &platform_file,
- lldb_private::FileSpecList &file_list);
+ struct SDKDirectoryInfo {
+ SDKDirectoryInfo(const lldb_private::FileSpec &sdk_dir_spec);
+ lldb_private::FileSpec directory;
+ lldb_private::ConstString build;
+ uint32_t version_major;
+ uint32_t version_minor;
+ uint32_t version_update;
+ bool user_cached;
+ };
+ typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
+ SDKDirectoryInfoCollection m_sdk_directory_infos;
+ std::string m_device_support_directory;
+ std::string m_device_support_directory_for_os_version;
+ std::string m_build_update;
+ uint32_t m_last_module_sdk_idx;
+ uint32_t m_connected_module_sdk_idx;
+
+ bool UpdateSDKDirectoryInfosIfNeeded();
+
+ const char *GetDeviceSupportDirectory();
+
+ const char *GetDeviceSupportDirectoryForOSVersion();
+
+ const SDKDirectoryInfo *GetSDKDirectoryForLatestOSVersion();
+
+ const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion();
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ GetContainedFilesIntoVectorOfStringsCallback(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec);
+
+ uint32_t FindFileInAllSDKs(const char *platform_file_path,
+ lldb_private::FileSpecList &file_list);
+
+ bool GetFileInSDK(const char *platform_file_path, uint32_t sdk_idx,
+ lldb_private::FileSpec &local_file);
+
+ uint32_t FindFileInAllSDKs(const lldb_private::FileSpec &platform_file,
+ lldb_private::FileSpecList &file_list);
- uint32_t
- GetConnectedSDKIndex ();
+ uint32_t GetConnectedSDKIndex();
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformRemoteAppleWatch);
+ DISALLOW_COPY_AND_ASSIGN(PlatformRemoteAppleWatch);
};
#endif // liblldb_PlatformRemoteAppleWatch_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Tue Sep 6 15:57:50 2016
@@ -30,27 +30,20 @@
using namespace lldb;
using namespace lldb_private;
-PlatformRemoteiOS::SDKDirectoryInfo::SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir) :
- directory(sdk_dir),
- build(),
- version_major(0),
- version_minor(0),
- version_update(0),
- user_cached(false)
-{
- const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
- const char *pos = Args::StringToVersion (dirname_cstr,
- version_major,
- version_minor,
- version_update);
-
- if (pos && pos[0] == ' ' && pos[1] == '(')
- {
- const char *build_start = pos + 2;
- const char *end_paren = strchr (build_start, ')');
- if (end_paren && build_start < end_paren)
- build.SetCStringWithLength(build_start, end_paren - build_start);
- }
+PlatformRemoteiOS::SDKDirectoryInfo::SDKDirectoryInfo(
+ const lldb_private::FileSpec &sdk_dir)
+ : directory(sdk_dir), build(), version_major(0), version_minor(0),
+ version_update(0), user_cached(false) {
+ const char *dirname_cstr = sdk_dir.GetFilename().GetCString();
+ const char *pos = Args::StringToVersion(dirname_cstr, version_major,
+ version_minor, version_update);
+
+ if (pos && pos[0] == ' ' && pos[1] == '(') {
+ const char *build_start = pos + 2;
+ const char *end_paren = strchr(build_start, ')');
+ if (end_paren && build_start < end_paren)
+ build.SetCStringWithLength(build_start, end_paren - build_start);
+ }
}
//------------------------------------------------------------------
@@ -61,141 +54,118 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformRemoteiOS::Initialize ()
-{
- PlatformDarwin::Initialize ();
+void PlatformRemoteiOS::Initialize() {
+ PlatformDarwin::Initialize();
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformRemoteiOS::GetPluginNameStatic(),
- PlatformRemoteiOS::GetDescriptionStatic(),
- PlatformRemoteiOS::CreateInstance);
- }
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(PlatformRemoteiOS::GetPluginNameStatic(),
+ PlatformRemoteiOS::GetDescriptionStatic(),
+ PlatformRemoteiOS::CreateInstance);
+ }
}
-void
-PlatformRemoteiOS::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformRemoteiOS::CreateInstance);
- }
+void PlatformRemoteiOS::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformRemoteiOS::CreateInstance);
}
+ }
- PlatformDarwin::Terminate ();
+ PlatformDarwin::Terminate();
}
-PlatformSP
-PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
-
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
- log->Printf ("PlatformRemoteiOS::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::arm:
- case llvm::Triple::aarch64:
- case llvm::Triple::thumb:
- {
- const llvm::Triple &triple = arch->GetTriple();
- llvm::Triple::VendorType vendor = triple.getVendor();
- switch (vendor)
- {
- case llvm::Triple::Apple:
- create = true;
- break;
+ log->Printf("PlatformRemoteiOS::%s(force=%s, arch={%s,%s})", __FUNCTION__,
+ force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::aarch64:
+ case llvm::Triple::thumb: {
+ const llvm::Triple &triple = arch->GetTriple();
+ llvm::Triple::VendorType vendor = triple.getVendor();
+ switch (vendor) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
#if defined(__APPLE__)
- // Only accept "unknown" for the vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for the vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::Darwin: // Deprecated, but still support Darwin for historical reasons
- case llvm::Triple::IOS: // This is the right triple value for iOS debugging
- break;
-
- default:
- create = false;
- break;
- }
- }
- }
- break;
+ default:
+ break;
+ }
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
+ // historical reasons
+ case llvm::Triple::IOS: // This is the right triple value for iOS
+ // debugging
+ break;
+
default:
- break;
+ create = false;
+ break;
}
+ }
+ } break;
+ default:
+ break;
}
+ }
- if (create)
- {
- if (log)
- log->Printf ("PlatformRemoteiOS::%s() creating platform", __FUNCTION__);
-
- return lldb::PlatformSP(new PlatformRemoteiOS ());
- }
-
+ if (create) {
if (log)
- log->Printf ("PlatformRemoteiOS::%s() aborting creation of platform", __FUNCTION__);
+ log->Printf("PlatformRemoteiOS::%s() creating platform", __FUNCTION__);
- return lldb::PlatformSP();
-}
+ return lldb::PlatformSP(new PlatformRemoteiOS());
+ }
+ if (log)
+ log->Printf("PlatformRemoteiOS::%s() aborting creation of platform",
+ __FUNCTION__);
-lldb_private::ConstString
-PlatformRemoteiOS::GetPluginNameStatic ()
-{
- static ConstString g_name("remote-ios");
- return g_name;
+ return lldb::PlatformSP();
}
-const char *
-PlatformRemoteiOS::GetDescriptionStatic()
-{
- return "Remote iOS platform plug-in.";
+lldb_private::ConstString PlatformRemoteiOS::GetPluginNameStatic() {
+ static ConstString g_name("remote-ios");
+ return g_name;
}
+const char *PlatformRemoteiOS::GetDescriptionStatic() {
+ return "Remote iOS platform plug-in.";
+}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformRemoteiOS::PlatformRemoteiOS () :
- PlatformDarwin (false), // This is a remote platform
- m_sdk_directory_infos(),
- m_device_support_directory(),
- m_device_support_directory_for_os_version (),
- m_build_update(),
- m_last_module_sdk_idx (UINT32_MAX),
- m_connected_module_sdk_idx (UINT32_MAX)
-{
-}
+PlatformRemoteiOS::PlatformRemoteiOS()
+ : PlatformDarwin(false), // This is a remote platform
+ m_sdk_directory_infos(), m_device_support_directory(),
+ m_device_support_directory_for_os_version(), m_build_update(),
+ m_last_module_sdk_idx(UINT32_MAX),
+ m_connected_module_sdk_idx(UINT32_MAX) {}
//------------------------------------------------------------------
/// Destructor.
@@ -203,784 +173,668 @@ PlatformRemoteiOS::PlatformRemoteiOS ()
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformRemoteiOS::~PlatformRemoteiOS()
-{
-}
-
-
-void
-PlatformRemoteiOS::GetStatus (Stream &strm)
-{
- Platform::GetStatus (strm);
- const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
- if (sdk_directory)
- strm.Printf (" SDK Path: \"%s\"\n", sdk_directory);
- else
- strm.PutCString (" SDK Path: error: unable to locate SDK\n");
-
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- strm.Printf (" SDK Roots: [%2u] \"%s\"\n",
- i,
- sdk_dir_info.directory.GetPath().c_str());
- }
-}
+PlatformRemoteiOS::~PlatformRemoteiOS() {}
+void PlatformRemoteiOS::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+ const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
+ if (sdk_directory)
+ strm.Printf(" SDK Path: \"%s\"\n", sdk_directory);
+ else
+ strm.PutCString(" SDK Path: error: unable to locate SDK\n");
+
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ strm.Printf(" SDK Roots: [%2u] \"%s\"\n", i,
+ sdk_dir_info.directory.GetPath().c_str());
+ }
+}
+
+Error PlatformRemoteiOS::ResolveExecutable(
+ const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ ModuleSpec resolved_module_spec(ms);
+
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one
+ // ourselves
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ if (resolved_module_spec.GetArchitecture().IsValid() ||
+ resolved_module_spec.GetUUID().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
-Error
-PlatformRemoteiOS::ResolveExecutable (const ModuleSpec &ms,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- ModuleSpec resolved_module_spec(ms);
-
- // Resolve any executable within a bundle on MacOSX
- // TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact ARM slice wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
}
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
- return error;
-}
-
-FileSpec::EnumerateDirectoryResult
-PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback (void *baton,
- FileSpec::FileType file_type,
- const FileSpec &file_spec)
-{
- ((PlatformRemoteiOS::SDKDirectoryInfoCollection *)baton)->push_back(PlatformRemoteiOS::SDKDirectoryInfo(file_spec));
- return FileSpec::eEnumerateDirectoryResultNext;
-}
-
-bool
-PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded()
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (m_sdk_directory_infos.empty())
- {
- // A --sysroot option was supplied - add it to our list of SDKs to check
- if (m_sdk_sysroot)
- {
- FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString(), true);
- const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec);
- m_sdk_directory_infos.push_back(sdk_sysroot_directory_info);
- if (log)
- {
- log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded added --sysroot SDK directory %s", m_sdk_sysroot.GetCString());
- }
- return true;
- }
- const char *device_support_dir = GetDeviceSupportDirectory();
- if (log)
- {
- log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir);
- }
- if (device_support_dir)
- {
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = false;
-
- SDKDirectoryInfoCollection builtin_sdk_directory_infos;
- FileSpec::EnumerateDirectory (m_device_support_directory.c_str(),
- find_directories,
- find_files,
- find_other,
- GetContainedFilesIntoVectorOfStringsCallback,
- &builtin_sdk_directory_infos);
-
- // Only add SDK directories that have symbols in them, some SDKs only contain
- // developer disk images and no symbols, so they aren't useful to us.
- FileSpec sdk_symbols_symlink_fspec;
- for (const auto &sdk_directory_info : builtin_sdk_directory_infos)
- {
- sdk_symbols_symlink_fspec = sdk_directory_info.directory;
- sdk_symbols_symlink_fspec.AppendPathComponent("Symbols");
- if (sdk_symbols_symlink_fspec.Exists())
- {
- m_sdk_directory_infos.push_back(sdk_directory_info);
- if (log)
- {
- log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
- }
- }
- }
-
- const uint32_t num_installed = m_sdk_directory_infos.size();
- FileSpec local_sdk_cache("~/Library/Developer/Xcode/iOS DeviceSupport", true);
- if (local_sdk_cache.Exists())
- {
- if (log)
- {
- log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str());
- }
- char path[PATH_MAX];
- if (local_sdk_cache.GetPath(path, sizeof(path)))
- {
- FileSpec::EnumerateDirectory (path,
- find_directories,
- find_files,
- find_other,
- GetContainedFilesIntoVectorOfStringsCallback,
- &m_sdk_directory_infos);
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // First try for an exact match of major, minor and update
- for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
- {
- m_sdk_directory_infos[i].user_cached = true;
- if (log)
- {
- log->Printf ("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str());
- }
- }
- }
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' does not exist",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+
+ return error;
+}
+
+FileSpec::EnumerateDirectoryResult
+PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback(
+ void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ ((PlatformRemoteiOS::SDKDirectoryInfoCollection *)baton)
+ ->push_back(PlatformRemoteiOS::SDKDirectoryInfo(file_spec));
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+bool PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded() {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (m_sdk_directory_infos.empty()) {
+ // A --sysroot option was supplied - add it to our list of SDKs to check
+ if (m_sdk_sysroot) {
+ FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString(), true);
+ const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec);
+ m_sdk_directory_infos.push_back(sdk_sysroot_directory_info);
+ if (log) {
+ log->Printf("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded added "
+ "--sysroot SDK directory %s",
+ m_sdk_sysroot.GetCString());
+ }
+ return true;
+ }
+ const char *device_support_dir = GetDeviceSupportDirectory();
+ if (log) {
+ log->Printf("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded Got "
+ "DeviceSupport directory %s",
+ device_support_dir);
+ }
+ if (device_support_dir) {
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = false;
+
+ SDKDirectoryInfoCollection builtin_sdk_directory_infos;
+ FileSpec::EnumerateDirectory(m_device_support_directory.c_str(),
+ find_directories, find_files, find_other,
+ GetContainedFilesIntoVectorOfStringsCallback,
+ &builtin_sdk_directory_infos);
+
+ // Only add SDK directories that have symbols in them, some SDKs only
+ // contain
+ // developer disk images and no symbols, so they aren't useful to us.
+ FileSpec sdk_symbols_symlink_fspec;
+ for (const auto &sdk_directory_info : builtin_sdk_directory_infos) {
+ sdk_symbols_symlink_fspec = sdk_directory_info.directory;
+ sdk_symbols_symlink_fspec.AppendPathComponent("Symbols");
+ if (sdk_symbols_symlink_fspec.Exists()) {
+ m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log) {
+ log->Printf("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded "
+ "added builtin SDK directory %s",
+ sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
+ }
+ }
+
+ const uint32_t num_installed = m_sdk_directory_infos.size();
+ FileSpec local_sdk_cache("~/Library/Developer/Xcode/iOS DeviceSupport",
+ true);
+ if (local_sdk_cache.Exists()) {
+ if (log) {
+ log->Printf("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded "
+ "searching %s for additional SDKs",
+ local_sdk_cache.GetPath().c_str());
+ }
+ char path[PATH_MAX];
+ if (local_sdk_cache.GetPath(path, sizeof(path))) {
+ FileSpec::EnumerateDirectory(
+ path, find_directories, find_files, find_other,
+ GetContainedFilesIntoVectorOfStringsCallback,
+ &m_sdk_directory_infos);
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // First try for an exact match of major, minor and update
+ for (uint32_t i = num_installed; i < num_sdk_infos; ++i) {
+ m_sdk_directory_infos[i].user_cached = true;
+ if (log) {
+ log->Printf("PlatformRemoteiOS::UpdateSDKDirectoryInfosIfNeeded "
+ "user SDK directory %s",
+ m_sdk_directory_infos[i].directory.GetPath().c_str());
}
+ }
}
+ }
}
- return !m_sdk_directory_infos.empty();
+ }
+ return !m_sdk_directory_infos.empty();
}
const PlatformRemoteiOS::SDKDirectoryInfo *
-PlatformRemoteiOS::GetSDKDirectoryForCurrentOSVersion ()
-{
- uint32_t i;
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+PlatformRemoteiOS::GetSDKDirectoryForCurrentOSVersion() {
+ uint32_t i;
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // Check to see if the user specified a build string. If they did, then
- // be sure to match it.
- std::vector<bool> check_sdk_info(num_sdk_infos, true);
- ConstString build(m_sdk_build);
- if (build)
- {
- for (i=0; i<num_sdk_infos; ++i)
- check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
- }
-
- // If we are connected we can find the version of the OS the platform
- // us running on and select the right SDK
- uint32_t major, minor, update;
- if (GetOSVersion(major, minor, update))
- {
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- // First try for an exact match of major, minor and update
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major &&
- m_sdk_directory_infos[i].version_minor == minor &&
- m_sdk_directory_infos[i].version_update == update)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- // First try for an exact match of major and minor
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major &&
- m_sdk_directory_infos[i].version_minor == minor)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- // Lastly try to match of major version only..
- for (i=0; i<num_sdk_infos; ++i)
- {
- if (check_sdk_info[i])
- {
- if (m_sdk_directory_infos[i].version_major == major)
- {
- return &m_sdk_directory_infos[i];
- }
- }
- }
- }
- }
- else if (build)
- {
- // No version, just a build number, search for the first one that matches
- for (i=0; i<num_sdk_infos; ++i)
- if (check_sdk_info[i])
- return &m_sdk_directory_infos[i];
- }
+ // Check to see if the user specified a build string. If they did, then
+ // be sure to match it.
+ std::vector<bool> check_sdk_info(num_sdk_infos, true);
+ ConstString build(m_sdk_build);
+ if (build) {
+ for (i = 0; i < num_sdk_infos; ++i)
+ check_sdk_info[i] = m_sdk_directory_infos[i].build == build;
}
- return NULL;
-}
-const PlatformRemoteiOS::SDKDirectoryInfo *
-PlatformRemoteiOS::GetSDKDirectoryForLatestOSVersion ()
-{
- const PlatformRemoteiOS::SDKDirectoryInfo *result = NULL;
- if (UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // If we are connected we can find the version of the OS the platform
+ // us running on and select the right SDK
+ uint32_t major, minor, update;
+ if (GetOSVersion(major, minor, update)) {
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
// First try for an exact match of major, minor and update
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- if (sdk_dir_info.version_major != UINT32_MAX)
- {
- if (result == NULL || sdk_dir_info.version_major > result->version_major)
- {
- result = &sdk_dir_info;
- }
- else if (sdk_dir_info.version_major == result->version_major)
- {
- if (sdk_dir_info.version_minor > result->version_minor)
- {
- result = &sdk_dir_info;
- }
- else if (sdk_dir_info.version_minor == result->version_minor)
- {
- if (sdk_dir_info.version_update > result->version_update)
- {
- result = &sdk_dir_info;
- }
- }
- }
- }
- }
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major &&
+ m_sdk_directory_infos[i].version_minor == minor &&
+ m_sdk_directory_infos[i].version_update == update) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ // First try for an exact match of major and minor
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major &&
+ m_sdk_directory_infos[i].version_minor == minor) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ // Lastly try to match of major version only..
+ for (i = 0; i < num_sdk_infos; ++i) {
+ if (check_sdk_info[i]) {
+ if (m_sdk_directory_infos[i].version_major == major) {
+ return &m_sdk_directory_infos[i];
+ }
+ }
+ }
+ }
+ } else if (build) {
+ // No version, just a build number, search for the first one that matches
+ for (i = 0; i < num_sdk_infos; ++i)
+ if (check_sdk_info[i])
+ return &m_sdk_directory_infos[i];
}
- return result;
+ }
+ return NULL;
}
-
-
-const char *
-PlatformRemoteiOS::GetDeviceSupportDirectory()
-{
- if (m_device_support_directory.empty())
- {
- const char *device_support_dir = GetDeveloperDirectory();
- if (device_support_dir)
- {
- m_device_support_directory.assign (device_support_dir);
- m_device_support_directory.append ("/Platforms/iPhoneOS.platform/DeviceSupport");
- }
- else
- {
- // 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_device_support_directory.assign (1, '\0');
- }
- }
- // We should have put a single NULL character into m_device_support_directory
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory.empty() == false);
- if (m_device_support_directory[0])
- return m_device_support_directory.c_str();
- return NULL;
-}
-
-
-const char *
-PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion()
-{
- if (m_sdk_sysroot)
- return m_sdk_sysroot.GetCString();
-
- if (m_device_support_directory_for_os_version.empty())
- {
- const PlatformRemoteiOS::SDKDirectoryInfo *sdk_dir_info = GetSDKDirectoryForCurrentOSVersion ();
- if (sdk_dir_info == NULL)
- sdk_dir_info = GetSDKDirectoryForLatestOSVersion ();
- if (sdk_dir_info)
- {
- char path[PATH_MAX];
- if (sdk_dir_info->directory.GetPath(path, sizeof(path)))
- {
- m_device_support_directory_for_os_version = path;
- return m_device_support_directory_for_os_version.c_str();
- }
- }
- else
- {
- // 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_device_support_directory_for_os_version.assign (1, '\0');
- }
- }
- // We should have put a single NULL character into m_device_support_directory_for_os_version
- // or it should have a valid path if the code gets here
- assert (m_device_support_directory_for_os_version.empty() == false);
- if (m_device_support_directory_for_os_version[0])
+const PlatformRemoteiOS::SDKDirectoryInfo *
+PlatformRemoteiOS::GetSDKDirectoryForLatestOSVersion() {
+ const PlatformRemoteiOS::SDKDirectoryInfo *result = NULL;
+ if (UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ // First try for an exact match of major, minor and update
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (sdk_dir_info.version_major != UINT32_MAX) {
+ if (result == NULL ||
+ sdk_dir_info.version_major > result->version_major) {
+ result = &sdk_dir_info;
+ } else if (sdk_dir_info.version_major == result->version_major) {
+ if (sdk_dir_info.version_minor > result->version_minor) {
+ result = &sdk_dir_info;
+ } else if (sdk_dir_info.version_minor == result->version_minor) {
+ if (sdk_dir_info.version_update > result->version_update) {
+ result = &sdk_dir_info;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+const char *PlatformRemoteiOS::GetDeviceSupportDirectory() {
+ if (m_device_support_directory.empty()) {
+ const char *device_support_dir = GetDeveloperDirectory();
+ if (device_support_dir) {
+ m_device_support_directory.assign(device_support_dir);
+ m_device_support_directory.append(
+ "/Platforms/iPhoneOS.platform/DeviceSupport");
+ } else {
+ // 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_device_support_directory.assign(1, '\0');
+ }
+ }
+ // We should have put a single NULL character into m_device_support_directory
+ // or it should have a valid path if the code gets here
+ assert(m_device_support_directory.empty() == false);
+ if (m_device_support_directory[0])
+ return m_device_support_directory.c_str();
+ return NULL;
+}
+
+const char *PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion() {
+ if (m_sdk_sysroot)
+ return m_sdk_sysroot.GetCString();
+
+ if (m_device_support_directory_for_os_version.empty()) {
+ const PlatformRemoteiOS::SDKDirectoryInfo *sdk_dir_info =
+ GetSDKDirectoryForCurrentOSVersion();
+ if (sdk_dir_info == NULL)
+ sdk_dir_info = GetSDKDirectoryForLatestOSVersion();
+ if (sdk_dir_info) {
+ char path[PATH_MAX];
+ if (sdk_dir_info->directory.GetPath(path, sizeof(path))) {
+ m_device_support_directory_for_os_version = path;
return m_device_support_directory_for_os_version.c_str();
- return NULL;
-}
-
-uint32_t
-PlatformRemoteiOS::FindFileInAllSDKs (const char *platform_file_path,
- FileSpecList &file_list)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
- if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded())
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- lldb_private::FileSpec local_file;
- // First try for an exact match of major, minor and update
- for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path,
- sdk_idx,
- local_file))
- {
- file_list.Append(local_file);
- }
+ }
+ } else {
+ // 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_device_support_directory_for_os_version.assign(1, '\0');
+ }
+ }
+ // We should have put a single NULL character into
+ // m_device_support_directory_for_os_version
+ // or it should have a valid path if the code gets here
+ assert(m_device_support_directory_for_os_version.empty() == false);
+ if (m_device_support_directory_for_os_version[0])
+ return m_device_support_directory_for_os_version.c_str();
+ return NULL;
+}
+
+uint32_t PlatformRemoteiOS::FindFileInAllSDKs(const char *platform_file_path,
+ FileSpecList &file_list) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+ LIBLLDB_LOG_VERBOSE);
+ if (platform_file_path && platform_file_path[0] &&
+ UpdateSDKDirectoryInfosIfNeeded()) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ lldb_private::FileSpec local_file;
+ // First try for an exact match of major, minor and update
+ for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) {
+ file_list.Append(local_file);
+ }
+ }
+ }
+ return file_list.GetSize();
+}
+
+bool PlatformRemoteiOS::GetFileInSDK(const char *platform_file_path,
+ uint32_t sdk_idx,
+ lldb_private::FileSpec &local_file) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (sdk_idx < m_sdk_directory_infos.size()) {
+ std::string sdkroot_path =
+ m_sdk_directory_infos[sdk_idx].directory.GetPath();
+ local_file.Clear();
+
+ if (!sdkroot_path.empty() && platform_file_path && platform_file_path[0]) {
+ // We may need to interpose "/Symbols/" or "/Symbols.Internal/" between
+ // the
+ // SDK root directory and the file path.
+
+ const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr};
+ for (size_t i = 0; paths_to_try[i] != nullptr; i++) {
+ local_file.SetFile(sdkroot_path.c_str(), false);
+ if (paths_to_try[i][0] != '\0')
+ local_file.AppendPathComponent(paths_to_try[i]);
+ local_file.AppendPathComponent(platform_file_path);
+ local_file.ResolvePath();
+ if (local_file.Exists()) {
+ if (log)
+ log->Printf("Found a copy of %s in the SDK dir %s/%s",
+ platform_file_path, sdkroot_path.c_str(),
+ paths_to_try[i]);
+ return true;
}
- }
- return file_list.GetSize();
-}
-
-bool
-PlatformRemoteiOS::GetFileInSDK (const char *platform_file_path,
- uint32_t sdk_idx,
- lldb_private::FileSpec &local_file)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- if (sdk_idx < m_sdk_directory_infos.size())
- {
- std::string sdkroot_path = m_sdk_directory_infos[sdk_idx].directory.GetPath();
local_file.Clear();
-
- if (!sdkroot_path.empty() && platform_file_path && platform_file_path[0])
- {
- // We may need to interpose "/Symbols/" or "/Symbols.Internal/" between the
- // SDK root directory and the file path.
-
- const char *paths_to_try[] = { "Symbols", "", "Symbols.Internal", nullptr };
- for (size_t i = 0; paths_to_try[i] != nullptr; i++)
- {
- local_file.SetFile (sdkroot_path.c_str(), false);
- if (paths_to_try[i][0] != '\0')
- local_file.AppendPathComponent (paths_to_try[i]);
- local_file.AppendPathComponent (platform_file_path);
- local_file.ResolvePath();
- if (local_file.Exists())
- {
- if (log)
- log->Printf ("Found a copy of %s in the SDK dir %s/%s", platform_file_path, sdkroot_path.c_str(), paths_to_try[i]);
- return true;
- }
- local_file.Clear();
- }
- }
+ }
}
- return false;
+ }
+ return false;
}
+Error PlatformRemoteiOS::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ Error error;
+ char platform_file_path[PATH_MAX];
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
+ char resolved_path[PATH_MAX];
+
+ const char *os_version_dir = GetDeviceSupportDirectoryForOSVersion();
+ if (os_version_dir) {
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir,
+ platform_file_path);
+
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf("Found a copy of %s in the DeviceSupport dir %s",
+ platform_file_path, os_version_dir);
+ }
+ return error;
+ }
-Error
-PlatformRemoteiOS::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
- Error error;
- char platform_file_path[PATH_MAX];
- if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
- {
- char resolved_path[PATH_MAX];
-
- const char * os_version_dir = GetDeviceSupportDirectoryForOSVersion();
- if (os_version_dir)
- {
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir);
- }
- return error;
- }
-
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/Symbols.Internal/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir);
- }
- return error;
- }
- ::snprintf (resolved_path,
- sizeof(resolved_path),
- "%s/Symbols/%s",
- os_version_dir,
- platform_file_path);
-
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- {
- if (log)
- {
- log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir);
- }
- return error;
- }
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols.Internal/%s",
+ os_version_dir, platform_file_path);
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf(
+ "Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal",
+ platform_file_path, os_version_dir);
}
- local_file = platform_file;
- if (local_file.Exists())
- return error;
-
- error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
- platform_file_path,
- GetPluginName().GetCString());
- }
- else
- {
- error.SetErrorString ("invalid platform file argument");
+ return error;
+ }
+ ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s",
+ os_version_dir, platform_file_path);
+
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists()) {
+ if (log) {
+ log->Printf("Found a copy of %s in the DeviceSupport dir %s/Symbols",
+ platform_file_path, os_version_dir);
+ }
+ return error;
+ }
}
- return error;
-}
+ local_file = platform_file;
+ if (local_file.Exists())
+ return error;
+
+ error.SetErrorStringWithFormat(
+ "unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path, GetPluginName().GetCString());
+ } else {
+ error.SetErrorString("invalid platform file argument");
+ }
+ return error;
+}
+
+Error PlatformRemoteiOS::GetSharedModule(
+ const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
+ // For iOS, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+ LIBLLDB_LOG_VERBOSE);
-Error
-PlatformRemoteiOS::GetSharedModule (const ModuleSpec &module_spec,
- Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- // For iOS, the SDK files are all cached locally on the host
- // system. So first we ask for the file in the cached SDK,
- // then we attempt to get a shared module for the right architecture
- // with the right UUID.
- const FileSpec &platform_file = module_spec.GetFileSpec();
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
-
- Error error;
- char platform_file_path[PATH_MAX];
-
- if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
- {
- ModuleSpec platform_module_spec(module_spec);
+ Error error;
+ char platform_file_path[PATH_MAX];
- UpdateSDKDirectoryInfosIfNeeded();
+ if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
+ ModuleSpec platform_module_spec(module_spec);
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ UpdateSDKDirectoryInfosIfNeeded();
- // If we are connected we migth be able to correctly deduce the SDK directory
- // using the OS build.
- const uint32_t connected_sdk_idx = GetConnectedSDKIndex ();
- if (connected_sdk_idx < num_sdk_infos)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable (platform_module_spec,
- module_sp,
- NULL);
- if (module_sp)
- {
- m_last_module_sdk_idx = connected_sdk_idx;
- error.Clear();
- return error;
- }
- }
- }
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- // Try the last SDK index if it is set as most files from an SDK
- // will tend to be valid in that same SDK.
- if (m_last_module_sdk_idx < num_sdk_infos)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable (platform_module_spec,
- module_sp,
- NULL);
- if (module_sp)
- {
- error.Clear();
- return error;
- }
- }
- }
-
- // First try for an exact match of major, minor and update:
- // If a particalar SDK version was specified via --version or --build, look for a match on disk.
- const SDKDirectoryInfo *current_sdk_info = GetSDKDirectoryForCurrentOSVersion();
- const uint32_t current_sdk_idx = GetSDKIndexBySDKDirectoryInfo(current_sdk_info);
- if (current_sdk_idx < num_sdk_infos && current_sdk_idx != m_last_module_sdk_idx)
- {
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[current_sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, current_sdk_idx, platform_module_spec.GetFileSpec()))
- {
- module_sp.reset();
- error = ResolveExecutable (platform_module_spec,
- module_sp,
- NULL);
- if (module_sp)
- {
- m_last_module_sdk_idx = current_sdk_idx;
- error.Clear();
- return error;
- }
- }
- }
+ // If we are connected we migth be able to correctly deduce the SDK
+ // directory
+ // using the OS build.
+ const uint32_t connected_sdk_idx = GetConnectedSDKIndex();
+ if (connected_sdk_idx < num_sdk_infos) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[connected_sdk_idx]
+ .directory.GetPath()
+ .c_str());
+ }
+ if (GetFileInSDK(platform_file_path, connected_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, NULL);
+ if (module_sp) {
+ m_last_module_sdk_idx = connected_sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // Try the last SDK index if it is set as most files from an SDK
+ // will tend to be valid in that same SDK.
+ if (m_last_module_sdk_idx < num_sdk_infos) {
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[m_last_module_sdk_idx]
+ .directory.GetPath()
+ .c_str());
+ }
+ if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, NULL);
+ if (module_sp) {
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // First try for an exact match of major, minor and update:
+ // If a particalar SDK version was specified via --version or --build, look
+ // for a match on disk.
+ const SDKDirectoryInfo *current_sdk_info =
+ GetSDKDirectoryForCurrentOSVersion();
+ const uint32_t current_sdk_idx =
+ GetSDKIndexBySDKDirectoryInfo(current_sdk_info);
+ if (current_sdk_idx < num_sdk_infos &&
+ current_sdk_idx != m_last_module_sdk_idx) {
+ if (log) {
+ log->Printf(
+ "Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[current_sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, current_sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ module_sp.reset();
+ error = ResolveExecutable(platform_module_spec, module_sp, NULL);
+ if (module_sp) {
+ m_last_module_sdk_idx = current_sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
+ // Second try all SDKs that were found.
+ for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
+ if (m_last_module_sdk_idx == sdk_idx) {
+ // Skip the last module SDK index if we already searched
+ // it above
+ continue;
+ }
+ if (log) {
+ log->Printf("Searching for %s in sdk path %s", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
+ if (GetFileInSDK(platform_file_path, sdk_idx,
+ platform_module_spec.GetFileSpec())) {
+ // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
+
+ error = ResolveExecutable(platform_module_spec, module_sp, NULL);
+ if (module_sp) {
+ // Remember the index of the last SDK that we found a file
+ // in in case the wrong SDK was selected.
+ m_last_module_sdk_idx = sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+ }
+ // Not the module we are looking for... Nothing to see here...
+ module_sp.reset();
+
+ // This may not be an SDK-related module. Try whether we can bring in the
+ // thing to our local cache.
+ error = GetSharedModuleWithLocalCache(module_spec, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ if (error.Success())
+ return error;
- // Second try all SDKs that were found.
- for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
- {
- if (m_last_module_sdk_idx == sdk_idx)
- {
- // Skip the last module SDK index if we already searched
- // it above
- continue;
- }
- if (log)
- {
- log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
- if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec()))
- {
- //printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
-
- error = ResolveExecutable (platform_module_spec, module_sp, NULL);
- if (module_sp)
- {
- // Remember the index of the last SDK that we found a file
- // in in case the wrong SDK was selected.
- m_last_module_sdk_idx = sdk_idx;
- error.Clear();
- return error;
- }
- }
+ // See if the file is present in any of the module_search_paths_ptr
+ // directories.
+ if (!module_sp && module_search_paths_ptr && platform_file) {
+ // create a vector of all the file / directory names in platform_file
+ // e.g. this might be
+ // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ //
+ // We'll need to look in the module_search_paths_ptr directories for
+ // both "UIFoundation" and "UIFoundation.framework" -- most likely the
+ // latter will be the one we find there.
+
+ FileSpec platform_pull_apart(platform_file);
+ std::vector<std::string> path_parts;
+ ConstString unix_root_dir("/");
+ while (true) {
+ ConstString part = platform_pull_apart.GetLastPathComponent();
+ platform_pull_apart.RemoveLastPathComponent();
+ if (part.IsEmpty() || part == unix_root_dir)
+ break;
+ path_parts.push_back(part.AsCString());
+ }
+ const size_t path_parts_size = path_parts.size();
+
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i) {
+ // Create a new FileSpec with this module_search_paths_ptr
+ // plus just the filename ("UIFoundation"), then the parent
+ // dir plus filename ("UIFoundation.framework/UIFoundation")
+ // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
+
+ for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
+ FileSpec path_to_try(module_search_paths_ptr->GetFileSpecAtIndex(i));
+
+ // Add the components backwards. For
+ // .../PrivateFrameworks/UIFoundation.framework/UIFoundation
+ // path_parts is
+ // [0] UIFoundation
+ // [1] UIFoundation.framework
+ // [2] PrivateFrameworks
+ //
+ // and if 'j' is 2, we want to append path_parts[1] and then
+ // path_parts[0], aka
+ // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr
+ // path.
+
+ for (int k = j; k >= 0; --k) {
+ path_to_try.AppendPathComponent(path_parts[k]);
}
- }
- // Not the module we are looking for... Nothing to see here...
- module_sp.reset();
- // This may not be an SDK-related module. Try whether we can bring in the thing to our local cache.
- error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
- if (error.Success())
- return error;
+ if (path_to_try.Exists()) {
+ ModuleSpec new_module_spec(module_spec);
+ new_module_spec.GetFileSpec() = path_to_try;
+ Error new_error(Platform::GetSharedModule(
+ new_module_spec, process, module_sp, NULL, old_module_sp_ptr,
+ did_create_ptr));
- // See if the file is present in any of the module_search_paths_ptr directories.
- if (!module_sp && module_search_paths_ptr && platform_file)
- {
- // create a vector of all the file / directory names in platform_file
- // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
- //
- // We'll need to look in the module_search_paths_ptr directories for
- // both "UIFoundation" and "UIFoundation.framework" -- most likely the
- // latter will be the one we find there.
-
- FileSpec platform_pull_apart (platform_file);
- std::vector<std::string> path_parts;
- ConstString unix_root_dir("/");
- while (true)
- {
- ConstString part = platform_pull_apart.GetLastPathComponent();
- platform_pull_apart.RemoveLastPathComponent();
- if (part.IsEmpty() || part == unix_root_dir)
- break;
- path_parts.push_back (part.AsCString());
- }
- const size_t path_parts_size = path_parts.size();
-
- size_t num_module_search_paths = module_search_paths_ptr->GetSize();
- for (size_t i = 0; i < num_module_search_paths; ++i)
- {
- // Create a new FileSpec with this module_search_paths_ptr
- // plus just the filename ("UIFoundation"), then the parent
- // dir plus filename ("UIFoundation.framework/UIFoundation")
- // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
-
- for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j)
- {
- FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i));
-
- // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation
- // path_parts is
- // [0] UIFoundation
- // [1] UIFoundation.framework
- // [2] PrivateFrameworks
- //
- // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka
- // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path.
-
- for (int k = j; k >= 0; --k)
- {
- path_to_try.AppendPathComponent (path_parts[k]);
- }
-
- if (path_to_try.Exists())
- {
- ModuleSpec new_module_spec (module_spec);
- new_module_spec.GetFileSpec() = path_to_try;
- Error new_error (Platform::GetSharedModule (new_module_spec,
- process,
- module_sp,
- NULL,
- old_module_sp_ptr,
- did_create_ptr));
-
- if (module_sp)
- {
- module_sp->SetPlatformFileSpec (path_to_try);
- return new_error;
- }
- }
- }
+ if (module_sp) {
+ module_sp->SetPlatformFileSpec(path_to_try);
+ return new_error;
+ }
}
+ }
}
+ }
- const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr,
- always_create);
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr, always_create);
- if (module_sp)
- module_sp->SetPlatformFileSpec(platform_file);
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
- return error;
+ return error;
}
-bool
-PlatformRemoteiOS::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- return ARMGetSupportedArchitectureAtIndex (idx, arch);
-}
-
-uint32_t
-PlatformRemoteiOS::GetConnectedSDKIndex ()
-{
- if (IsConnected())
- {
- if (m_connected_module_sdk_idx == UINT32_MAX)
- {
- std::string build;
- if (GetRemoteOSBuildString(build))
- {
- const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
- for (uint32_t i=0; i<num_sdk_infos; ++i)
- {
- const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
- if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""), build.c_str()))
- {
- m_connected_module_sdk_idx = i;
- }
- }
- }
- }
- }
- else
- {
- m_connected_module_sdk_idx = UINT32_MAX;
- }
- return m_connected_module_sdk_idx;
+bool PlatformRemoteiOS::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ return ARMGetSupportedArchitectureAtIndex(idx, arch);
}
-uint32_t
-PlatformRemoteiOS::GetSDKIndexBySDKDirectoryInfo (const SDKDirectoryInfo *sdk_info)
-{
- if (sdk_info == NULL)
- {
- return UINT32_MAX;
- }
+uint32_t PlatformRemoteiOS::GetConnectedSDKIndex() {
+ if (IsConnected()) {
+ if (m_connected_module_sdk_idx == UINT32_MAX) {
+ std::string build;
+ if (GetRemoteOSBuildString(build)) {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i = 0; i < num_sdk_infos; ++i) {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""),
+ build.c_str())) {
+ m_connected_module_sdk_idx = i;
+ }
+ }
+ }
+ }
+ } else {
+ m_connected_module_sdk_idx = UINT32_MAX;
+ }
+ return m_connected_module_sdk_idx;
+}
+
+uint32_t PlatformRemoteiOS::GetSDKIndexBySDKDirectoryInfo(
+ const SDKDirectoryInfo *sdk_info) {
+ if (sdk_info == NULL) {
+ return UINT32_MAX;
+ }
- return sdk_info - &m_sdk_directory_infos[0];
+ return sdk_info - &m_sdk_directory_infos[0];
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Tue Sep 6 15:57:50 2016
@@ -16,152 +16,123 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
#include "PlatformDarwin.h"
+#include "lldb/Host/FileSpec.h"
-class PlatformRemoteiOS : public PlatformDarwin
-{
+class PlatformRemoteiOS : public PlatformDarwin {
public:
- PlatformRemoteiOS ();
+ PlatformRemoteiOS();
+
+ ~PlatformRemoteiOS() override;
+
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override { return GetDescriptionStatic(); }
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ virtual lldb_private::Error
+ GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
- ~PlatformRemoteiOS() override;
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- virtual lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneOS);
- }
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::iPhoneOS);
+ }
protected:
- struct SDKDirectoryInfo
- {
- SDKDirectoryInfo (const lldb_private::FileSpec &sdk_dir_spec);
- lldb_private::FileSpec directory;
- lldb_private::ConstString build;
- uint32_t version_major;
- uint32_t version_minor;
- uint32_t version_update;
- bool user_cached;
- };
-
- typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
-
- SDKDirectoryInfoCollection m_sdk_directory_infos;
- std::string m_device_support_directory;
- std::string m_device_support_directory_for_os_version;
- std::string m_build_update;
- uint32_t m_last_module_sdk_idx;
- uint32_t m_connected_module_sdk_idx;
-
- bool
- UpdateSDKDirectoryInfosIfNeeded();
-
- const char *
- GetDeviceSupportDirectory();
-
- const char *
- GetDeviceSupportDirectoryForOSVersion();
-
- const SDKDirectoryInfo *
- GetSDKDirectoryForLatestOSVersion ();
-
- const SDKDirectoryInfo *
- GetSDKDirectoryForCurrentOSVersion ();
-
- static lldb_private::FileSpec::EnumerateDirectoryResult
- GetContainedFilesIntoVectorOfStringsCallback (void *baton,
- lldb_private::FileSpec::FileType file_type,
- const lldb_private::FileSpec &file_spec);
-
- uint32_t
- FindFileInAllSDKs (const char *platform_file_path,
- lldb_private::FileSpecList &file_list);
-
- bool
- GetFileInSDK (const char *platform_file_path,
- uint32_t sdk_idx,
- lldb_private::FileSpec &local_file);
-
- uint32_t
- FindFileInAllSDKs (const lldb_private::FileSpec &platform_file,
- lldb_private::FileSpecList &file_list);
-
- uint32_t
- GetConnectedSDKIndex ();
-
- // Get index of SDK in SDKDirectoryInfoCollection by its pointer and return UINT32_MAX if that SDK not found.
- uint32_t
- GetSDKIndexBySDKDirectoryInfo (const SDKDirectoryInfo *sdk_info);
+ struct SDKDirectoryInfo {
+ SDKDirectoryInfo(const lldb_private::FileSpec &sdk_dir_spec);
+ lldb_private::FileSpec directory;
+ lldb_private::ConstString build;
+ uint32_t version_major;
+ uint32_t version_minor;
+ uint32_t version_update;
+ bool user_cached;
+ };
+
+ typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
+
+ SDKDirectoryInfoCollection m_sdk_directory_infos;
+ std::string m_device_support_directory;
+ std::string m_device_support_directory_for_os_version;
+ std::string m_build_update;
+ uint32_t m_last_module_sdk_idx;
+ uint32_t m_connected_module_sdk_idx;
+
+ bool UpdateSDKDirectoryInfosIfNeeded();
+
+ const char *GetDeviceSupportDirectory();
+
+ const char *GetDeviceSupportDirectoryForOSVersion();
+
+ const SDKDirectoryInfo *GetSDKDirectoryForLatestOSVersion();
+
+ const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion();
+
+ static lldb_private::FileSpec::EnumerateDirectoryResult
+ GetContainedFilesIntoVectorOfStringsCallback(
+ void *baton, lldb_private::FileSpec::FileType file_type,
+ const lldb_private::FileSpec &file_spec);
+
+ uint32_t FindFileInAllSDKs(const char *platform_file_path,
+ lldb_private::FileSpecList &file_list);
+
+ bool GetFileInSDK(const char *platform_file_path, uint32_t sdk_idx,
+ lldb_private::FileSpec &local_file);
+
+ uint32_t FindFileInAllSDKs(const lldb_private::FileSpec &platform_file,
+ lldb_private::FileSpecList &file_list);
+
+ uint32_t GetConnectedSDKIndex();
+
+ // Get index of SDK in SDKDirectoryInfoCollection by its pointer and return
+ // UINT32_MAX if that SDK not found.
+ uint32_t GetSDKIndexBySDKDirectoryInfo(const SDKDirectoryInfo *sdk_info);
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformRemoteiOS);
+ DISALLOW_COPY_AND_ASSIGN(PlatformRemoteiOS);
};
#endif // liblldb_PlatformRemoteiOS_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- PlatformiOSSimulator.cpp -----------------------------------*- C++ -*-===//
+//===-- PlatformiOSSimulator.cpp -----------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -39,144 +40,122 @@ static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-void
-PlatformiOSSimulator::Initialize ()
-{
- PlatformAppleSimulator::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
- PluginManager::RegisterPlugin (PlatformiOSSimulator::GetPluginNameStatic(),
- PlatformiOSSimulator::GetDescriptionStatic(),
- PlatformiOSSimulator::CreateInstance);
- }
+void PlatformiOSSimulator::Initialize() {
+ PlatformAppleSimulator::Initialize();
+
+ if (g_initialize_count++ == 0) {
+ PluginManager::RegisterPlugin(PlatformiOSSimulator::GetPluginNameStatic(),
+ PlatformiOSSimulator::GetDescriptionStatic(),
+ PlatformiOSSimulator::CreateInstance);
+ }
}
-void
-PlatformiOSSimulator::Terminate ()
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
- PluginManager::UnregisterPlugin (PlatformiOSSimulator::CreateInstance);
- }
+void PlatformiOSSimulator::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformiOSSimulator::CreateInstance);
}
-
- PlatformAppleSimulator::Terminate ();
+ }
+
+ PlatformAppleSimulator::Terminate();
}
-PlatformSP
-PlatformiOSSimulator::CreateInstance (bool force, const ArchSpec *arch)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- if (log)
- {
- const char *arch_name;
- if (arch && arch->GetArchitectureName ())
- arch_name = arch->GetArchitectureName ();
- else
- arch_name = "<null>";
-
- const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
-
- log->Printf ("PlatformiOSSimulator::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
- }
-
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- switch (arch->GetMachine())
- {
- case llvm::Triple::x86_64:
- case llvm::Triple::x86:
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getVendor())
- {
- case llvm::Triple::Apple:
- create = true;
- break;
-
+PlatformSP PlatformiOSSimulator::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
+
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
+
+ log->Printf("PlatformiOSSimulator::%s(force=%s, arch={%s,%s})",
+ __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+ }
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ switch (arch->GetMachine()) {
+ case llvm::Triple::x86_64:
+ case llvm::Triple::x86: {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor()) {
+ case llvm::Triple::Apple:
+ create = true;
+ break;
+
#if defined(__APPLE__)
- // Only accept "unknown" for the vendor if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
+ // Only accept "unknown" for the vendor if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
#endif
- default:
- break;
- }
-
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::Darwin: // Deprecated, but still support Darwin for historical reasons
- case llvm::Triple::MacOSX:
- case llvm::Triple::IOS: // IOS is not used for simulator triples, but accept it just in case
- break;
-
+ default:
+ break;
+ }
+
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
+ // historical reasons
+ case llvm::Triple::MacOSX:
+ case llvm::Triple::IOS: // IOS is not used for simulator triples, but
+ // accept it just in case
+ break;
+
#if defined(__APPLE__)
- // Only accept "unknown" for the OS if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
+ // Only accept "unknown" for the OS if the host is Apple and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
#endif
- default:
- create = false;
- break;
- }
- }
- }
- break;
- default:
- break;
- }
+ default:
+ create = false;
+ break;
+ }
+ }
+ } break;
+ default:
+ break;
}
- if (create)
- {
- if (log)
- log->Printf ("PlatformiOSSimulator::%s() creating platform", __FUNCTION__);
-
- return PlatformSP(new PlatformiOSSimulator ());
- }
-
+ }
+ if (create) {
if (log)
- log->Printf ("PlatformiOSSimulator::%s() aborting creation of platform", __FUNCTION__);
+ log->Printf("PlatformiOSSimulator::%s() creating platform", __FUNCTION__);
- return PlatformSP();
-}
+ return PlatformSP(new PlatformiOSSimulator());
+ }
+ if (log)
+ log->Printf("PlatformiOSSimulator::%s() aborting creation of platform",
+ __FUNCTION__);
-lldb_private::ConstString
-PlatformiOSSimulator::GetPluginNameStatic ()
-{
- static ConstString g_name("ios-simulator");
- return g_name;
+ return PlatformSP();
}
-const char *
-PlatformiOSSimulator::GetDescriptionStatic()
-{
- return "iOS simulator platform plug-in.";
+lldb_private::ConstString PlatformiOSSimulator::GetPluginNameStatic() {
+ static ConstString g_name("ios-simulator");
+ return g_name;
}
+const char *PlatformiOSSimulator::GetDescriptionStatic() {
+ return "iOS simulator platform plug-in.";
+}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformiOSSimulator::PlatformiOSSimulator () :
-PlatformAppleSimulator (),
-m_sdk_dir_mutex (),
-m_sdk_directory (),
-m_build_update ()
-{
-}
+PlatformiOSSimulator::PlatformiOSSimulator()
+ : PlatformAppleSimulator(), m_sdk_dir_mutex(), m_sdk_directory(),
+ m_build_update() {}
//------------------------------------------------------------------
/// Destructor.
@@ -184,321 +163,261 @@ m_build_update ()
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformiOSSimulator::~PlatformiOSSimulator()
-{
-}
+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);
+ else
+ strm.PutCString(" SDK Path: error: unable to locate SDK\n");
+ PlatformAppleSimulator::GetStatus(strm);
+}
+
+Error PlatformiOSSimulator::ResolveExecutable(
+ const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ ModuleSpec resolved_module_spec(module_spec);
+
+ // If we have "ls" as the exe_file, resolve the executable loation based on
+ // the current path variables
+ // TODO: resolve bare executables in the Platform SDK
+ // if (!resolved_exe_file.Exists())
+ // resolved_exe_file.ResolveExecutableLocation ();
+
+ // Resolve any executable within a bundle on MacOSX
+ // TODO: verify that this handles shallow bundles, if not then implement one
+ // ourselves
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact ARM slice wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ ArchSpec platform_arch;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ // Only match x86 with x86 and x86_64 with x86_64...
+ if (!module_spec.GetArchitecture().IsValid() ||
+ module_spec.GetArchitecture().GetCore() ==
+ resolved_module_spec.GetArchitecture().GetCore()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ NULL, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(platform_arch.GetArchitectureName());
+ }
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat("'%s' does not exist",
+ module_spec.GetFileSpec().GetPath().c_str());
+ }
-void
-PlatformiOSSimulator::GetStatus (Stream &strm)
-{
- Platform::GetStatus (strm);
- const char *sdk_directory = GetSDKDirectoryAsCString();
- if (sdk_directory)
- strm.Printf (" SDK Path: \"%s\"\n", sdk_directory);
- else
- strm.PutCString (" SDK Path: error: unable to locate SDK\n");
- PlatformAppleSimulator::GetStatus(strm);
-}
-
-
-Error
-PlatformiOSSimulator::ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- ModuleSpec resolved_module_spec(module_spec);
-
- // If we have "ls" as the exe_file, resolve the executable loation based on
- // the current path variables
- // TODO: resolve bare executables in the Platform SDK
- // if (!resolved_exe_file.Exists())
- // resolved_exe_file.ResolveExecutableLocation ();
-
- // Resolve any executable within a bundle on MacOSX
- // TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact ARM slice wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- ArchSpec platform_arch;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- // Only match x86 with x86 and x86_64 with x86_64...
- if (!module_spec.GetArchitecture().IsValid() || module_spec.GetArchitecture().GetCore() == resolved_module_spec.GetArchitecture().GetCore())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- NULL,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (platform_arch.GetArchitectureName());
- }
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- module_spec.GetFileSpec().GetPath().c_str());
- }
-
- return error;
+ return error;
}
static FileSpec::EnumerateDirectoryResult
-EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const FileSpec &file_spec)
-{
- if (file_type == FileSpec::eFileTypeDirectory)
- {
- const char *filename = file_spec.GetFilename().GetCString();
- if (filename && strncmp(filename, "iPhoneSimulator", strlen ("iPhoneSimulator")) == 0)
- {
- ::snprintf ((char *)baton, PATH_MAX, "%s", filename);
- return FileSpec::eEnumerateDirectoryResultQuit;
- }
- }
- return FileSpec::eEnumerateDirectoryResultNext;
-}
-
-
-
-const char *
-PlatformiOSSimulator::GetSDKDirectoryAsCString()
-{
- std::lock_guard<std::mutex> guard(m_sdk_dir_mutex);
- if (m_sdk_directory.empty())
- {
- const char *developer_dir = GetDeveloperDirectory();
- if (developer_dir)
- {
- 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);
- FileSpec simulator_sdk_spec;
- bool find_directories = true;
- bool find_files = false;
- bool find_other = false;
- FileSpec::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])
+EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
+ const FileSpec &file_spec) {
+ if (file_type == FileSpec::eFileTypeDirectory) {
+ const char *filename = file_spec.GetFilename().GetCString();
+ if (filename &&
+ strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) {
+ ::snprintf((char *)baton, PATH_MAX, "%s", filename);
+ return FileSpec::eEnumerateDirectoryResultQuit;
+ }
+ }
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
+const char *PlatformiOSSimulator::GetSDKDirectoryAsCString() {
+ std::lock_guard<std::mutex> guard(m_sdk_dir_mutex);
+ if (m_sdk_directory.empty()) {
+ const char *developer_dir = GetDeveloperDirectory();
+ if (developer_dir) {
+ 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);
+ FileSpec simulator_sdk_spec;
+ bool find_directories = true;
+ bool find_files = false;
+ bool find_other = false;
+ FileSpec::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();
- return NULL;
-}
-
-Error
-PlatformiOSSimulator::GetSymbolFile (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- Error error;
- char platform_file_path[PATH_MAX];
- 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);
-
- // First try in the SDK and see if the file is in there
- local_file.SetFile(resolved_path, true);
- if (local_file.Exists())
- return error;
-
- // Else fall back to the actual path itself
- local_file.SetFile(platform_file_path, true);
- if (local_file.Exists())
- return error;
-
- }
- error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'",
- platform_file_path,
- GetPluginName().GetCString());
- }
- else
- {
- error.SetErrorString ("invalid platform file argument");
+ }
}
- return error;
-}
+ // 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;
+}
+
+Error PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ Error error;
+ char platform_file_path[PATH_MAX];
+ 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);
+
+ // First try in the SDK and see if the file is in there
+ local_file.SetFile(resolved_path, true);
+ if (local_file.Exists())
+ return error;
+
+ // Else fall back to the actual path itself
+ local_file.SetFile(platform_file_path, true);
+ if (local_file.Exists())
+ return error;
+ }
+ error.SetErrorStringWithFormat(
+ "unable to locate a platform file for '%s' in platform '%s'",
+ platform_file_path, GetPluginName().GetCString());
+ } else {
+ error.SetErrorString("invalid platform file argument");
+ }
+ return error;
+}
+
+Error PlatformiOSSimulator::GetSharedModule(
+ const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
+ // For iOS, the SDK files are all cached locally on the host
+ // system. So first we ask for the file in the cached SDK,
+ // then we attempt to get a shared module for the right architecture
+ // with the right UUID.
+ Error error;
+ ModuleSpec platform_module_spec(module_spec);
+ const FileSpec &platform_file = module_spec.GetFileSpec();
+ error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
+ platform_module_spec.GetFileSpec());
+ if (error.Success()) {
+ error = ResolveExecutable(platform_module_spec, module_sp,
+ module_search_paths_ptr);
+ } else {
+ const bool always_create = false;
+ error = ModuleList::GetSharedModule(
+ module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+ did_create_ptr, always_create);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(platform_file);
-Error
-PlatformiOSSimulator::GetSharedModule (const ModuleSpec &module_spec,
- Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- // For iOS, the SDK files are all cached locally on the host
- // system. So first we ask for the file in the cached SDK,
- // then we attempt to get a shared module for the right architecture
- // with the right UUID.
- Error error;
- ModuleSpec platform_module_spec (module_spec);
- const FileSpec &platform_file = module_spec.GetFileSpec();
- error = GetSymbolFile (platform_file, module_spec.GetUUIDPtr(), platform_module_spec.GetFileSpec());
- if (error.Success())
- {
- error = ResolveExecutable (platform_module_spec, module_sp, module_search_paths_ptr);
- }
- else
- {
- const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr,
- always_create);
-
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(platform_file);
-
- return error;
+ return error;
}
-
uint32_t
-PlatformiOSSimulator::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- ProcessInstanceInfoList all_osx_process_infos;
- // First we get all OSX processes
- const uint32_t n = Host::FindProcesses (match_info, all_osx_process_infos);
-
- // Now we filter them down to only the iOS triples
- for (uint32_t i=0; i<n; ++i)
- {
- const ProcessInstanceInfo &proc_info = all_osx_process_infos.GetProcessInfoAtIndex(i);
- if (proc_info.GetArchitecture().GetTriple().getOS() == llvm::Triple::IOS) {
- process_infos.Append(proc_info);
- }
- }
- return process_infos.GetSize();
-}
-
-bool
-PlatformiOSSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- static const ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
- static const ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64));
-
- if (idx == 0)
- {
- arch = platform_arch;
- if (arch.IsValid())
- {
- arch.GetTriple().setOS (llvm::Triple::IOS);
- return true;
- }
- }
- else
- {
- if (platform_arch.IsExactMatch(platform_arch64))
- {
- // This macosx platform supports both 32 and 64 bit.
- if (idx == 1)
- {
- // 32/64: return "x86_64-apple-macosx" for architecture 1
- arch = platform_arch64;
- return true;
- }
- else if (idx == 2 || idx == 3)
- {
- arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
- if (arch.IsValid())
- {
- if (idx == 2)
- arch.GetTriple().setOS (llvm::Triple::IOS);
- // 32/64: return "i386-apple-ios" for architecture 2
- // 32/64: return "i386-apple-macosx" for architecture 3
- return true;
- }
- }
- }
- else if (idx == 1)
- {
- // This macosx platform supports only 32 bit, so return the *-apple-macosx version
- arch = platform_arch;
- return true;
- }
+PlatformiOSSimulator::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ ProcessInstanceInfoList all_osx_process_infos;
+ // First we get all OSX processes
+ const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
+
+ // Now we filter them down to only the iOS triples
+ for (uint32_t i = 0; i < n; ++i) {
+ const ProcessInstanceInfo &proc_info =
+ all_osx_process_infos.GetProcessInfoAtIndex(i);
+ if (proc_info.GetArchitecture().GetTriple().getOS() == llvm::Triple::IOS) {
+ process_infos.Append(proc_info);
+ }
+ }
+ return process_infos.GetSize();
+}
+
+bool PlatformiOSSimulator::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ static const ArchSpec platform_arch(
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
+ static const ArchSpec platform_arch64(
+ HostInfo::GetArchitecture(HostInfo::eArchKind64));
+
+ if (idx == 0) {
+ arch = platform_arch;
+ if (arch.IsValid()) {
+ arch.GetTriple().setOS(llvm::Triple::IOS);
+ return true;
+ }
+ } else {
+ if (platform_arch.IsExactMatch(platform_arch64)) {
+ // This macosx platform supports both 32 and 64 bit.
+ if (idx == 1) {
+ // 32/64: return "x86_64-apple-macosx" for architecture 1
+ arch = platform_arch64;
+ return true;
+ } else if (idx == 2 || idx == 3) {
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ if (arch.IsValid()) {
+ if (idx == 2)
+ arch.GetTriple().setOS(llvm::Triple::IOS);
+ // 32/64: return "i386-apple-ios" for architecture 2
+ // 32/64: return "i386-apple-macosx" for architecture 3
+ return true;
+ }
+ }
+ } else if (idx == 1) {
+ // This macosx platform supports only 32 bit, so return the *-apple-macosx
+ // version
+ arch = platform_arch;
+ return true;
}
- return false;
+ }
+ return false;
}
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h Tue Sep 6 15:57:50 2016
@@ -19,100 +19,81 @@
// Project includes
#include "PlatformAppleSimulator.h"
-class PlatformiOSSimulator : public PlatformAppleSimulator
-{
+class PlatformiOSSimulator : public PlatformAppleSimulator {
public:
- PlatformiOSSimulator ();
-
- ~PlatformiOSSimulator() override;
-
- //------------------------------------------------------------
- // Class Functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetDescriptionStatic();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- lldb_private::Error
- ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic();
- }
-
- void
- GetStatus (lldb_private::Stream &strm) override;
-
- virtual lldb_private::Error
- GetSymbolFile (const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid_ptr,
- lldb_private::FileSpec &local_file);
-
- lldb_private::Error
- GetSharedModule (const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- uint32_t
- FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx,
- lldb_private::ArchSpec &arch) override;
-
- void
- AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override
- {
- return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(target, options, PlatformDarwin::SDKType::iPhoneSimulator);
- }
-
+ PlatformiOSSimulator();
+
+ ~PlatformiOSSimulator() override;
+
+ //------------------------------------------------------------
+ // Class Functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ lldb_private::Error ResolveExecutable(
+ const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ const char *GetDescription() override { return GetDescriptionStatic(); }
+
+ void GetStatus(lldb_private::Stream &strm) override;
+
+ virtual lldb_private::Error
+ GetSymbolFile(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid_ptr,
+ lldb_private::FileSpec &local_file);
+
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
+
+ uint32_t
+ FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
+
+ void
+ AddClangModuleCompilationOptions(lldb_private::Target *target,
+ std::vector<std::string> &options) override {
+ return PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
+ target, options, PlatformDarwin::SDKType::iPhoneSimulator);
+ }
+
protected:
- std::mutex m_sdk_dir_mutex;
- std::string m_sdk_directory;
- std::string m_build_update;
-
- const char *
- GetSDKDirectoryAsCString();
-
+ std::mutex m_sdk_dir_mutex;
+ std::string m_sdk_directory;
+ std::string m_build_update;
+
+ const char *GetSDKDirectoryAsCString();
+
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformiOSSimulator);
+ DISALLOW_COPY_AND_ASSIGN(PlatformiOSSimulator);
};
#endif // liblldb_PlatformiOSSimulator_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- PlatformiOSSimulatorCoreSimulatorSupport.h ----------------*- C++ -*-===//
+//===-- PlatformiOSSimulatorCoreSimulatorSupport.h ----------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,8 +14,8 @@
// C Includes
// C++ Includes
#include <functional>
-#include <string>
#include <ostream>
+#include <string>
#include <vector>
// Other libraries and framework includes
#ifdef __APPLE__
@@ -31,285 +32,194 @@ typedef void *id;
#include "llvm/ADT/Optional.h"
// And now the actual magic
-namespace CoreSimulatorSupport
-{
- class Process
- {
- public:
- lldb::pid_t
- GetPID ()
- {
- return m_pid;
- }
-
- explicit operator bool ()
- {
- return m_pid != LLDB_INVALID_PROCESS_ID;
- }
-
- lldb_private::Error
- GetError ()
- {
- return m_error;
- }
-
- private:
- Process (lldb::pid_t p);
-
- Process(lldb_private::Error error);
-
- Process (lldb::pid_t p, lldb_private::Error error);
-
- lldb::pid_t m_pid;
- lldb_private::Error m_error;
-
- friend class Device;
- };
-
- class ModelIdentifier {
- public:
- ModelIdentifier (const std::string& mi);
- ModelIdentifier ();
-
- explicit operator bool () const
- {
- return !m_versions.empty();
- }
-
- size_t
- GetNumVersions () const
- {
- return m_versions.size();
- }
-
- unsigned int
- GetVersionAtIndex (size_t idx) const
- {
- return m_versions[idx];
- }
-
- std::string
- GetFamily () const
- {
- return m_family.c_str();
- }
-
- private:
- std::string m_family;
- std::vector<unsigned int> m_versions;
- };
-
- class DeviceType
- {
- public:
- enum class ProductFamilyID : int32_t
- {
- iPhone = 1,
- iPad = 2,
- appleTV = 3,
- appleWatch = 4
- };
-
- DeviceType ();
-
- DeviceType (id d);
-
- explicit operator bool ();
-
- std::string
- GetName ();
-
- lldb_private::ConstString
- GetIdentifier ();
-
- ModelIdentifier
- GetModelIdentifier ();
-
- lldb_private::ConstString
- GetProductFamily ();
-
- ProductFamilyID
- GetProductFamilyID ();
-
- private:
- id m_dev;
- llvm::Optional<ModelIdentifier> m_model_identifier;
- };
-
- class OSVersion {
- public:
- OSVersion (const std::string& ver,
- const std::string& build);
-
- OSVersion ();
-
- explicit operator bool () const
- {
- return !m_versions.empty();
- }
-
- size_t
- GetNumVersions () const
- {
- return m_versions.size();
- }
-
- unsigned int
- GetVersionAtIndex (size_t idx) const
- {
- return m_versions[idx];
- }
-
- const char*
- GetBuild () const
- {
- return m_build.c_str();
- }
-
- private:
- std::vector<unsigned int> m_versions;
- std::string m_build;
- };
-
- class DeviceRuntime
- {
- public:
- DeviceRuntime ();
-
- DeviceRuntime (id d);
-
- explicit operator bool ();
-
- OSVersion
- GetVersion ();
-
- bool
- IsAvailable ();
-
- private:
- id m_dev;
- llvm::Optional<OSVersion> m_os_version;
- };
-
- class Device
- {
- private:
- typedef unsigned long int NSUInteger;
-
- public:
- enum class State : NSUInteger
- {
- Creating,
- Shutdown,
- Booting,
- Booted,
- ShuttingDown
- };
-
- Device ();
-
- Device (id d);
-
- explicit operator bool ();
-
- std::string
- GetName () const;
-
- DeviceType
- GetDeviceType ();
-
- DeviceRuntime
- GetDeviceRuntime ();
-
- State
- GetState ();
-
- bool
- Boot (lldb_private::Error &err);
-
- bool
- Shutdown (lldb_private::Error &err);
-
- std::string
- GetUDID () const;
-
- Process
- Spawn (lldb_private::ProcessLaunchInfo& launch_info);
-
- private:
- id m_dev;
- llvm::Optional<DeviceType> m_dev_type;
- llvm::Optional<DeviceRuntime> m_dev_runtime;
-
- friend class DeviceSet;
- };
-
- bool
- operator > (const OSVersion& lhs,
- const OSVersion& rhs);
-
- bool
- operator > (const ModelIdentifier& lhs,
- const ModelIdentifier& rhs);
-
- bool
- operator < (const OSVersion& lhs,
- const OSVersion& rhs);
-
- bool
- operator < (const ModelIdentifier& lhs,
- const ModelIdentifier& rhs);
-
- bool
- operator == (const OSVersion& lhs,
- const OSVersion& rhs);
-
- bool
- operator == (const ModelIdentifier& lhs,
- const ModelIdentifier& rhs);
-
- bool
- operator != (const OSVersion& lhs,
- const OSVersion& rhs);
-
- bool
- operator != (const ModelIdentifier& lhs,
- const ModelIdentifier& rhs);
-
- class DeviceSet
- {
- public:
- static DeviceSet
- GetAllDevices (const char *developer_dir);
-
- static DeviceSet
- GetAvailableDevices (const char *developer_dir);
-
- size_t
- GetNumDevices ();
-
- Device
- GetDeviceAtIndex (size_t idx);
-
- void
- ForEach (std::function<bool(const Device &)> f);
-
- DeviceSet
- GetDevicesIf (std::function<bool(Device)> f);
-
- DeviceSet
- GetDevices (DeviceType::ProductFamilyID dev_id);
-
- Device
- GetFanciest (DeviceType::ProductFamilyID dev_id);
-
- private:
- DeviceSet (id arr) : m_dev(arr)
- {
- }
-
- id m_dev;
- };
+namespace CoreSimulatorSupport {
+class Process {
+public:
+ lldb::pid_t GetPID() { return m_pid; }
+
+ explicit operator bool() { return m_pid != LLDB_INVALID_PROCESS_ID; }
+
+ lldb_private::Error GetError() { return m_error; }
+
+private:
+ Process(lldb::pid_t p);
+
+ Process(lldb_private::Error error);
+
+ Process(lldb::pid_t p, lldb_private::Error error);
+
+ lldb::pid_t m_pid;
+ lldb_private::Error m_error;
+
+ friend class Device;
+};
+
+class ModelIdentifier {
+public:
+ ModelIdentifier(const std::string &mi);
+ ModelIdentifier();
+
+ explicit operator bool() const { return !m_versions.empty(); }
+
+ size_t GetNumVersions() const { return m_versions.size(); }
+
+ unsigned int GetVersionAtIndex(size_t idx) const { return m_versions[idx]; }
+
+ std::string GetFamily() const { return m_family.c_str(); }
+
+private:
+ std::string m_family;
+ std::vector<unsigned int> m_versions;
+};
+
+class DeviceType {
+public:
+ enum class ProductFamilyID : int32_t {
+ iPhone = 1,
+ iPad = 2,
+ appleTV = 3,
+ appleWatch = 4
+ };
+
+ DeviceType();
+
+ DeviceType(id d);
+
+ explicit operator bool();
+
+ std::string GetName();
+
+ lldb_private::ConstString GetIdentifier();
+
+ ModelIdentifier GetModelIdentifier();
+
+ lldb_private::ConstString GetProductFamily();
+
+ ProductFamilyID GetProductFamilyID();
+
+private:
+ id m_dev;
+ llvm::Optional<ModelIdentifier> m_model_identifier;
+};
+
+class OSVersion {
+public:
+ OSVersion(const std::string &ver, const std::string &build);
+
+ OSVersion();
+
+ explicit operator bool() const { return !m_versions.empty(); }
+
+ size_t GetNumVersions() const { return m_versions.size(); }
+
+ unsigned int GetVersionAtIndex(size_t idx) const { return m_versions[idx]; }
+
+ const char *GetBuild() const { return m_build.c_str(); }
+
+private:
+ std::vector<unsigned int> m_versions;
+ std::string m_build;
+};
+
+class DeviceRuntime {
+public:
+ DeviceRuntime();
+
+ DeviceRuntime(id d);
+
+ explicit operator bool();
+
+ OSVersion GetVersion();
+
+ bool IsAvailable();
+
+private:
+ id m_dev;
+ llvm::Optional<OSVersion> m_os_version;
+};
+
+class Device {
+private:
+ typedef unsigned long int NSUInteger;
+
+public:
+ enum class State : NSUInteger {
+ Creating,
+ Shutdown,
+ Booting,
+ Booted,
+ ShuttingDown
+ };
+
+ Device();
+
+ Device(id d);
+
+ explicit operator bool();
+
+ std::string GetName() const;
+
+ DeviceType GetDeviceType();
+
+ DeviceRuntime GetDeviceRuntime();
+
+ State GetState();
+
+ bool Boot(lldb_private::Error &err);
+
+ bool Shutdown(lldb_private::Error &err);
+
+ std::string GetUDID() const;
+
+ Process Spawn(lldb_private::ProcessLaunchInfo &launch_info);
+
+private:
+ id m_dev;
+ llvm::Optional<DeviceType> m_dev_type;
+ llvm::Optional<DeviceRuntime> m_dev_runtime;
+
+ friend class DeviceSet;
+};
+
+bool operator>(const OSVersion &lhs, const OSVersion &rhs);
+
+bool operator>(const ModelIdentifier &lhs, const ModelIdentifier &rhs);
+
+bool operator<(const OSVersion &lhs, const OSVersion &rhs);
+
+bool operator<(const ModelIdentifier &lhs, const ModelIdentifier &rhs);
+
+bool operator==(const OSVersion &lhs, const OSVersion &rhs);
+
+bool operator==(const ModelIdentifier &lhs, const ModelIdentifier &rhs);
+
+bool operator!=(const OSVersion &lhs, const OSVersion &rhs);
+
+bool operator!=(const ModelIdentifier &lhs, const ModelIdentifier &rhs);
+
+class DeviceSet {
+public:
+ static DeviceSet GetAllDevices(const char *developer_dir);
+
+ static DeviceSet GetAvailableDevices(const char *developer_dir);
+
+ size_t GetNumDevices();
+
+ Device GetDeviceAtIndex(size_t idx);
+
+ void ForEach(std::function<bool(const Device &)> f);
+
+ DeviceSet GetDevicesIf(std::function<bool(Device)> f);
+
+ DeviceSet GetDevices(DeviceType::ProductFamilyID dev_id);
+
+ Device GetFanciest(DeviceType::ProductFamilyID dev_id);
+
+private:
+ DeviceSet(id arr) : m_dev(arr) {}
+
+ id m_dev;
+};
}
-#endif // liblldb_PlatformiOSSimulatorCoreSimulatorSupport_h_
+#endif // liblldb_PlatformiOSSimulatorCoreSimulatorSupport_h_
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ---------------*- C++ -*-===//
+//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ---------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,631 +23,503 @@
using namespace lldb_private;
using namespace lldb_utility;
-// CoreSimulator lives as part of Xcode, which means we can't really link against it, so we dlopen()
+// CoreSimulator lives as part of Xcode, which means we can't really link
+// against it, so we dlopen()
// it at runtime, and error out nicely if that fails
- at interface SimServiceContext
-{}
-+ (id) sharedServiceContextForDeveloperDir:(NSString*)dir error:(NSError**)error;
+ at interface SimServiceContext {
+}
++ (id)sharedServiceContextForDeveloperDir:(NSString *)dir
+ error:(NSError **)error;
@end
-// However, the drawback is that the compiler will not know about the selectors we're trying to use
-// until runtime; to appease clang in this regard, define a fake protocol on NSObject that exposes
+// However, the drawback is that the compiler will not know about the selectors
+// we're trying to use
+// until runtime; to appease clang in this regard, define a fake protocol on
+// NSObject that exposes
// the needed interface names for us
@protocol LLDBCoreSimulatorSupport <NSObject>
-- (id) defaultDeviceSetWithError:(NSError**)error;
-- (NSArray *) devices;
-- (id) deviceType;
-- (NSString *) name;
-- (NSString *) identifier;
-- (NSString *) modelIdentifier;
-- (NSString *) productFamily;
-- (int32_t) productFamilyID;
-- (id) runtime;
-- (BOOL) available;
-- (NSString *) versionString;
-- (NSString *) buildVersionString;
-- (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;
+- (id)defaultDeviceSetWithError:(NSError **)error;
+- (NSArray *)devices;
+- (id)deviceType;
+- (NSString *)name;
+- (NSString *)identifier;
+- (NSString *)modelIdentifier;
+- (NSString *)productFamily;
+- (int32_t)productFamilyID;
+- (id)runtime;
+- (BOOL)available;
+- (NSString *)versionString;
+- (NSString *)buildVersionString;
+- (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;
@end
-CoreSimulatorSupport::Process::Process (lldb::pid_t p) :
- m_pid (p),
- m_error ()
-{
-}
-
-CoreSimulatorSupport::Process::Process(Error error) :
- m_pid (LLDB_INVALID_PROCESS_ID),
- m_error (error)
-{
-}
+CoreSimulatorSupport::Process::Process(lldb::pid_t p) : m_pid(p), m_error() {}
-CoreSimulatorSupport::Process::Process (lldb::pid_t p, Error error) :
- m_pid (p),
- m_error (error)
-{
-}
+CoreSimulatorSupport::Process::Process(Error error)
+ : m_pid(LLDB_INVALID_PROCESS_ID), m_error(error) {}
+CoreSimulatorSupport::Process::Process(lldb::pid_t p, Error error)
+ : m_pid(p), m_error(error) {}
-CoreSimulatorSupport::DeviceType::DeviceType () :
- m_dev (nil),
- m_model_identifier ()
-{
-}
+CoreSimulatorSupport::DeviceType::DeviceType()
+ : m_dev(nil), m_model_identifier() {}
-CoreSimulatorSupport::DeviceType::DeviceType (id d) :
- m_dev (d),
- m_model_identifier ()
-{
-}
+CoreSimulatorSupport::DeviceType::DeviceType(id d)
+ : m_dev(d), m_model_identifier() {}
-CoreSimulatorSupport::DeviceType::operator bool ()
-{
- return m_dev != nil;
-}
+CoreSimulatorSupport::DeviceType::operator bool() { return m_dev != nil; }
-ConstString
-CoreSimulatorSupport::DeviceType::GetIdentifier ()
-{
- return ConstString( [[m_dev identifier] UTF8String] );
+ConstString CoreSimulatorSupport::DeviceType::GetIdentifier() {
+ return ConstString([[m_dev identifier] UTF8String]);
}
-ConstString
-CoreSimulatorSupport::DeviceType::GetProductFamily ()
-{
- return ConstString( [[m_dev productFamily] UTF8String] );
+ConstString CoreSimulatorSupport::DeviceType::GetProductFamily() {
+ return ConstString([[m_dev productFamily] UTF8String]);
}
CoreSimulatorSupport::DeviceType::ProductFamilyID
-CoreSimulatorSupport::DeviceType::GetProductFamilyID ()
-{
- return ProductFamilyID([m_dev productFamilyID]);
+CoreSimulatorSupport::DeviceType::GetProductFamilyID() {
+ return ProductFamilyID([m_dev productFamilyID]);
}
-CoreSimulatorSupport::DeviceRuntime::DeviceRuntime () :
- m_dev (nil),
- m_os_version ()
-{
-}
+CoreSimulatorSupport::DeviceRuntime::DeviceRuntime()
+ : m_dev(nil), m_os_version() {}
-CoreSimulatorSupport::DeviceRuntime::DeviceRuntime (id d) :
- m_dev (d),
- m_os_version ()
-{
-}
+CoreSimulatorSupport::DeviceRuntime::DeviceRuntime(id d)
+ : m_dev(d), m_os_version() {}
-CoreSimulatorSupport::DeviceRuntime::operator bool ()
-{
- return m_dev != nil;
-}
+CoreSimulatorSupport::DeviceRuntime::operator bool() { return m_dev != nil; }
-bool
-CoreSimulatorSupport::DeviceRuntime::IsAvailable ()
-{
- return [m_dev available];
+bool CoreSimulatorSupport::DeviceRuntime::IsAvailable() {
+ return [m_dev available];
}
-CoreSimulatorSupport::Device::Device () :
- m_dev (nil),
- m_dev_type (),
- m_dev_runtime ()
-{
-}
+CoreSimulatorSupport::Device::Device()
+ : m_dev(nil), m_dev_type(), m_dev_runtime() {}
-CoreSimulatorSupport::Device::Device (id d) :
- m_dev (d),
- m_dev_type (),
- m_dev_runtime ()
-{
-}
+CoreSimulatorSupport::Device::Device(id d)
+ : m_dev(d), m_dev_type(), m_dev_runtime() {}
-CoreSimulatorSupport::Device::operator bool ()
-{
- return m_dev != nil;
-}
+CoreSimulatorSupport::Device::operator bool() { return m_dev != nil; }
-CoreSimulatorSupport::Device::State
-CoreSimulatorSupport::Device::GetState ()
-{
- return (State)([m_dev state]);
+CoreSimulatorSupport::Device::State CoreSimulatorSupport::Device::GetState() {
+ return (State)([m_dev state]);
}
-CoreSimulatorSupport::ModelIdentifier::ModelIdentifier (const std::string& mi) :
- m_family (),
- m_versions ()
-{
- bool any = false;
- bool first_digit = false;
- unsigned int val = 0;
-
- for (char c : mi)
- {
- any = true;
- if (::isdigit(c))
- {
- if (!first_digit)
- first_digit = true;
- val = 10*val + (c - '0');
- }
- else if (c == ',')
- {
- if (first_digit)
- {
- m_versions.push_back(val);
- val = 0;
- }
- else
- m_family.push_back(c);
- }
- else
- {
- if (first_digit)
- {
- m_family.clear();
- m_versions.clear();
- return;
- }
- else
- {
- m_family.push_back(c);
- }
- }
- }
-
- if (first_digit)
- m_versions.push_back(val);
-}
+CoreSimulatorSupport::ModelIdentifier::ModelIdentifier(const std::string &mi)
+ : m_family(), m_versions() {
+ bool any = false;
+ bool first_digit = false;
+ unsigned int val = 0;
-CoreSimulatorSupport::ModelIdentifier::ModelIdentifier () :
-ModelIdentifier("")
-{
-}
-
-CoreSimulatorSupport::OSVersion::OSVersion (const std::string& ver,
- const std::string& build) :
- m_versions (),
- m_build (build)
-{
- bool any = false;
- unsigned int val = 0;
- for (char c : ver)
- {
- if (c == '.')
- {
- m_versions.push_back(val);
- val = 0;
- }
- else if (::isdigit(c))
- {
- val = 10*val + (c - '0');
- any = true;
- }
- else
- {
- m_versions.clear();
- return;
- }
- }
- if (any)
+ for (char c : mi) {
+ any = true;
+ if (::isdigit(c)) {
+ if (!first_digit)
+ first_digit = true;
+ val = 10 * val + (c - '0');
+ } else if (c == ',') {
+ if (first_digit) {
m_versions.push_back(val);
+ val = 0;
+ } else
+ m_family.push_back(c);
+ } else {
+ if (first_digit) {
+ m_family.clear();
+ m_versions.clear();
+ return;
+ } else {
+ m_family.push_back(c);
+ }
+ }
+ }
+
+ if (first_digit)
+ m_versions.push_back(val);
+}
+
+CoreSimulatorSupport::ModelIdentifier::ModelIdentifier()
+ : ModelIdentifier("") {}
+
+CoreSimulatorSupport::OSVersion::OSVersion(const std::string &ver,
+ const std::string &build)
+ : m_versions(), m_build(build) {
+ bool any = false;
+ unsigned int val = 0;
+ for (char c : ver) {
+ if (c == '.') {
+ m_versions.push_back(val);
+ val = 0;
+ } else if (::isdigit(c)) {
+ val = 10 * val + (c - '0');
+ any = true;
+ } else {
+ m_versions.clear();
+ return;
+ }
+ }
+ if (any)
+ m_versions.push_back(val);
}
-CoreSimulatorSupport::OSVersion::OSVersion () :
- OSVersion("","")
-{
-}
+CoreSimulatorSupport::OSVersion::OSVersion() : OSVersion("", "") {}
CoreSimulatorSupport::ModelIdentifier
-CoreSimulatorSupport::DeviceType::GetModelIdentifier ()
-{
- if (!m_model_identifier.hasValue())
- {
- auto utf8_model_id = [[m_dev modelIdentifier] UTF8String];
- if (utf8_model_id && *utf8_model_id)
- m_model_identifier = ModelIdentifier (utf8_model_id);
- }
-
- if (m_model_identifier.hasValue())
- return m_model_identifier.getValue();
- else
- return ModelIdentifier();
+CoreSimulatorSupport::DeviceType::GetModelIdentifier() {
+ if (!m_model_identifier.hasValue()) {
+ auto utf8_model_id = [[m_dev modelIdentifier] UTF8String];
+ if (utf8_model_id && *utf8_model_id)
+ m_model_identifier = ModelIdentifier(utf8_model_id);
+ }
+
+ if (m_model_identifier.hasValue())
+ return m_model_identifier.getValue();
+ else
+ return ModelIdentifier();
}
CoreSimulatorSupport::OSVersion
-CoreSimulatorSupport::DeviceRuntime::GetVersion ()
-{
- if (!m_os_version.hasValue())
- {
- auto utf8_ver_string = [[m_dev versionString] UTF8String];
- auto utf8_build_ver = [[m_dev buildVersionString] UTF8String];
- if (utf8_ver_string && *utf8_ver_string &&
- utf8_build_ver && *utf8_build_ver)
- {
- m_os_version = OSVersion(utf8_ver_string, utf8_build_ver);
- }
+CoreSimulatorSupport::DeviceRuntime::GetVersion() {
+ if (!m_os_version.hasValue()) {
+ auto utf8_ver_string = [[m_dev versionString] UTF8String];
+ auto utf8_build_ver = [[m_dev buildVersionString] UTF8String];
+ if (utf8_ver_string && *utf8_ver_string && utf8_build_ver &&
+ *utf8_build_ver) {
+ m_os_version = OSVersion(utf8_ver_string, utf8_build_ver);
}
-
- if (m_os_version.hasValue())
- return m_os_version.getValue();
- return OSVersion();
-}
-
-std::string
-CoreSimulatorSupport::DeviceType::GetName ()
-{
- auto utf8_name = [[m_dev name] UTF8String];
- if (utf8_name)
- return std::string(utf8_name);
- return "";
-}
-
-std::string
-CoreSimulatorSupport::Device::GetName () const
-{
- auto utf8_name = [[m_dev name] UTF8String];
- if (utf8_name)
- return std::string(utf8_name);
- return "";
-}
-
-std::string
-CoreSimulatorSupport::Device::GetUDID () const
-{
- auto utf8_udid = [ [[m_dev UDID] UUIDString] UTF8String];
- if (utf8_udid)
- return std::string(utf8_udid);
- else
- return std::string();
-}
-
-CoreSimulatorSupport::DeviceType
-CoreSimulatorSupport::Device::GetDeviceType ()
-{
- if (!m_dev_type.hasValue())
- m_dev_type = DeviceType([m_dev deviceType]);
-
- return m_dev_type.getValue();
-}
+ }
-CoreSimulatorSupport::DeviceRuntime
-CoreSimulatorSupport::Device::GetDeviceRuntime ()
-{
- if (!m_dev_runtime.hasValue())
- m_dev_runtime = DeviceRuntime([m_dev runtime]);
-
- return m_dev_runtime.getValue();
-}
-
-bool
-CoreSimulatorSupport::operator > (const CoreSimulatorSupport::OSVersion& lhs,
- const CoreSimulatorSupport::OSVersion& rhs)
-{
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l > r)
- return true;
- }
- return false;
+ if (m_os_version.hasValue())
+ return m_os_version.getValue();
+ return OSVersion();
}
-bool
-CoreSimulatorSupport::operator > (const CoreSimulatorSupport::ModelIdentifier& lhs,
- const CoreSimulatorSupport::ModelIdentifier& rhs)
-{
- if (lhs.GetFamily() != rhs.GetFamily())
- return false;
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l > r)
- return true;
- }
- return false;
+std::string CoreSimulatorSupport::DeviceType::GetName() {
+ auto utf8_name = [[m_dev name] UTF8String];
+ if (utf8_name)
+ return std::string(utf8_name);
+ return "";
}
-bool
-CoreSimulatorSupport::operator < (const CoreSimulatorSupport::OSVersion& lhs,
- const CoreSimulatorSupport::OSVersion& rhs)
-{
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l < r)
- return true;
- }
- return false;
+std::string CoreSimulatorSupport::Device::GetName() const {
+ auto utf8_name = [[m_dev name] UTF8String];
+ if (utf8_name)
+ return std::string(utf8_name);
+ return "";
}
-bool
-CoreSimulatorSupport::operator < (const CoreSimulatorSupport::ModelIdentifier& lhs,
- const CoreSimulatorSupport::ModelIdentifier& rhs)
-{
- if (lhs.GetFamily() != rhs.GetFamily())
- return false;
-
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l < r)
- return true;
- }
- return false;
+std::string CoreSimulatorSupport::Device::GetUDID() const {
+ auto utf8_udid = [[[m_dev UDID] UUIDString] UTF8String];
+ if (utf8_udid)
+ return std::string(utf8_udid);
+ else
+ return std::string();
}
-bool
-CoreSimulatorSupport::operator == (const CoreSimulatorSupport::OSVersion& lhs,
- const CoreSimulatorSupport::OSVersion& rhs)
-{
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l != r)
- return false;
- }
- return true;
-}
+CoreSimulatorSupport::DeviceType CoreSimulatorSupport::Device::GetDeviceType() {
+ if (!m_dev_type.hasValue())
+ m_dev_type = DeviceType([m_dev deviceType]);
-bool
-CoreSimulatorSupport::operator == (const CoreSimulatorSupport::ModelIdentifier& lhs,
- const CoreSimulatorSupport::ModelIdentifier& rhs)
-{
- if (lhs.GetFamily() != rhs.GetFamily())
- return false;
-
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l != r)
- return false;
- }
- return true;
+ return m_dev_type.getValue();
}
-bool
-CoreSimulatorSupport::operator != (const CoreSimulatorSupport::OSVersion& lhs,
- const CoreSimulatorSupport::OSVersion& rhs)
-{
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l != r)
- return true;
- }
+CoreSimulatorSupport::DeviceRuntime
+CoreSimulatorSupport::Device::GetDeviceRuntime() {
+ if (!m_dev_runtime.hasValue())
+ m_dev_runtime = DeviceRuntime([m_dev runtime]);
+
+ return m_dev_runtime.getValue();
+}
+
+bool CoreSimulatorSupport::
+operator>(const CoreSimulatorSupport::OSVersion &lhs,
+ const CoreSimulatorSupport::OSVersion &rhs) {
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l > r)
+ return true;
+ }
+ return false;
+}
+
+bool CoreSimulatorSupport::
+operator>(const CoreSimulatorSupport::ModelIdentifier &lhs,
+ const CoreSimulatorSupport::ModelIdentifier &rhs) {
+ if (lhs.GetFamily() != rhs.GetFamily())
+ return false;
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l > r)
+ return true;
+ }
+ return false;
+}
+
+bool CoreSimulatorSupport::
+operator<(const CoreSimulatorSupport::OSVersion &lhs,
+ const CoreSimulatorSupport::OSVersion &rhs) {
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l < r)
+ return true;
+ }
+ return false;
+}
+
+bool CoreSimulatorSupport::
+operator<(const CoreSimulatorSupport::ModelIdentifier &lhs,
+ const CoreSimulatorSupport::ModelIdentifier &rhs) {
+ if (lhs.GetFamily() != rhs.GetFamily())
return false;
-}
-bool
-CoreSimulatorSupport::operator != (const CoreSimulatorSupport::ModelIdentifier& lhs,
- const CoreSimulatorSupport::ModelIdentifier& rhs)
-{
- if (lhs.GetFamily() != rhs.GetFamily())
- return false;
-
- for (size_t i = 0;
- i < rhs.GetNumVersions();
- i++)
- {
- unsigned int l = lhs.GetVersionAtIndex(i);
- unsigned int r = rhs.GetVersionAtIndex(i);
- if (l != r)
- return true;
- }
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l < r)
+ return true;
+ }
+ return false;
+}
+
+bool CoreSimulatorSupport::
+operator==(const CoreSimulatorSupport::OSVersion &lhs,
+ const CoreSimulatorSupport::OSVersion &rhs) {
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l != r)
+ return false;
+ }
+ return true;
+}
+
+bool CoreSimulatorSupport::
+operator==(const CoreSimulatorSupport::ModelIdentifier &lhs,
+ const CoreSimulatorSupport::ModelIdentifier &rhs) {
+ if (lhs.GetFamily() != rhs.GetFamily())
+ return false;
+
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l != r)
+ return false;
+ }
+ return true;
+}
+
+bool CoreSimulatorSupport::
+operator!=(const CoreSimulatorSupport::OSVersion &lhs,
+ const CoreSimulatorSupport::OSVersion &rhs) {
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l != r)
+ return true;
+ }
+ return false;
+}
+
+bool CoreSimulatorSupport::
+operator!=(const CoreSimulatorSupport::ModelIdentifier &lhs,
+ const CoreSimulatorSupport::ModelIdentifier &rhs) {
+ if (lhs.GetFamily() != rhs.GetFamily())
return false;
+
+ for (size_t i = 0; i < rhs.GetNumVersions(); i++) {
+ unsigned int l = lhs.GetVersionAtIndex(i);
+ unsigned int r = rhs.GetVersionAtIndex(i);
+ if (l != r)
+ return true;
+ }
+ return false;
}
-bool
-CoreSimulatorSupport::Device::Boot (Error &err)
-{
- if (m_dev == nil)
- {
- err.SetErrorString("no valid simulator instance");
- return false;
- }
+bool CoreSimulatorSupport::Device::Boot(Error &err) {
+ if (m_dev == nil) {
+ err.SetErrorString("no valid simulator instance");
+ return false;
+ }
-#define kSimDeviceBootPersist @"persist" /* An NSNumber (boolean) indicating whether or not the session should outlive the calling process (default false) */
-
- NSDictionary *options = @{
- kSimDeviceBootPersist : @NO,
- };
+#define kSimDeviceBootPersist \
+ @"persist" /* An NSNumber (boolean) indicating whether or not the session \
+ should outlive the calling process (default false) */
+
+ NSDictionary *options = @{
+ kSimDeviceBootPersist : @NO,
+ };
#undef kSimDeviceBootPersist
-
- NSError* nserror;
- if ([m_dev bootWithOptions:options error:&nserror])
- {
- err.Clear();
- return true;
- }
- else
- {
- err.SetErrorString([[nserror description] UTF8String]);
- return false;
- }
-}
-bool
-CoreSimulatorSupport::Device::Shutdown (Error &err)
-{
- NSError* nserror;
- if ([m_dev shutdownWithError:&nserror])
- {
- err.Clear();
- return true;
- }
- else
- {
- err.SetErrorString([[nserror description] UTF8String]);
- return false;
- }
+ NSError *nserror;
+ if ([m_dev bootWithOptions:options error:&nserror]) {
+ err.Clear();
+ return true;
+ } else {
+ err.SetErrorString([[nserror description] UTF8String]);
+ return false;
+ }
}
+bool CoreSimulatorSupport::Device::Shutdown(Error &err) {
+ NSError *nserror;
+ if ([m_dev shutdownWithError:&nserror]) {
+ err.Clear();
+ return true;
+ } else {
+ err.SetErrorString([[nserror description] UTF8String]);
+ return false;
+ }
+}
-static Error
-HandleFileAction(ProcessLaunchInfo& launch_info,
- NSMutableDictionary *options,
- NSString *key,
- const int fd,
- File &file)
-{
- Error error;
- const FileAction *file_action = launch_info.GetFileActionForFD (fd);
- if (file_action)
- {
- switch (file_action->GetAction())
- {
- case FileAction::eFileActionNone:
- break;
-
- case FileAction::eFileActionClose:
- error.SetErrorStringWithFormat ("close file action for %i not supported", fd);
- break;
-
- case FileAction::eFileActionDuplicate:
- error.SetErrorStringWithFormat ("duplication file action for %i not supported", fd);
- break;
-
- case FileAction::eFileActionOpen:
- {
- FileSpec file_spec = file_action->GetFileSpec();
- if (file_spec)
- {
- const int master_fd = launch_info.GetPTY().GetMasterFileDescriptor();
- if (master_fd != PseudoTerminal::invalid_fd)
- {
- // Check in case our file action open wants to open the slave
- const char *slave_path = launch_info.GetPTY().GetSlaveName(NULL, 0);
- if (slave_path)
- {
- FileSpec slave_spec(slave_path, false);
- if (file_spec == slave_spec)
- {
- int slave_fd = launch_info.GetPTY().GetSlaveFileDescriptor();
- if (slave_fd == PseudoTerminal::invalid_fd)
- slave_fd = launch_info.GetPTY().OpenSlave(O_RDWR, nullptr, 0);
- if (slave_fd == PseudoTerminal::invalid_fd)
- {
- error.SetErrorStringWithFormat("unable to open slave pty '%s'", slave_path);
- return error; // Failure
- }
- [options setValue:[NSNumber numberWithInteger:slave_fd] forKey:key];
- return error; // Success
- }
- }
- }
- Error posix_error;
- int created_fd = open(file_spec.GetPath().c_str(), file_action->GetActionArgument(), S_IRUSR | S_IWUSR);
- if (created_fd >= 0)
- {
- file.SetDescriptor(created_fd, true);
- [options setValue:[NSNumber numberWithInteger:created_fd] forKey:key];
- return error; // Success
- }
- else
- {
- posix_error.SetErrorToErrno();
- error.SetErrorStringWithFormat("unable to open file '%s': %s", file_spec.GetPath().c_str(), posix_error.AsCString());
- }
- }
- }
- break;
+static Error HandleFileAction(ProcessLaunchInfo &launch_info,
+ NSMutableDictionary *options, NSString *key,
+ const int fd, File &file) {
+ Error error;
+ const FileAction *file_action = launch_info.GetFileActionForFD(fd);
+ if (file_action) {
+ switch (file_action->GetAction()) {
+ case FileAction::eFileActionNone:
+ break;
+
+ case FileAction::eFileActionClose:
+ error.SetErrorStringWithFormat("close file action for %i not supported",
+ fd);
+ break;
+
+ case FileAction::eFileActionDuplicate:
+ error.SetErrorStringWithFormat(
+ "duplication file action for %i not supported", fd);
+ break;
+
+ case FileAction::eFileActionOpen: {
+ FileSpec file_spec = file_action->GetFileSpec();
+ if (file_spec) {
+ const int master_fd = launch_info.GetPTY().GetMasterFileDescriptor();
+ if (master_fd != PseudoTerminal::invalid_fd) {
+ // Check in case our file action open wants to open the slave
+ const char *slave_path = launch_info.GetPTY().GetSlaveName(NULL, 0);
+ if (slave_path) {
+ FileSpec slave_spec(slave_path, false);
+ if (file_spec == slave_spec) {
+ int slave_fd = launch_info.GetPTY().GetSlaveFileDescriptor();
+ if (slave_fd == PseudoTerminal::invalid_fd)
+ slave_fd = launch_info.GetPTY().OpenSlave(O_RDWR, nullptr, 0);
+ if (slave_fd == PseudoTerminal::invalid_fd) {
+ error.SetErrorStringWithFormat("unable to open slave pty '%s'",
+ slave_path);
+ return error; // Failure
+ }
+ [options setValue:[NSNumber numberWithInteger:slave_fd]
+ forKey:key];
+ return error; // Success
+ }
+ }
}
+ Error posix_error;
+ int created_fd =
+ open(file_spec.GetPath().c_str(), file_action->GetActionArgument(),
+ S_IRUSR | S_IWUSR);
+ if (created_fd >= 0) {
+ file.SetDescriptor(created_fd, true);
+ [options setValue:[NSNumber numberWithInteger:created_fd] forKey:key];
+ return error; // Success
+ } else {
+ posix_error.SetErrorToErrno();
+ error.SetErrorStringWithFormat("unable to open file '%s': %s",
+ file_spec.GetPath().c_str(),
+ posix_error.AsCString());
+ }
+ }
+ } break;
}
- return error; // Success, no file action, nothing to do
+ }
+ return error; // Success, no file action, nothing to do
}
CoreSimulatorSupport::Process
-CoreSimulatorSupport::Device::Spawn (ProcessLaunchInfo& launch_info)
-{
-#define kSimDeviceSpawnEnvironment @"environment" /* An NSDictionary (NSStrings -> NSStrings) of environment key/values */
-#define kSimDeviceSpawnStdin @"stdin" /* An NSNumber corresponding to a fd */
-#define kSimDeviceSpawnStdout @"stdout" /* An NSNumber corresponding to a fd */
-#define kSimDeviceSpawnStderr @"stderr" /* An NSNumber corresponding to a fd */
-#define kSimDeviceSpawnArguments @"arguments" /* An NSArray of strings to use as the argv array. If not provided, path will be argv[0] */
-#define kSimDeviceSpawnWaitForDebugger @"wait_for_debugger" /* An NSNumber (bool) */
-
- NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
-
- if (launch_info.GetFlags().Test(lldb::eLaunchFlagDebug))
- [options setObject:@YES forKey:kSimDeviceSpawnWaitForDebugger];
-
- if (launch_info.GetArguments().GetArgumentCount())
- {
- const Args& args(launch_info.GetArguments());
- NSMutableArray *args_array = [[NSMutableArray alloc] init];
- for (size_t idx = 0;
- idx < args.GetArgumentCount();
- idx++)
- [args_array addObject:[NSString stringWithUTF8String:args.GetArgumentAtIndex(idx)]];
-
- [options setObject:args_array forKey:kSimDeviceSpawnArguments];
- }
-
- if (launch_info.GetEnvironmentEntries().GetArgumentCount())
- {
- const Args& envs(launch_info.GetEnvironmentEntries());
- NSMutableDictionary *env_dict = [[NSMutableDictionary alloc] init];
- for (size_t idx = 0;
- idx < envs.GetArgumentCount();
- idx++)
- {
- llvm::StringRef arg_sr(envs.GetArgumentAtIndex(idx));
- auto first_eq = arg_sr.find('=');
- if (first_eq == llvm::StringRef::npos)
- continue;
- llvm::StringRef key = arg_sr.substr(0, first_eq);
- llvm::StringRef value = arg_sr.substr(first_eq+1);
-
- NSString *key_ns = [NSString stringWithUTF8String:key.str().c_str()];
- NSString *value_ns = [NSString stringWithUTF8String:value.str().c_str()];
-
- [env_dict setValue:value_ns forKey:key_ns];
- }
-
- [options setObject:env_dict forKey:kSimDeviceSpawnEnvironment];
- }
-
- Error error;
- File stdin_file;
- File stdout_file;
- File stderr_file;
- error = HandleFileAction(launch_info, options, kSimDeviceSpawnStdin, STDIN_FILENO, stdin_file);
+CoreSimulatorSupport::Device::Spawn(ProcessLaunchInfo &launch_info) {
+#define kSimDeviceSpawnEnvironment \
+ @"environment" /* An NSDictionary (NSStrings -> NSStrings) of environment \
+ key/values */
+#define kSimDeviceSpawnStdin @"stdin" /* An NSNumber corresponding to a fd */
+#define kSimDeviceSpawnStdout @"stdout" /* An NSNumber corresponding to a fd \
+ */
+#define kSimDeviceSpawnStderr @"stderr" /* An NSNumber corresponding to a fd \
+ */
+#define kSimDeviceSpawnArguments \
+ @"arguments" /* An NSArray of strings to use as the argv array. If not \
+ provided, path will be argv[0] */
+#define kSimDeviceSpawnWaitForDebugger \
+ @"wait_for_debugger" /* An NSNumber (bool) */
+
+ NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
+
+ if (launch_info.GetFlags().Test(lldb::eLaunchFlagDebug))
+ [options setObject:@YES forKey:kSimDeviceSpawnWaitForDebugger];
+
+ if (launch_info.GetArguments().GetArgumentCount()) {
+ const Args &args(launch_info.GetArguments());
+ NSMutableArray *args_array = [[NSMutableArray alloc] init];
+ for (size_t idx = 0; idx < args.GetArgumentCount(); idx++)
+ [args_array
+ addObject:[NSString
+ stringWithUTF8String:args.GetArgumentAtIndex(idx)]];
+
+ [options setObject:args_array forKey:kSimDeviceSpawnArguments];
+ }
+
+ if (launch_info.GetEnvironmentEntries().GetArgumentCount()) {
+ const Args &envs(launch_info.GetEnvironmentEntries());
+ NSMutableDictionary *env_dict = [[NSMutableDictionary alloc] init];
+ for (size_t idx = 0; idx < envs.GetArgumentCount(); idx++) {
+ llvm::StringRef arg_sr(envs.GetArgumentAtIndex(idx));
+ auto first_eq = arg_sr.find('=');
+ if (first_eq == llvm::StringRef::npos)
+ continue;
+ llvm::StringRef key = arg_sr.substr(0, first_eq);
+ llvm::StringRef value = arg_sr.substr(first_eq + 1);
+
+ NSString *key_ns = [NSString stringWithUTF8String:key.str().c_str()];
+ NSString *value_ns = [NSString stringWithUTF8String:value.str().c_str()];
+
+ [env_dict setValue:value_ns forKey:key_ns];
+ }
+
+ [options setObject:env_dict forKey:kSimDeviceSpawnEnvironment];
+ }
+
+ Error error;
+ File stdin_file;
+ File stdout_file;
+ File stderr_file;
+ error = HandleFileAction(launch_info, options, kSimDeviceSpawnStdin,
+ STDIN_FILENO, stdin_file);
+
+ if (error.Fail())
+ return CoreSimulatorSupport::Process(error);
+
+ error = HandleFileAction(launch_info, options, kSimDeviceSpawnStdout,
+ STDOUT_FILENO, stdout_file);
- if (error.Fail())
- return CoreSimulatorSupport::Process(error);
+ if (error.Fail())
+ return CoreSimulatorSupport::Process(error);
- error = HandleFileAction(launch_info, options, kSimDeviceSpawnStdout, STDOUT_FILENO, stdout_file);
+ error = HandleFileAction(launch_info, options, kSimDeviceSpawnStderr,
+ STDERR_FILENO, stderr_file);
- if (error.Fail())
- return CoreSimulatorSupport::Process(error);
-
- error = HandleFileAction(launch_info, options, kSimDeviceSpawnStderr, STDERR_FILENO, stderr_file);
-
- if (error.Fail())
- return CoreSimulatorSupport::Process(error);
+ if (error.Fail())
+ return CoreSimulatorSupport::Process(error);
#undef kSimDeviceSpawnEnvironment
#undef kSimDeviceSpawnStdin
@@ -654,127 +527,118 @@ CoreSimulatorSupport::Device::Spawn (Pro
#undef kSimDeviceSpawnStderr
#undef kSimDeviceSpawnWaitForDebugger
#undef kSimDeviceSpawnArguments
-
- NSError* nserror;
-
- pid_t pid = [m_dev spawnWithPath: [NSString stringWithUTF8String: launch_info.GetExecutableFile().GetPath().c_str()]
- options: options
- terminationHandler: nil
- error: &nserror];
+ NSError *nserror;
- if (pid < 0)
- {
- const char* nserror_string = [[nserror description] UTF8String];
- error.SetErrorString(nserror_string ? nserror_string : "unable to launch");
- }
-
- return CoreSimulatorSupport::Process (pid, error);
-}
-
-CoreSimulatorSupport::DeviceSet
-CoreSimulatorSupport::DeviceSet::GetAllDevices (const char *developer_dir)
-{
- if (!developer_dir || !developer_dir[0])
- return DeviceSet([NSArray new]);
-
- Class SimServiceContextClass = NSClassFromString(@"SimServiceContext");
- NSString *dev_dir = @(developer_dir);
- NSError *error = nil;
-
- id serviceContext = [SimServiceContextClass sharedServiceContextForDeveloperDir:dev_dir error:&error];
- if (!serviceContext)
- return DeviceSet([NSArray new]);
+ pid_t pid = [m_dev
+ spawnWithPath:[NSString stringWithUTF8String:launch_info
+ .GetExecutableFile()
+ .GetPath()
+ .c_str()]
+ options:options
+ terminationHandler:nil
+ error:&nserror];
+
+ if (pid < 0) {
+ const char *nserror_string = [[nserror description] UTF8String];
+ error.SetErrorString(nserror_string ? nserror_string : "unable to launch");
+ }
- return DeviceSet([[serviceContext defaultDeviceSetWithError:&error] devices]);
+ return CoreSimulatorSupport::Process(pid, error);
}
CoreSimulatorSupport::DeviceSet
-CoreSimulatorSupport::DeviceSet::GetAvailableDevices (const char *developer_dir)
-{
- return GetAllDevices(developer_dir).GetDevicesIf( [] (Device d) -> bool {
- return (d && d.GetDeviceType() && d.GetDeviceRuntime() && d.GetDeviceRuntime().IsAvailable());
- });
-}
-
-size_t
-CoreSimulatorSupport::DeviceSet::GetNumDevices ()
-{
- return [m_dev count];
-}
+CoreSimulatorSupport::DeviceSet::GetAllDevices(const char *developer_dir) {
+ if (!developer_dir || !developer_dir[0])
+ return DeviceSet([NSArray new]);
+
+ Class SimServiceContextClass = NSClassFromString(@"SimServiceContext");
+ NSString *dev_dir = @(developer_dir);
+ NSError *error = nil;
+
+ id serviceContext =
+ [SimServiceContextClass sharedServiceContextForDeveloperDir:dev_dir
+ error:&error];
+ if (!serviceContext)
+ return DeviceSet([NSArray new]);
-CoreSimulatorSupport::Device
-CoreSimulatorSupport::DeviceSet::GetDeviceAtIndex (size_t idx)
-{
- if (idx < GetNumDevices())
- return Device([m_dev objectAtIndex:idx]);
- return Device();
+ return DeviceSet([[serviceContext defaultDeviceSetWithError:&error] devices]);
}
CoreSimulatorSupport::DeviceSet
-CoreSimulatorSupport::DeviceSet::GetDevicesIf (std::function<bool(CoreSimulatorSupport::Device)> f)
-{
- NSMutableArray *array = [[NSMutableArray alloc] init];
- for (NSUInteger i = 0;
- i < GetNumDevices();
- i++)
- {
- Device d(GetDeviceAtIndex(i));
- if (f(d))
- [array addObject:(id)d.m_dev];
- }
-
- return DeviceSet(array);
+CoreSimulatorSupport::DeviceSet::GetAvailableDevices(
+ const char *developer_dir) {
+ return GetAllDevices(developer_dir).GetDevicesIf([](Device d) -> bool {
+ return (d && d.GetDeviceType() && d.GetDeviceRuntime() &&
+ d.GetDeviceRuntime().IsAvailable());
+ });
}
-void
-CoreSimulatorSupport::DeviceSet::ForEach (std::function<bool(const Device &)> f)
-{
- const size_t n = GetNumDevices();
- for (NSUInteger i = 0; i < n; ++i)
- {
- if (f(GetDeviceAtIndex(i)) == false)
- break;
- }
-}
-
-CoreSimulatorSupport::DeviceSet
-CoreSimulatorSupport::DeviceSet::GetDevices (CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id)
-{
- NSMutableArray *array = [[NSMutableArray alloc] init];
- const size_t n = GetNumDevices();
- for (NSUInteger i = 0; i < n; ++i)
- {
- Device d(GetDeviceAtIndex(i));
- if (d && d.GetDeviceType() && d.GetDeviceType().GetProductFamilyID() == dev_id)
- [array addObject:(id)d.m_dev];
- }
-
- return DeviceSet(array);
+size_t CoreSimulatorSupport::DeviceSet::GetNumDevices() {
+ return [m_dev count];
}
CoreSimulatorSupport::Device
-CoreSimulatorSupport::DeviceSet::GetFanciest (CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id)
-{
- Device dev;
-
- for (NSUInteger i = 0;
- i < GetNumDevices();
- i++)
- {
- Device d(GetDeviceAtIndex(i));
- if (d && d.GetDeviceType() && d.GetDeviceType().GetProductFamilyID() == dev_id)
- {
- if (!dev)
- dev = d;
- else
- {
- if ((d.GetDeviceType().GetModelIdentifier() > dev.GetDeviceType().GetModelIdentifier()) ||
- d.GetDeviceRuntime().GetVersion() > dev.GetDeviceRuntime().GetVersion())
- dev = d;
- }
- }
+CoreSimulatorSupport::DeviceSet::GetDeviceAtIndex(size_t idx) {
+ if (idx < GetNumDevices())
+ return Device([m_dev objectAtIndex:idx]);
+ return Device();
+}
+
+CoreSimulatorSupport::DeviceSet CoreSimulatorSupport::DeviceSet::GetDevicesIf(
+ std::function<bool(CoreSimulatorSupport::Device)> f) {
+ NSMutableArray *array = [[NSMutableArray alloc] init];
+ for (NSUInteger i = 0; i < GetNumDevices(); i++) {
+ Device d(GetDeviceAtIndex(i));
+ if (f(d))
+ [array addObject:(id)d.m_dev];
+ }
+
+ return DeviceSet(array);
+}
+
+void CoreSimulatorSupport::DeviceSet::ForEach(
+ std::function<bool(const Device &)> f) {
+ const size_t n = GetNumDevices();
+ for (NSUInteger i = 0; i < n; ++i) {
+ if (f(GetDeviceAtIndex(i)) == false)
+ break;
+ }
+}
+
+CoreSimulatorSupport::DeviceSet CoreSimulatorSupport::DeviceSet::GetDevices(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id) {
+ NSMutableArray *array = [[NSMutableArray alloc] init];
+ const size_t n = GetNumDevices();
+ for (NSUInteger i = 0; i < n; ++i) {
+ Device d(GetDeviceAtIndex(i));
+ if (d && d.GetDeviceType() &&
+ d.GetDeviceType().GetProductFamilyID() == dev_id)
+ [array addObject:(id)d.m_dev];
+ }
+
+ return DeviceSet(array);
+}
+
+CoreSimulatorSupport::Device CoreSimulatorSupport::DeviceSet::GetFanciest(
+ CoreSimulatorSupport::DeviceType::ProductFamilyID dev_id) {
+ Device dev;
+
+ for (NSUInteger i = 0; i < GetNumDevices(); i++) {
+ Device d(GetDeviceAtIndex(i));
+ if (d && d.GetDeviceType() &&
+ d.GetDeviceType().GetProductFamilyID() == dev_id) {
+ if (!dev)
+ dev = d;
+ else {
+ if ((d.GetDeviceType().GetModelIdentifier() >
+ dev.GetDeviceType().GetModelIdentifier()) ||
+ d.GetDeviceRuntime().GetVersion() >
+ dev.GetDeviceRuntime().GetVersion())
+ dev = d;
+ }
}
-
- return dev;
+ }
+
+ return dev;
}
Modified: lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp Tue Sep 6 15:57:50 2016
@@ -21,8 +21,8 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -34,624 +34,516 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_netbsd;
-PlatformSP
-PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch)
-{
- // The only time we create an instance is when we are creating a remote
- // netbsd platform
- const bool is_host = false;
-
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getOS())
- {
- case llvm::Triple::NetBSD:
- create = true;
- break;
-
- default:
- break;
- }
- }
- if (create)
- return PlatformSP(new PlatformNetBSD (is_host));
- return PlatformSP();
-
-}
-
-ConstString
-PlatformNetBSD::GetPluginNameStatic(bool is_host)
-{
- if (is_host)
- {
- static ConstString g_host_name(Platform::GetHostPlatformName ());
- return g_host_name;
- }
- else
- {
- static ConstString g_remote_name("remote-netbsd");
- return g_remote_name;
- }
-}
-
-const char *
-PlatformNetBSD::GetDescriptionStatic (bool is_host)
-{
- if (is_host)
- return "Local NetBSD user platform plug-in.";
- else
- return "Remote NetBSD user platform plug-in.";
+PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
+ // The only time we create an instance is when we are creating a remote
+ // netbsd platform
+ const bool is_host = false;
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getOS()) {
+ case llvm::Triple::NetBSD:
+ create = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (create)
+ return PlatformSP(new PlatformNetBSD(is_host));
+ return PlatformSP();
+}
+
+ConstString PlatformNetBSD::GetPluginNameStatic(bool is_host) {
+ if (is_host) {
+ static ConstString g_host_name(Platform::GetHostPlatformName());
+ return g_host_name;
+ } else {
+ static ConstString g_remote_name("remote-netbsd");
+ return g_remote_name;
+ }
+}
+
+const char *PlatformNetBSD::GetDescriptionStatic(bool is_host) {
+ if (is_host)
+ return "Local NetBSD user platform plug-in.";
+ else
+ return "Remote NetBSD user platform plug-in.";
}
static uint32_t g_initialize_count = 0;
-void
-PlatformNetBSD::Initialize ()
-{
- Platform::Initialize ();
+void PlatformNetBSD::Initialize() {
+ Platform::Initialize();
- if (g_initialize_count++ == 0)
- {
+ if (g_initialize_count++ == 0) {
#if defined(__NetBSD__)
- // Force a host flag to true for the default platform object.
- PlatformSP default_platform_sp (new PlatformNetBSD(true));
- default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
- Platform::SetHostPlatform (default_platform_sp);
+ // Force a host flag to true for the default platform object.
+ PlatformSP default_platform_sp(new PlatformNetBSD(true));
+ default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+ Platform::SetHostPlatform(default_platform_sp);
#endif
- PluginManager::RegisterPlugin(PlatformNetBSD::GetPluginNameStatic(false),
- PlatformNetBSD::GetDescriptionStatic(false),
- PlatformNetBSD::CreateInstance);
- }
-}
-
-void
-PlatformNetBSD::Terminate ()
-{
- if (g_initialize_count > 0 && --g_initialize_count == 0)
- PluginManager::UnregisterPlugin (PlatformNetBSD::CreateInstance);
-
- Platform::Terminate ();
-}
-
-bool
-PlatformNetBSD::GetModuleSpec (const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec)
-{
+ PluginManager::RegisterPlugin(PlatformNetBSD::GetPluginNameStatic(false),
+ PlatformNetBSD::GetDescriptionStatic(false),
+ PlatformNetBSD::CreateInstance);
+ }
+}
+
+void PlatformNetBSD::Terminate() {
+ if (g_initialize_count > 0 && --g_initialize_count == 0)
+ PluginManager::UnregisterPlugin(PlatformNetBSD::CreateInstance);
+
+ Platform::Terminate();
+}
+
+bool PlatformNetBSD::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
+ module_spec);
+
+ return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+}
+
+Error PlatformNetBSD::RunShellCommand(const char *command,
+ const FileSpec &working_dir,
+ int *status_ptr, int *signo_ptr,
+ std::string *command_output,
+ uint32_t timeout_sec) {
+ if (IsHost())
+ return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
+ command_output, timeout_sec);
+ else {
if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec);
-
- return Platform::GetModuleSpec (module_file_spec, arch, module_spec);
-}
-
-Error
-PlatformNetBSD::RunShellCommand(const char *command,
- const FileSpec &working_dir,
- int *status_ptr,
- int *signo_ptr,
- std::string *command_output,
- uint32_t timeout_sec)
-{
- if (IsHost())
- return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
+ return m_remote_platform_sp->RunShellCommand(command, working_dir,
+ status_ptr, signo_ptr,
+ command_output, timeout_sec);
else
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
- else
- return Error("unable to run a remote command without a platform");
- }
+ return Error("unable to run a remote command without a platform");
+ }
}
-Error
-PlatformNetBSD::ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(module_spec);
-
- if (IsHost())
- {
- // If we have "ls" as the module_spec's file, resolve the executable location based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists())
- {
- module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
-
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
+Error PlatformNetBSD::ResolveExecutable(
+ const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ ModuleSpec resolved_module_spec(module_spec);
+
+ if (IsHost()) {
+ // If we have "ls" as the module_spec's file, resolve the executable
+ // location based on
+ // the current path variables
+ if (!resolved_module_spec.GetFileSpec().Exists()) {
+ module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+ }
+
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else {
+ error.SetErrorStringWithFormat(
+ "unable to find executable for '%s'",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ } else {
+ if (m_remote_platform_sp) {
+ error =
+ GetCachedExecutable(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, *m_remote_platform_sp);
+ } else {
+ // We may connect to a process and use the provided executable (Don't use
+ // local $PATH).
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- {
- error.SetErrorStringWithFormat("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- else
- {
- if (m_remote_platform_sp)
- {
- error = GetCachedExecutable (resolved_module_spec, exe_module_sp, module_search_paths_ptr, *m_remote_platform_sp);
- }
- else
- {
- // We may connect to a process and use the provided executable (Don't use local $PATH).
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- {
- error.Clear();
- }
- else
- {
- error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
- if (error.Success())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- module_search_paths_ptr,
- NULL,
- NULL);
-
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
- {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- }
- else
- {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- module_search_paths_ptr,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
+ if (resolved_module_spec.GetFileSpec().Exists()) {
+ error.Clear();
+ } else {
+ error.SetErrorStringWithFormat(
+ "the platform is not currently connected, and '%s' doesn't exist "
+ "in the system root.",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+
+ if (error.Success()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, NULL, NULL);
+
+ if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain the architecture %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+ } else {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error =
+ ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
}
+ }
}
+ }
- return error;
+ return error;
}
// From PlatformMacOSX only
-Error
-PlatformNetBSD::GetFileWithUUID (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- if (IsRemote())
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
- }
-
- // Default to the local case
- local_file = platform_file;
- return Error();
+Error PlatformNetBSD::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+ }
+
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
}
-
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformNetBSD::PlatformNetBSD (bool is_host) :
- Platform(is_host),
- m_remote_platform_sp()
-{
-}
-
-bool
-PlatformNetBSD::GetRemoteOSVersion ()
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetOSVersion (m_major_os_version,
- m_minor_os_version,
- m_update_os_version);
- return false;
-}
-
-bool
-PlatformNetBSD::GetRemoteOSBuildString (std::string &s)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString (s);
- s.clear();
- return false;
-}
+PlatformNetBSD::PlatformNetBSD(bool is_host)
+ : Platform(is_host), m_remote_platform_sp() {}
-bool
-PlatformNetBSD::GetRemoteOSKernelDescription (std::string &s)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription (s);
- s.clear();
- return false;
+bool PlatformNetBSD::GetRemoteOSVersion() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetOSVersion(
+ m_major_os_version, m_minor_os_version, m_update_os_version);
+ return false;
+}
+
+bool PlatformNetBSD::GetRemoteOSBuildString(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString(s);
+ s.clear();
+ return false;
+}
+
+bool PlatformNetBSD::GetRemoteOSKernelDescription(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
+ s.clear();
+ return false;
}
// Remote Platform subclasses need to override this function
-ArchSpec
-PlatformNetBSD::GetRemoteSystemArchitecture ()
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture ();
- return ArchSpec();
-}
-
-
-const char *
-PlatformNetBSD::GetHostname ()
-{
- if (IsHost())
- return Platform::GetHostname();
-
+ArchSpec PlatformNetBSD::GetRemoteSystemArchitecture() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture();
+ return ArchSpec();
+}
+
+const char *PlatformNetBSD::GetHostname() {
+ if (IsHost())
+ return Platform::GetHostname();
+
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname();
+ return NULL;
+}
+
+bool PlatformNetBSD::IsConnected() const {
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+Error PlatformNetBSD::ConnectRemote(Args &args) {
+ Error error;
+ if (IsHost()) {
+ error.SetErrorStringWithFormat(
+ "can't connect to the host platform '%s', always connected",
+ GetPluginName().GetCString());
+ } else {
+ if (!m_remote_platform_sp)
+ m_remote_platform_sp =
+ Platform::Create(ConstString("remote-gdb-server"), error);
+
+ if (m_remote_platform_sp) {
+ if (error.Success()) {
+ if (m_remote_platform_sp) {
+ error = m_remote_platform_sp->ConnectRemote(args);
+ } else {
+ error.SetErrorString(
+ "\"platform connect\" takes a single argument: <connect-url>");
+ }
+ }
+ } else
+ error.SetErrorString("failed to create a 'remote-gdb-server' platform");
+
+ if (error.Fail())
+ m_remote_platform_sp.reset();
+ }
+
+ return error;
+}
+
+Error PlatformNetBSD::DisconnectRemote() {
+ Error error;
+
+ if (IsHost()) {
+ error.SetErrorStringWithFormat(
+ "can't disconnect from the host platform '%s', always connected",
+ GetPluginName().GetCString());
+ } else {
if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname ();
- return NULL;
-}
-
-bool
-PlatformNetBSD::IsConnected () const
-{
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
-Error
-PlatformNetBSD::ConnectRemote (Args& args)
-{
- Error error;
- if (IsHost())
- {
- error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString());
- }
+ error = m_remote_platform_sp->DisconnectRemote();
else
- {
- if (!m_remote_platform_sp)
- m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
-
- if (m_remote_platform_sp)
- {
- if (error.Success())
- {
- if (m_remote_platform_sp)
- {
- error = m_remote_platform_sp->ConnectRemote (args);
- }
- else
- {
- error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
- }
- }
- }
- else
- error.SetErrorString ("failed to create a 'remote-gdb-server' platform");
-
- if (error.Fail())
- m_remote_platform_sp.reset();
- }
-
- return error;
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
}
-Error
-PlatformNetBSD::DisconnectRemote ()
-{
- Error error;
-
- if (IsHost())
- {
- error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetPluginName().GetCString());
- }
- else
- {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->DisconnectRemote ();
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return error;
-}
-
-bool
-PlatformNetBSD::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
- bool success = false;
- if (IsHost())
- {
- success = Platform::GetProcessInfo (pid, process_info);
- }
- else if (m_remote_platform_sp)
- {
- success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
- }
- return success;
+bool PlatformNetBSD::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ bool success = false;
+ if (IsHost()) {
+ success = Platform::GetProcessInfo(pid, process_info);
+ } else if (m_remote_platform_sp) {
+ success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ }
+ return success;
}
uint32_t
-PlatformNetBSD::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- uint32_t match_count = 0;
- if (IsHost())
- {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses (match_info, process_infos);
- }
- else
- {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
- }
- return match_count;
-}
-
-const char *
-PlatformNetBSD::GetUserName (uint32_t uid)
-{
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *
-PlatformNetBSD::GetGroupName (uint32_t gid)
-{
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
-}
-
-
-Error
-PlatformNetBSD::GetSharedModule (const ModuleSpec &module_spec,
- Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- Error error;
- module_sp.reset();
-
- if (IsRemote())
- {
- // If we have a remote platform always, let it try and locate
- // the shared module first.
- if (m_remote_platform_sp)
- {
- error = m_remote_platform_sp->GetSharedModule (module_spec,
- process,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr);
+PlatformNetBSD::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ uint32_t match_count = 0;
+ if (IsHost()) {
+ // Let the base class figure out the host details
+ match_count = Platform::FindProcesses(match_info, process_infos);
+ } else {
+ // If we are remote, we can only return results if we are connected
+ if (m_remote_platform_sp)
+ match_count =
+ m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ }
+ return match_count;
+}
+
+const char *PlatformNetBSD::GetUserName(uint32_t uid) {
+ // Check the cache in Platform in case we have already looked this uid up
+ const char *user_name = Platform::GetUserName(uid);
+ if (user_name)
+ return user_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserName(uid);
+ return NULL;
+}
+
+const char *PlatformNetBSD::GetGroupName(uint32_t gid) {
+ const char *group_name = Platform::GetGroupName(gid);
+ if (group_name)
+ return group_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetGroupName(gid);
+ return NULL;
+}
+
+Error PlatformNetBSD::GetSharedModule(
+ const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
+ Error error;
+ module_sp.reset();
+
+ if (IsRemote()) {
+ // If we have a remote platform always, let it try and locate
+ // the shared module first.
+ if (m_remote_platform_sp) {
+ error = m_remote_platform_sp->GetSharedModule(
+ module_spec, process, module_sp, module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ }
+ }
+
+ if (!module_sp) {
+ // Fall back to the local platform and find the file locally
+ error = Platform::GetSharedModule(module_spec, process, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return error;
+}
+
+bool PlatformNetBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ if (IsHost()) {
+ ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ if (hostArch.GetTriple().isOSNetBSD()) {
+ if (idx == 0) {
+ arch = hostArch;
+ return arch.IsValid();
+ } else if (idx == 1) {
+ // If the default host architecture is 64-bit, look for a 32-bit variant
+ if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) {
+ arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ return arch.IsValid();
}
+ }
}
+ } else {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
- if (!module_sp)
- {
- // Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule (module_spec,
- process,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr);
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return error;
-}
-
-
-bool
-PlatformNetBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- if (IsHost())
- {
- ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
- if (hostArch.GetTriple().isOSNetBSD())
- {
- if (idx == 0)
- {
- arch = hostArch;
- return arch.IsValid();
- }
- else if (idx == 1)
- {
- // If the default host architecture is 64-bit, look for a 32-bit variant
- if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit())
- {
- arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
- return arch.IsValid();
- }
- }
- }
- }
- else
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
-
- llvm::Triple triple;
- // Set the OS to NetBSD
- triple.setOS(llvm::Triple::NetBSD);
- // Set the architecture
- switch (idx)
- {
- case 0: triple.setArchName("x86_64"); break;
- case 1: triple.setArchName("i386"); break;
- default: return false;
- }
- // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the vendor by
- // calling triple.SetVendorName("unknown") so that it is a "unspecified unknown".
- // This means when someone calls triple.GetVendorName() it will return an empty string
- // which indicates that the vendor can be set when two architectures are merged
-
- // Now set the triple into "arch" and return true
- arch.SetTriple(triple);
- return true;
- }
- return false;
+ llvm::Triple triple;
+ // Set the OS to NetBSD
+ triple.setOS(llvm::Triple::NetBSD);
+ // Set the architecture
+ switch (idx) {
+ case 0:
+ triple.setArchName("x86_64");
+ break;
+ case 1:
+ triple.setArchName("i386");
+ break;
+ default:
+ return false;
+ }
+ // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
+ // vendor by
+ // calling triple.SetVendorName("unknown") so that it is a "unspecified
+ // unknown".
+ // This means when someone calls triple.GetVendorName() it will return an
+ // empty string
+ // which indicates that the vendor can be set when two architectures are
+ // merged
+
+ // Now set the triple into "arch" and return true
+ arch.SetTriple(triple);
+ return true;
+ }
+ return false;
}
-void
-PlatformNetBSD::GetStatus (Stream &strm)
-{
+void PlatformNetBSD::GetStatus(Stream &strm) {
#ifndef LLDB_DISABLE_POSIX
- struct ::utsname un;
-
- strm << " Host: ";
+ struct ::utsname un;
- ::memset(&un, 0, sizeof(utsname));
- if (::uname(&un) == -1) {
- strm << "NetBSD" << '\n';
- } else {
- strm << un.sysname << ' ' << un.release;
- if (un.nodename[0] != '\0')
- strm << " (" << un.nodename << ')';
- strm << '\n';
+ strm << " Host: ";
- // Dump a common information about the platform status.
- strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version << '\n';
- }
+ ::memset(&un, 0, sizeof(utsname));
+ if (::uname(&un) == -1) {
+ strm << "NetBSD" << '\n';
+ } else {
+ strm << un.sysname << ' ' << un.release;
+ if (un.nodename[0] != '\0')
+ strm << " (" << un.nodename << ')';
+ strm << '\n';
+
+ // Dump a common information about the platform status.
+ strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version
+ << '\n';
+ }
#endif
- Platform::GetStatus(strm);
+ Platform::GetStatus(strm);
}
-void
-PlatformNetBSD::CalculateTrapHandlerSymbolNames ()
-{
- m_trap_handlers.push_back (ConstString ("_sigtramp"));
-}
-
-Error
-PlatformNetBSD::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
- Error error;
- if (IsHost())
- {
- error = Platform::LaunchProcess (launch_info);
- }
- else
- {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess (launch_info);
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return error;
+void PlatformNetBSD::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
}
-lldb::ProcessSP
-PlatformNetBSD::Attach(ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target,
- Error &error)
-{
- lldb::ProcessSP process_sp;
- if (IsHost())
- {
- if (target == NULL)
- {
- TargetSP new_target_sp;
- ArchSpec emptyArchSpec;
-
- error = debugger.GetTargetList().CreateTarget (debugger,
- NULL,
- emptyArchSpec,
- false,
- m_remote_platform_sp,
- new_target_sp);
- target = new_target_sp.get();
- }
- else
- error.Clear();
-
- if (target && error.Success())
- {
- debugger.GetTargetList().SetSelectedTarget(target);
- // The netbsd always currently uses the GDB remote debugger plug-in
- // so even when debugging locally we are debugging remotely!
- // Just like the darwin plugin.
- process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+Error PlatformNetBSD::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Error error;
+ if (IsHost()) {
+ error = Platform::LaunchProcess(launch_info);
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess(launch_info);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
+
+lldb::ProcessSP PlatformNetBSD::Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger, Target *target,
+ Error &error) {
+ lldb::ProcessSP process_sp;
+ if (IsHost()) {
+ if (target == NULL) {
+ TargetSP new_target_sp;
+ ArchSpec emptyArchSpec;
+
+ error = debugger.GetTargetList().CreateTarget(
+ debugger, NULL, emptyArchSpec, false, m_remote_platform_sp,
+ new_target_sp);
+ target = new_target_sp.get();
+ } else
+ error.Clear();
+
+ if (target && error.Success()) {
+ debugger.GetTargetList().SetSelectedTarget(target);
+ // The netbsd always currently uses the GDB remote debugger plug-in
+ // so even when debugging locally we are debugging remotely!
+ // Just like the darwin plugin.
+ process_sp = target->CreateProcess(
+ attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
- if (process_sp)
- error = process_sp->Attach (attach_info);
- }
+ if (process_sp)
+ error = process_sp->Attach(attach_info);
}
+ } else {
+ if (m_remote_platform_sp)
+ process_sp =
+ m_remote_platform_sp->Attach(attach_info, debugger, target, error);
else
- {
- if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return process_sp;
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return process_sp;
}
Modified: lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.h (original)
+++ lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.h Tue Sep 6 15:57:50 2016
@@ -19,153 +19,108 @@
namespace lldb_private {
namespace platform_netbsd {
- class PlatformNetBSD : public Platform
- {
- public:
- PlatformNetBSD (bool is_host);
-
- ~PlatformNetBSD() override = default;
-
- //------------------------------------------------------------
- // Class functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance(bool force, const ArchSpec *arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static ConstString
- GetPluginNameStatic (bool is_host);
-
- static const char *
- GetDescriptionStatic (bool is_host);
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic (IsHost());
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- const char *
- GetDescription () override
- {
- return GetDescriptionStatic(IsHost());
- }
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- bool
- GetModuleSpec(const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec) override;
-
- Error
- RunShellCommand(const char *command,
- const FileSpec &working_dir,
- int *status_ptr,
- int *signo_ptr,
+class PlatformNetBSD : public Platform {
+public:
+ PlatformNetBSD(bool is_host);
+
+ ~PlatformNetBSD() override = default;
+
+ //------------------------------------------------------------
+ // Class functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static ConstString GetPluginNameStatic(bool is_host);
+
+ static const char *GetDescriptionStatic(bool is_host);
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ ConstString GetPluginName() override { return GetPluginNameStatic(IsHost()); }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ const char *GetDescription() override {
+ return GetDescriptionStatic(IsHost());
+ }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
+ ModuleSpec &module_spec) override;
+
+ Error RunShellCommand(const char *command, const FileSpec &working_dir,
+ int *status_ptr, int *signo_ptr,
std::string *command_output,
uint32_t timeout_sec) override;
- Error
- ResolveExecutable(const ModuleSpec &module_spec,
+ Error ResolveExecutable(const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr) override;
- bool
- GetRemoteOSVersion () override;
+ bool GetRemoteOSVersion() override;
- bool
- GetRemoteOSBuildString (std::string &s) override;
+ bool GetRemoteOSBuildString(std::string &s) override;
- bool
- GetRemoteOSKernelDescription (std::string &s) override;
+ bool GetRemoteOSKernelDescription(std::string &s) override;
- // Remote Platform subclasses need to override this function
- ArchSpec
- GetRemoteSystemArchitecture() override;
+ // Remote Platform subclasses need to override this function
+ ArchSpec GetRemoteSystemArchitecture() override;
- bool
- IsConnected () const override;
+ bool IsConnected() const override;
- Error
- ConnectRemote(Args& args) override;
+ Error ConnectRemote(Args &args) override;
- Error
- DisconnectRemote() override;
+ Error DisconnectRemote() override;
- const char *
- GetHostname () override;
+ const char *GetHostname() override;
- const char *
- GetUserName (uint32_t uid) override;
+ const char *GetUserName(uint32_t uid) override;
- const char *
- GetGroupName (uint32_t gid) override;
+ const char *GetGroupName(uint32_t gid) override;
- bool
- GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &proc_info) override;
+ bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
- uint32_t
- FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) override;
+ uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
- Error
- LaunchProcess(ProcessLaunchInfo &launch_info) override;
+ Error LaunchProcess(ProcessLaunchInfo &launch_info) override;
- lldb::ProcessSP
- Attach(ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target,
- Error &error) override;
+ lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
+ Target *target, Error &error) override;
- // NetBSD processes can not be launched by spawning and attaching.
- bool
- CanDebugProcess () override { return false; }
+ // NetBSD processes can not be launched by spawning and attaching.
+ bool CanDebugProcess() override { return false; }
- // Only on PlatformMacOSX:
- Error
- GetFileWithUUID(const FileSpec &platform_file,
- const UUID* uuid, FileSpec &local_file) override;
+ // Only on PlatformMacOSX:
+ Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
+ FileSpec &local_file) override;
- Error
- GetSharedModule(const ModuleSpec &module_spec,
- Process* process,
+ Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
lldb::ModuleSP *old_module_sp_ptr,
bool *did_create_ptr) override;
- bool
- GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
- void
- GetStatus(Stream &strm) override;
+ void GetStatus(Stream &strm) override;
- void
- CalculateTrapHandlerSymbolNames () override;
+ void CalculateTrapHandlerSymbolNames() override;
- protected:
- lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote netbsd OS
+protected:
+ lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
+ // remote netbsd OS
- private:
- DISALLOW_COPY_AND_ASSIGN (PlatformNetBSD);
- };
+private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformNetBSD);
+};
} // namespace platform_netbsd
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Tue Sep 6 15:57:50 2016
@@ -35,18 +35,15 @@
using namespace lldb;
using namespace lldb_private;
-
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformPOSIX::PlatformPOSIX (bool is_host) :
-Platform(is_host), // This is the local host platform
-m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
-m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
-m_option_group_platform_caching(new OptionGroupPlatformCaching()),
-m_remote_platform_sp ()
-{
-}
+PlatformPOSIX::PlatformPOSIX(bool is_host)
+ : Platform(is_host), // This is the local host platform
+ m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
+ m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
+ m_option_group_platform_caching(new OptionGroupPlatformCaching()),
+ m_remote_platform_sp() {}
//------------------------------------------------------------------
/// Destructor.
@@ -54,859 +51,707 @@ m_remote_platform_sp ()
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformPOSIX::~PlatformPOSIX()
-{
-}
-
-bool
-PlatformPOSIX::GetModuleSpec (const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec);
+PlatformPOSIX::~PlatformPOSIX() {}
- return Platform::GetModuleSpec (module_file_spec, arch, module_spec);
-}
-
-lldb_private::OptionGroupOptions*
-PlatformPOSIX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter)
-{
- auto iter = m_options.find(&interpreter), end = m_options.end();
- if (iter == end)
- {
- std::unique_ptr<lldb_private::OptionGroupOptions> options(new OptionGroupOptions());
- options->Append(m_option_group_platform_rsync.get());
- options->Append(m_option_group_platform_ssh.get());
- options->Append(m_option_group_platform_caching.get());
- m_options[&interpreter] = std::move(options);
- }
-
- return m_options.at(&interpreter).get();
-}
-
-bool
-PlatformPOSIX::IsConnected () const
-{
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
+bool PlatformPOSIX::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
+ module_spec);
+
+ return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+}
+
+lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
+ lldb_private::CommandInterpreter &interpreter) {
+ auto iter = m_options.find(&interpreter), end = m_options.end();
+ if (iter == end) {
+ std::unique_ptr<lldb_private::OptionGroupOptions> options(
+ new OptionGroupOptions());
+ options->Append(m_option_group_platform_rsync.get());
+ options->Append(m_option_group_platform_ssh.get());
+ options->Append(m_option_group_platform_caching.get());
+ m_options[&interpreter] = std::move(options);
+ }
+
+ return m_options.at(&interpreter).get();
+}
+
+bool PlatformPOSIX::IsConnected() const {
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+lldb_private::Error PlatformPOSIX::RunShellCommand(
+ const char *command, // Shouldn't be NULL
+ const FileSpec &
+ working_dir, // Pass empty FileSpec to use the current working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the
+ // process to exit
+ std::string
+ *command_output, // Pass NULL if you don't want the command output
+ uint32_t
+ timeout_sec) // Timeout in seconds to wait for shell program to finish
+{
+ if (IsHost())
+ return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
+ command_output, timeout_sec);
+ else {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->RunShellCommand(command, working_dir,
+ status_ptr, signo_ptr,
+ command_output, timeout_sec);
+ else
+ return Error("unable to run a remote command without a platform");
+ }
+}
+
+Error PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
+ else
+ return Platform::MakeDirectory(file_spec, file_permissions);
+}
+
+Error PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFilePermissions(file_spec,
+ file_permissions);
+ else
+ return Platform::GetFilePermissions(file_spec, file_permissions);
+}
+
+Error PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->SetFilePermissions(file_spec,
+ file_permissions);
+ else
+ return Platform::SetFilePermissions(file_spec, file_permissions);
+}
+
+lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec,
+ uint32_t flags, uint32_t mode,
+ Error &error) {
+ if (IsHost())
+ return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
+ else
+ return Platform::OpenFile(file_spec, flags, mode, error);
+}
+
+bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Error &error) {
+ if (IsHost())
+ return FileCache::GetInstance().CloseFile(fd, error);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->CloseFile(fd, error);
+ else
+ return Platform::CloseFile(fd, error);
+}
+
+uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+ uint64_t dst_len, Error &error) {
+ if (IsHost())
+ return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
+ else
+ return Platform::ReadFile(fd, offset, dst, dst_len, error);
+}
+
+uint64_t PlatformPOSIX::WriteFile(lldb::user_id_t fd, uint64_t offset,
+ const void *src, uint64_t src_len,
+ Error &error) {
+ if (IsHost())
+ return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
+ else
+ return Platform::WriteFile(fd, offset, src, src_len, error);
+}
+
+static uint32_t chown_file(Platform *platform, const char *path,
+ uint32_t uid = UINT32_MAX,
+ uint32_t gid = UINT32_MAX) {
+ if (!platform || !path || *path == 0)
+ return UINT32_MAX;
+
+ if (uid == UINT32_MAX && gid == UINT32_MAX)
+ return 0; // pretend I did chown correctly - actually I just didn't care
+
+ StreamString command;
+ command.PutCString("chown ");
+ if (uid != UINT32_MAX)
+ command.Printf("%d", uid);
+ if (gid != UINT32_MAX)
+ command.Printf(":%d", gid);
+ command.Printf("%s", path);
+ int status;
+ platform->RunShellCommand(command.GetData(), NULL, &status, NULL, NULL, 10);
+ return status;
}
lldb_private::Error
-PlatformPOSIX::RunShellCommand(const char *command, // Shouldn't be NULL
- const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec) // Timeout in seconds to wait for shell program to finish
-{
- if (IsHost())
- return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
- else
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
- else
- return Error("unable to run a remote command without a platform");
- }
-}
-
-Error
-PlatformPOSIX::MakeDirectory(const FileSpec &file_spec, uint32_t file_permissions)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
- else
- return Platform::MakeDirectory(file_spec ,file_permissions);
-}
-
-Error
-PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFilePermissions(file_spec, file_permissions);
- else
- return Platform::GetFilePermissions(file_spec ,file_permissions);
-}
-
-Error
-PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->SetFilePermissions(file_spec, file_permissions);
- else
- return Platform::SetFilePermissions(file_spec, file_permissions);
-}
-
-lldb::user_id_t
-PlatformPOSIX::OpenFile (const FileSpec& file_spec,
- uint32_t flags,
- uint32_t mode,
- Error &error)
-{
- if (IsHost())
- return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
- else
- return Platform::OpenFile(file_spec, flags, mode, error);
-}
-
-bool
-PlatformPOSIX::CloseFile (lldb::user_id_t fd, Error &error)
-{
- if (IsHost())
- return FileCache::GetInstance().CloseFile(fd, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->CloseFile(fd, error);
- else
- return Platform::CloseFile(fd, error);
-}
-
-uint64_t
-PlatformPOSIX::ReadFile (lldb::user_id_t fd,
- uint64_t offset,
- void *dst,
- uint64_t dst_len,
- Error &error)
-{
- if (IsHost())
- return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
- else
- return Platform::ReadFile(fd, offset, dst, dst_len, error);
-}
-
-uint64_t
-PlatformPOSIX::WriteFile (lldb::user_id_t fd,
- uint64_t offset,
- const void* src,
- uint64_t src_len,
- Error &error)
-{
- if (IsHost())
- return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
- else
- return Platform::WriteFile(fd, offset, src, src_len, error);
-}
-
-static uint32_t
-chown_file(Platform *platform,
- const char* path,
- uint32_t uid = UINT32_MAX,
- uint32_t gid = UINT32_MAX)
-{
- if (!platform || !path || *path == 0)
- return UINT32_MAX;
-
- if (uid == UINT32_MAX && gid == UINT32_MAX)
- return 0; // pretend I did chown correctly - actually I just didn't care
-
+PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
+ const lldb_private::FileSpec &destination, uint32_t uid,
+ uint32_t gid) {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+
+ if (IsHost()) {
+ if (FileSpec::Equal(source, destination, true))
+ return Error();
+ // cp src dst
+ // chown uid:gid dst
+ std::string src_path(source.GetPath());
+ if (src_path.empty())
+ return Error("unable to get file path for source");
+ std::string dst_path(destination.GetPath());
+ if (dst_path.empty())
+ return Error("unable to get file path for destination");
StreamString command;
- command.PutCString("chown ");
- if (uid != UINT32_MAX)
- command.Printf("%d",uid);
- if (gid != UINT32_MAX)
- command.Printf(":%d",gid);
- command.Printf("%s",path);
+ command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
- platform->RunShellCommand(command.GetData(),
- NULL,
- &status,
- NULL,
- NULL,
- 10);
- return status;
-}
-
-lldb_private::Error
-PlatformPOSIX::PutFile (const lldb_private::FileSpec& source,
- const lldb_private::FileSpec& destination,
- uint32_t uid,
- uint32_t gid)
-{
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
-
- if (IsHost())
- {
- if (FileSpec::Equal(source, destination, true))
- return Error();
- // cp src dst
- // chown uid:gid dst
- std::string src_path (source.GetPath());
- if (src_path.empty())
- return Error("unable to get file path for source");
- std::string dst_path (destination.GetPath());
- if (dst_path.empty())
- return Error("unable to get file path for destination");
- StreamString command;
- command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
- int status;
- RunShellCommand(command.GetData(),
- NULL,
- &status,
- NULL,
- NULL,
- 10);
- if (status != 0)
- return Error("unable to perform copy");
- if (uid == UINT32_MAX && gid == UINT32_MAX)
- return Error();
- if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
- return Error("unable to perform chown");
- return Error();
- }
- else if (m_remote_platform_sp)
- {
- if (GetSupportsRSync())
- {
- std::string src_path (source.GetPath());
- if (src_path.empty())
- return Error("unable to get file path for source");
- std::string dst_path (destination.GetPath());
- if (dst_path.empty())
- return Error("unable to get file path for destination");
- StreamString command;
- if (GetIgnoresRemoteHostname())
- {
- if (!GetRSyncPrefix())
- command.Printf("rsync %s %s %s",
- GetRSyncOpts(),
- src_path.c_str(),
- dst_path.c_str());
- else
- command.Printf("rsync %s %s %s%s",
- GetRSyncOpts(),
- src_path.c_str(),
- GetRSyncPrefix(),
- dst_path.c_str());
- }
- else
- command.Printf("rsync %s %s %s:%s",
- GetRSyncOpts(),
- src_path.c_str(),
- GetHostname(),
- dst_path.c_str());
- if (log)
- log->Printf("[PutFile] Running command: %s\n", command.GetData());
- int retcode;
- Host::RunShellCommand(command.GetData(),
- NULL,
- &retcode,
- NULL,
- NULL,
- 60);
- if (retcode == 0)
- {
- // Don't chown a local file for a remote system
-// if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
-// return Error("unable to perform chown");
- return Error();
- }
- // if we are still here rsync has failed - let's try the slow way before giving up
- }
- }
- return Platform::PutFile(source,destination,uid,gid);
-}
-
-lldb::user_id_t
-PlatformPOSIX::GetFileSize (const FileSpec& file_spec)
-{
- if (IsHost())
- return FileSystem::GetFileSize(file_spec);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileSize(file_spec);
- else
- return Platform::GetFileSize(file_spec);
-}
-
-Error
-PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst)
-{
- if (IsHost())
- return FileSystem::Symlink(src, dst);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->CreateSymlink(src, dst);
- else
- return Platform::CreateSymlink(src, dst);
-}
-
-bool
-PlatformPOSIX::GetFileExists (const FileSpec& file_spec)
-{
- if (IsHost())
- return file_spec.Exists();
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileExists(file_spec);
- else
- return Platform::GetFileExists(file_spec);
-}
-
-Error
-PlatformPOSIX::Unlink(const FileSpec &file_spec)
-{
- if (IsHost())
- return FileSystem::Unlink(file_spec);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->Unlink(file_spec);
- else
- return Platform::Unlink(file_spec);
-}
-
-lldb_private::Error
-PlatformPOSIX::GetFile(const lldb_private::FileSpec &source, // remote file path
- const lldb_private::FileSpec &destination) // local file path
-{
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
-
- // Check the args, first.
- std::string src_path (source.GetPath());
- if (src_path.empty())
+ RunShellCommand(command.GetData(), NULL, &status, NULL, NULL, 10);
+ if (status != 0)
+ return Error("unable to perform copy");
+ if (uid == UINT32_MAX && gid == UINT32_MAX)
+ return Error();
+ if (chown_file(this, dst_path.c_str(), uid, gid) != 0)
+ return Error("unable to perform chown");
+ return Error();
+ } else if (m_remote_platform_sp) {
+ if (GetSupportsRSync()) {
+ std::string src_path(source.GetPath());
+ if (src_path.empty())
return Error("unable to get file path for source");
- std::string dst_path (destination.GetPath());
- if (dst_path.empty())
+ std::string dst_path(destination.GetPath());
+ if (dst_path.empty())
return Error("unable to get file path for destination");
- if (IsHost())
- {
- if (FileSpec::Equal(source, destination, true))
- return Error("local scenario->source and destination are the same file path: no operation performed");
- // cp src dst
- StreamString cp_command;
- cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
- int status;
- RunShellCommand(cp_command.GetData(),
- NULL,
- &status,
- NULL,
- NULL,
- 10);
- if (status != 0)
- return Error("unable to perform copy");
+ StreamString command;
+ if (GetIgnoresRemoteHostname()) {
+ if (!GetRSyncPrefix())
+ command.Printf("rsync %s %s %s", GetRSyncOpts(), src_path.c_str(),
+ dst_path.c_str());
+ else
+ command.Printf("rsync %s %s %s%s", GetRSyncOpts(), src_path.c_str(),
+ GetRSyncPrefix(), dst_path.c_str());
+ } else
+ command.Printf("rsync %s %s %s:%s", GetRSyncOpts(), src_path.c_str(),
+ GetHostname(), dst_path.c_str());
+ if (log)
+ log->Printf("[PutFile] Running command: %s\n", command.GetData());
+ int retcode;
+ Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL, 60);
+ if (retcode == 0) {
+ // Don't chown a local file for a remote system
+ // if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
+ // return Error("unable to perform chown");
return Error();
+ }
+ // if we are still here rsync has failed - let's try the slow way before
+ // giving up
+ }
+ }
+ return Platform::PutFile(source, destination, uid, gid);
+}
+
+lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) {
+ if (IsHost())
+ return FileSystem::GetFileSize(file_spec);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileSize(file_spec);
+ else
+ return Platform::GetFileSize(file_spec);
+}
+
+Error PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) {
+ if (IsHost())
+ return FileSystem::Symlink(src, dst);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->CreateSymlink(src, dst);
+ else
+ return Platform::CreateSymlink(src, dst);
+}
+
+bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) {
+ if (IsHost())
+ return file_spec.Exists();
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileExists(file_spec);
+ else
+ return Platform::GetFileExists(file_spec);
+}
+
+Error PlatformPOSIX::Unlink(const FileSpec &file_spec) {
+ if (IsHost())
+ return FileSystem::Unlink(file_spec);
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->Unlink(file_spec);
+ else
+ return Platform::Unlink(file_spec);
+}
+
+lldb_private::Error PlatformPOSIX::GetFile(
+ const lldb_private::FileSpec &source, // remote file path
+ const lldb_private::FileSpec &destination) // local file path
+{
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+
+ // Check the args, first.
+ std::string src_path(source.GetPath());
+ if (src_path.empty())
+ return Error("unable to get file path for source");
+ std::string dst_path(destination.GetPath());
+ if (dst_path.empty())
+ return Error("unable to get file path for destination");
+ if (IsHost()) {
+ if (FileSpec::Equal(source, destination, true))
+ return Error("local scenario->source and destination are the same file "
+ "path: no operation performed");
+ // cp src dst
+ StreamString cp_command;
+ cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
+ int status;
+ RunShellCommand(cp_command.GetData(), NULL, &status, NULL, NULL, 10);
+ if (status != 0)
+ return Error("unable to perform copy");
+ return Error();
+ } else if (m_remote_platform_sp) {
+ if (GetSupportsRSync()) {
+ StreamString command;
+ if (GetIgnoresRemoteHostname()) {
+ if (!GetRSyncPrefix())
+ command.Printf("rsync %s %s %s", GetRSyncOpts(), src_path.c_str(),
+ dst_path.c_str());
+ else
+ command.Printf("rsync %s %s%s %s", GetRSyncOpts(), GetRSyncPrefix(),
+ src_path.c_str(), dst_path.c_str());
+ } else
+ command.Printf("rsync %s %s:%s %s", GetRSyncOpts(),
+ m_remote_platform_sp->GetHostname(), src_path.c_str(),
+ dst_path.c_str());
+ if (log)
+ log->Printf("[GetFile] Running command: %s\n", command.GetData());
+ int retcode;
+ Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL, 60);
+ if (retcode == 0)
+ return Error();
+ // If we are here, rsync has failed - let's try the slow way before giving
+ // up
}
- else if (m_remote_platform_sp)
- {
- if (GetSupportsRSync())
- {
- StreamString command;
- if (GetIgnoresRemoteHostname())
- {
- if (!GetRSyncPrefix())
- command.Printf("rsync %s %s %s",
- GetRSyncOpts(),
- src_path.c_str(),
- dst_path.c_str());
- else
- command.Printf("rsync %s %s%s %s",
- GetRSyncOpts(),
- GetRSyncPrefix(),
- src_path.c_str(),
- dst_path.c_str());
- }
- else
- command.Printf("rsync %s %s:%s %s",
- GetRSyncOpts(),
- m_remote_platform_sp->GetHostname(),
- src_path.c_str(),
- dst_path.c_str());
- if (log)
- log->Printf("[GetFile] Running command: %s\n", command.GetData());
- int retcode;
- Host::RunShellCommand(command.GetData(),
- NULL,
- &retcode,
- NULL,
- NULL,
- 60);
- if (retcode == 0)
- return Error();
- // If we are here, rsync has failed - let's try the slow way before giving up
- }
- // open src and dst
- // read/write, read/write, read/write, ...
- // close src
- // close dst
- if (log)
- log->Printf("[GetFile] Using block by block transfer....\n");
- Error error;
- user_id_t fd_src = OpenFile (source,
- File::eOpenOptionRead,
- lldb::eFilePermissionsFileDefault,
- error);
-
- if (fd_src == UINT64_MAX)
- return Error("unable to open source file");
-
- uint32_t permissions = 0;
- error = GetFilePermissions(source, permissions);
-
- if (permissions == 0)
- permissions = lldb::eFilePermissionsFileDefault;
-
- user_id_t fd_dst = FileCache::GetInstance().OpenFile(
- destination, File::eOpenOptionCanCreate | File::eOpenOptionWrite | File::eOpenOptionTruncate, permissions,
- error);
-
- if (fd_dst == UINT64_MAX)
- {
- if (error.Success())
- error.SetErrorString("unable to open destination file");
- }
-
- if (error.Success())
- {
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
- uint64_t offset = 0;
- error.Clear();
- while (error.Success())
- {
- const uint64_t n_read = ReadFile (fd_src,
- offset,
- buffer_sp->GetBytes(),
- buffer_sp->GetByteSize(),
- error);
- if (error.Fail())
- break;
- if (n_read == 0)
- break;
- if (FileCache::GetInstance().WriteFile(fd_dst, offset, buffer_sp->GetBytes(), n_read, error) != n_read)
- {
- if (!error.Fail())
- error.SetErrorString("unable to write to destination file");
- break;
- }
- offset += n_read;
- }
- }
- // Ignore the close error of src.
- if (fd_src != UINT64_MAX)
- CloseFile(fd_src, error);
- // And close the dst file descriptot.
- if (fd_dst != UINT64_MAX && !FileCache::GetInstance().CloseFile(fd_dst, error))
- {
- if (!error.Fail())
- error.SetErrorString("unable to close destination file");
-
- }
- return error;
- }
- return Platform::GetFile(source,destination);
-}
-
-std::string
-PlatformPOSIX::GetPlatformSpecificConnectionInformation()
-{
- StreamString stream;
- if (GetSupportsRSync())
- {
- stream.PutCString("rsync");
- if ( (GetRSyncOpts() && *GetRSyncOpts()) ||
- (GetRSyncPrefix() && *GetRSyncPrefix()) ||
- GetIgnoresRemoteHostname())
- {
- stream.Printf(", options: ");
- if (GetRSyncOpts() && *GetRSyncOpts())
- stream.Printf("'%s' ",GetRSyncOpts());
- stream.Printf(", prefix: ");
- if (GetRSyncPrefix() && *GetRSyncPrefix())
- stream.Printf("'%s' ",GetRSyncPrefix());
- if (GetIgnoresRemoteHostname())
- stream.Printf("ignore remote-hostname ");
- }
- }
- if (GetSupportsSSH())
- {
- stream.PutCString("ssh");
- if (GetSSHOpts() && *GetSSHOpts())
- stream.Printf(", options: '%s' ",GetSSHOpts());
- }
- if (GetLocalCacheDirectory() && *GetLocalCacheDirectory())
- stream.Printf("cache dir: %s",GetLocalCacheDirectory());
- if (stream.GetSize())
- return stream.GetData();
- else
- return "";
-}
-
-bool
-PlatformPOSIX::CalculateMD5 (const FileSpec& file_spec,
- uint64_t &low,
- uint64_t &high)
-{
- if (IsHost())
- return Platform::CalculateMD5 (file_spec, low, high);
- if (m_remote_platform_sp)
- return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
- return false;
-}
-
-const lldb::UnixSignalsSP &
-PlatformPOSIX::GetRemoteUnixSignals() {
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteUnixSignals();
- return Platform::GetRemoteUnixSignals();
-}
-
-
-FileSpec
-PlatformPOSIX::GetRemoteWorkingDirectory()
-{
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteWorkingDirectory();
- else
- return Platform::GetRemoteWorkingDirectory();
-}
+ // open src and dst
+ // read/write, read/write, read/write, ...
+ // close src
+ // close dst
+ if (log)
+ log->Printf("[GetFile] Using block by block transfer....\n");
+ Error error;
+ user_id_t fd_src = OpenFile(source, File::eOpenOptionRead,
+ lldb::eFilePermissionsFileDefault, error);
-bool
-PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir)
-{
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
- else
- return Platform::SetRemoteWorkingDirectory(working_dir);
-}
+ if (fd_src == UINT64_MAX)
+ return Error("unable to open source file");
-bool
-PlatformPOSIX::GetRemoteOSVersion ()
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetOSVersion (m_major_os_version,
- m_minor_os_version,
- m_update_os_version);
- return false;
-}
+ uint32_t permissions = 0;
+ error = GetFilePermissions(source, permissions);
-bool
-PlatformPOSIX::GetRemoteOSBuildString (std::string &s)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString (s);
- s.clear();
- return false;
-}
-
-size_t
-PlatformPOSIX::GetEnvironment (StringList &env)
-{
- if (IsRemote())
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetEnvironment(env);
- return 0;
+ if (permissions == 0)
+ permissions = lldb::eFilePermissionsFileDefault;
+
+ user_id_t fd_dst = FileCache::GetInstance().OpenFile(
+ destination, File::eOpenOptionCanCreate | File::eOpenOptionWrite |
+ File::eOpenOptionTruncate,
+ permissions, error);
+
+ if (fd_dst == UINT64_MAX) {
+ if (error.Success())
+ error.SetErrorString("unable to open destination file");
+ }
+
+ if (error.Success()) {
+ lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
+ uint64_t offset = 0;
+ error.Clear();
+ while (error.Success()) {
+ const uint64_t n_read = ReadFile(fd_src, offset, buffer_sp->GetBytes(),
+ buffer_sp->GetByteSize(), error);
+ if (error.Fail())
+ break;
+ if (n_read == 0)
+ break;
+ if (FileCache::GetInstance().WriteFile(fd_dst, offset,
+ buffer_sp->GetBytes(), n_read,
+ error) != n_read) {
+ if (!error.Fail())
+ error.SetErrorString("unable to write to destination file");
+ break;
+ }
+ offset += n_read;
+ }
+ }
+ // Ignore the close error of src.
+ if (fd_src != UINT64_MAX)
+ CloseFile(fd_src, error);
+ // And close the dst file descriptot.
+ if (fd_dst != UINT64_MAX &&
+ !FileCache::GetInstance().CloseFile(fd_dst, error)) {
+ if (!error.Fail())
+ error.SetErrorString("unable to close destination file");
}
- return Host::GetEnvironment(env);
+ return error;
+ }
+ return Platform::GetFile(source, destination);
}
-bool
-PlatformPOSIX::GetRemoteOSKernelDescription (std::string &s)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription (s);
- s.clear();
- return false;
+std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
+ StreamString stream;
+ if (GetSupportsRSync()) {
+ stream.PutCString("rsync");
+ if ((GetRSyncOpts() && *GetRSyncOpts()) ||
+ (GetRSyncPrefix() && *GetRSyncPrefix()) || GetIgnoresRemoteHostname()) {
+ stream.Printf(", options: ");
+ if (GetRSyncOpts() && *GetRSyncOpts())
+ stream.Printf("'%s' ", GetRSyncOpts());
+ stream.Printf(", prefix: ");
+ if (GetRSyncPrefix() && *GetRSyncPrefix())
+ stream.Printf("'%s' ", GetRSyncPrefix());
+ if (GetIgnoresRemoteHostname())
+ stream.Printf("ignore remote-hostname ");
+ }
+ }
+ if (GetSupportsSSH()) {
+ stream.PutCString("ssh");
+ if (GetSSHOpts() && *GetSSHOpts())
+ stream.Printf(", options: '%s' ", GetSSHOpts());
+ }
+ if (GetLocalCacheDirectory() && *GetLocalCacheDirectory())
+ stream.Printf("cache dir: %s", GetLocalCacheDirectory());
+ if (stream.GetSize())
+ return stream.GetData();
+ else
+ return "";
+}
+
+bool PlatformPOSIX::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+ uint64_t &high) {
+ if (IsHost())
+ return Platform::CalculateMD5(file_spec, low, high);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
+ return false;
+}
+
+const lldb::UnixSignalsSP &PlatformPOSIX::GetRemoteUnixSignals() {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteUnixSignals();
+ return Platform::GetRemoteUnixSignals();
+}
+
+FileSpec PlatformPOSIX::GetRemoteWorkingDirectory() {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteWorkingDirectory();
+ else
+ return Platform::GetRemoteWorkingDirectory();
+}
+
+bool PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
+ else
+ return Platform::SetRemoteWorkingDirectory(working_dir);
+}
+
+bool PlatformPOSIX::GetRemoteOSVersion() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetOSVersion(
+ m_major_os_version, m_minor_os_version, m_update_os_version);
+ return false;
+}
+
+bool PlatformPOSIX::GetRemoteOSBuildString(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString(s);
+ s.clear();
+ return false;
+}
+
+size_t PlatformPOSIX::GetEnvironment(StringList &env) {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetEnvironment(env);
+ return 0;
+ }
+ return Host::GetEnvironment(env);
+}
+
+bool PlatformPOSIX::GetRemoteOSKernelDescription(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
+ s.clear();
+ return false;
}
// Remote Platform subclasses need to override this function
-ArchSpec
-PlatformPOSIX::GetRemoteSystemArchitecture ()
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture ();
- return ArchSpec();
+ArchSpec PlatformPOSIX::GetRemoteSystemArchitecture() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture();
+ return ArchSpec();
}
-const char *
-PlatformPOSIX::GetHostname ()
-{
- if (IsHost())
- return Platform::GetHostname();
+const char *PlatformPOSIX::GetHostname() {
+ if (IsHost())
+ return Platform::GetHostname();
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname ();
- return NULL;
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname();
+ return NULL;
}
-const char *
-PlatformPOSIX::GetUserName (uint32_t uid)
-{
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *
-PlatformPOSIX::GetGroupName (uint32_t gid)
-{
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
+const char *PlatformPOSIX::GetUserName(uint32_t uid) {
+ // Check the cache in Platform in case we have already looked this uid up
+ const char *user_name = Platform::GetUserName(uid);
+ if (user_name)
+ return user_name;
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserName(uid);
+ return NULL;
}
-Error
-PlatformPOSIX::ConnectRemote (Args& args)
-{
- Error error;
- if (IsHost())
- {
- error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().GetCString());
- }
- else
- {
- if (!m_remote_platform_sp)
- m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
-
- if (m_remote_platform_sp && error.Success())
- error = m_remote_platform_sp->ConnectRemote (args);
- else
- error.SetErrorString ("failed to create a 'remote-gdb-server' platform");
-
- if (error.Fail())
- m_remote_platform_sp.reset();
- }
+const char *PlatformPOSIX::GetGroupName(uint32_t gid) {
+ const char *group_name = Platform::GetGroupName(gid);
+ if (group_name)
+ return group_name;
- if (error.Success() && m_remote_platform_sp)
- {
- if (m_option_group_platform_rsync.get() && m_option_group_platform_ssh.get() && m_option_group_platform_caching.get())
- {
- if (m_option_group_platform_rsync->m_rsync)
- {
- SetSupportsRSync(true);
- SetRSyncOpts(m_option_group_platform_rsync->m_rsync_opts.c_str());
- SetRSyncPrefix(m_option_group_platform_rsync->m_rsync_prefix.c_str());
- SetIgnoresRemoteHostname(m_option_group_platform_rsync->m_ignores_remote_hostname);
- }
- if (m_option_group_platform_ssh->m_ssh)
- {
- SetSupportsSSH(true);
- SetSSHOpts(m_option_group_platform_ssh->m_ssh_opts.c_str());
- }
- SetLocalCacheDirectory(m_option_group_platform_caching->m_cache_dir.c_str());
- }
- }
-
- return error;
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetGroupName(gid);
+ return NULL;
}
-Error
-PlatformPOSIX::DisconnectRemote ()
-{
- Error error;
+Error PlatformPOSIX::ConnectRemote(Args &args) {
+ Error error;
+ if (IsHost()) {
+ error.SetErrorStringWithFormat(
+ "can't connect to the host platform '%s', always connected",
+ GetPluginName().GetCString());
+ } else {
+ if (!m_remote_platform_sp)
+ m_remote_platform_sp =
+ Platform::Create(ConstString("remote-gdb-server"), error);
- if (IsHost())
- {
- error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetPluginName().GetCString());
- }
+ if (m_remote_platform_sp && error.Success())
+ error = m_remote_platform_sp->ConnectRemote(args);
else
- {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->DisconnectRemote ();
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return error;
-}
-
-Error
-PlatformPOSIX::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
- Error error;
-
- if (IsHost())
- {
- error = Platform::LaunchProcess (launch_info);
- }
- else
- {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess (launch_info);
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return error;
-}
+ error.SetErrorString("failed to create a 'remote-gdb-server' platform");
-lldb_private::Error
-PlatformPOSIX::KillProcess (const lldb::pid_t pid)
-{
- if (IsHost())
- return Platform::KillProcess (pid);
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->KillProcess (pid);
+ if (error.Fail())
+ m_remote_platform_sp.reset();
+ }
- return Error ("the platform is not currently connected");
+ if (error.Success() && m_remote_platform_sp) {
+ if (m_option_group_platform_rsync.get() &&
+ m_option_group_platform_ssh.get() &&
+ m_option_group_platform_caching.get()) {
+ if (m_option_group_platform_rsync->m_rsync) {
+ SetSupportsRSync(true);
+ SetRSyncOpts(m_option_group_platform_rsync->m_rsync_opts.c_str());
+ SetRSyncPrefix(m_option_group_platform_rsync->m_rsync_prefix.c_str());
+ SetIgnoresRemoteHostname(
+ m_option_group_platform_rsync->m_ignores_remote_hostname);
+ }
+ if (m_option_group_platform_ssh->m_ssh) {
+ SetSupportsSSH(true);
+ SetSSHOpts(m_option_group_platform_ssh->m_ssh_opts.c_str());
+ }
+ SetLocalCacheDirectory(
+ m_option_group_platform_caching->m_cache_dir.c_str());
+ }
+ }
+
+ return error;
+}
+
+Error PlatformPOSIX::DisconnectRemote() {
+ Error error;
+
+ if (IsHost()) {
+ error.SetErrorStringWithFormat(
+ "can't disconnect from the host platform '%s', always connected",
+ GetPluginName().GetCString());
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->DisconnectRemote();
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
+
+Error PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Error error;
+
+ if (IsHost()) {
+ error = Platform::LaunchProcess(launch_info);
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess(launch_info);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
+
+lldb_private::Error PlatformPOSIX::KillProcess(const lldb::pid_t pid) {
+ if (IsHost())
+ return Platform::KillProcess(pid);
+
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->KillProcess(pid);
+
+ return Error("the platform is not currently connected");
+}
+
+lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger, Target *target,
+ Error &error) {
+ lldb::ProcessSP process_sp;
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+
+ if (IsHost()) {
+ if (target == NULL) {
+ TargetSP new_target_sp;
+
+ error = debugger.GetTargetList().CreateTarget(debugger, NULL, NULL, false,
+ NULL, new_target_sp);
+ target = new_target_sp.get();
+ if (log)
+ log->Printf("PlatformPOSIX::%s created new target", __FUNCTION__);
+ } else {
+ error.Clear();
+ if (log)
+ log->Printf("PlatformPOSIX::%s target already existed, setting target",
+ __FUNCTION__);
+ }
+
+ if (target && error.Success()) {
+ debugger.GetTargetList().SetSelectedTarget(target);
+ if (log) {
+ ModuleSP exe_module_sp = target->GetExecutableModule();
+ log->Printf("PlatformPOSIX::%s set selected target to %p %s",
+ __FUNCTION__, (void *)target,
+ exe_module_sp
+ ? exe_module_sp->GetFileSpec().GetPath().c_str()
+ : "<null>");
+ }
+
+ process_sp =
+ target->CreateProcess(attach_info.GetListenerForProcess(debugger),
+ attach_info.GetProcessPluginName(), NULL);
+
+ if (process_sp) {
+ ListenerSP listener_sp = attach_info.GetHijackListener();
+ if (listener_sp == nullptr) {
+ listener_sp =
+ Listener::MakeListener("lldb.PlatformPOSIX.attach.hijack");
+ attach_info.SetHijackListener(listener_sp);
+ }
+ process_sp->HijackProcessEvents(listener_sp);
+ error = process_sp->Attach(attach_info);
+ }
+ }
+ } else {
+ if (m_remote_platform_sp)
+ process_sp =
+ m_remote_platform_sp->Attach(attach_info, debugger, target, error);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return process_sp;
}
lldb::ProcessSP
-PlatformPOSIX::Attach (ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target,
- Error &error)
-{
- lldb::ProcessSP process_sp;
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
-
- if (IsHost())
- {
- if (target == NULL)
- {
- TargetSP new_target_sp;
-
- error = debugger.GetTargetList().CreateTarget (debugger,
- NULL,
- NULL,
- false,
- NULL,
- new_target_sp);
- target = new_target_sp.get();
- if (log)
- log->Printf ("PlatformPOSIX::%s created new target", __FUNCTION__);
- }
- else
- {
- error.Clear();
- if (log)
- log->Printf ("PlatformPOSIX::%s target already existed, setting target", __FUNCTION__);
- }
-
- if (target && error.Success())
- {
- debugger.GetTargetList().SetSelectedTarget(target);
- if (log)
- {
- ModuleSP exe_module_sp = target->GetExecutableModule ();
- log->Printf("PlatformPOSIX::%s set selected target to %p %s", __FUNCTION__, (void *)target,
- exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str() : "<null>");
- }
-
-
- process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), attach_info.GetProcessPluginName(), NULL);
-
- if (process_sp)
- {
- ListenerSP listener_sp = attach_info.GetHijackListener();
- if (listener_sp == nullptr)
- {
- listener_sp = Listener::MakeListener("lldb.PlatformPOSIX.attach.hijack");
- attach_info.SetHijackListener(listener_sp);
- }
- process_sp->HijackProcessEvents(listener_sp);
- error = process_sp->Attach (attach_info);
- }
- }
- }
- else
- {
- if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return process_sp;
-}
-
-lldb::ProcessSP
-PlatformPOSIX::DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error)
-{
- ProcessSP process_sp;
-
- if (IsHost())
- {
- // We are going to hand this process off to debugserver which will be in charge of setting the exit status.
- // We still need to reap it from lldb but if we let the monitor thread also set the exit status, we set up a
- // race between debugserver & us for who will find out about the debugged process's death.
- launch_info.GetFlags().Set(eLaunchFlagDontSetExitStatus);
- process_sp = Platform::DebugProcess (launch_info, debugger, target, error);
- }
- else
- {
- if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->DebugProcess (launch_info, debugger, target, error);
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return process_sp;
-
-}
-
-void
-PlatformPOSIX::CalculateTrapHandlerSymbolNames ()
-{
- m_trap_handlers.push_back (ConstString ("_sigtramp"));
-}
-
-Error
-PlatformPOSIX::EvaluateLibdlExpression(lldb_private::Process* process,
- const char* expr_cstr,
- const char* expr_prefix,
- lldb::ValueObjectSP& result_valobj_sp)
-{
- DynamicLoader *loader = process->GetDynamicLoader();
- if (loader)
- {
- Error error = loader->CanLoadImage();
- if (error.Fail())
- return error;
- }
-
- ThreadSP thread_sp(process->GetThreadList().GetExpressionExecutionThread());
- if (!thread_sp)
- return Error("Selected thread isn't valid");
-
- StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
- if (!frame_sp)
- return Error("Frame 0 isn't valid");
-
- ExecutionContext exe_ctx;
- frame_sp->CalculateExecutionContext(exe_ctx);
- EvaluateExpressionOptions expr_options;
- expr_options.SetUnwindOnError(true);
- expr_options.SetIgnoreBreakpoints(true);
- expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
- expr_options.SetLanguage(eLanguageTypeC_plus_plus);
- expr_options.SetTrapExceptions(false); // dlopen can't throw exceptions, so don't do the work to trap them.
- expr_options.SetTimeoutUsec(2000000); // 2 seconds
-
- Error expr_error;
- UserExpression::Evaluate(exe_ctx,
- expr_options,
- expr_cstr,
- expr_prefix,
- result_valobj_sp,
- expr_error);
- if (result_valobj_sp->GetError().Fail())
- return result_valobj_sp->GetError();
- return Error();
-}
+PlatformPOSIX::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new
+ // target, else use existing one
+ Error &error) {
+ ProcessSP process_sp;
+
+ if (IsHost()) {
+ // We are going to hand this process off to debugserver which will be in
+ // charge of setting the exit status.
+ // We still need to reap it from lldb but if we let the monitor thread also
+ // set the exit status, we set up a
+ // race between debugserver & us for who will find out about the debugged
+ // process's death.
+ launch_info.GetFlags().Set(eLaunchFlagDontSetExitStatus);
+ process_sp = Platform::DebugProcess(launch_info, debugger, target, error);
+ } else {
+ if (m_remote_platform_sp)
+ process_sp = m_remote_platform_sp->DebugProcess(launch_info, debugger,
+ target, error);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return process_sp;
+}
+
+void PlatformPOSIX::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
+}
+
+Error PlatformPOSIX::EvaluateLibdlExpression(
+ lldb_private::Process *process, const char *expr_cstr,
+ const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp) {
+ DynamicLoader *loader = process->GetDynamicLoader();
+ if (loader) {
+ Error error = loader->CanLoadImage();
+ if (error.Fail())
+ return error;
+ }
-uint32_t
-PlatformPOSIX::DoLoadImage(lldb_private::Process* process,
- const lldb_private::FileSpec& remote_file,
- lldb_private::Error& error)
-{
- char path[PATH_MAX];
- remote_file.GetPath(path, sizeof(path));
+ ThreadSP thread_sp(process->GetThreadList().GetExpressionExecutionThread());
+ if (!thread_sp)
+ return Error("Selected thread isn't valid");
+
+ StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
+ if (!frame_sp)
+ return Error("Frame 0 isn't valid");
+
+ ExecutionContext exe_ctx;
+ frame_sp->CalculateExecutionContext(exe_ctx);
+ EvaluateExpressionOptions expr_options;
+ expr_options.SetUnwindOnError(true);
+ expr_options.SetIgnoreBreakpoints(true);
+ expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
+ expr_options.SetLanguage(eLanguageTypeC_plus_plus);
+ expr_options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
+ // don't do the work to trap them.
+ expr_options.SetTimeoutUsec(2000000); // 2 seconds
+
+ Error expr_error;
+ UserExpression::Evaluate(exe_ctx, expr_options, expr_cstr, expr_prefix,
+ result_valobj_sp, expr_error);
+ if (result_valobj_sp->GetError().Fail())
+ return result_valobj_sp->GetError();
+ return Error();
+}
+
+uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
+ const lldb_private::FileSpec &remote_file,
+ lldb_private::Error &error) {
+ char path[PATH_MAX];
+ remote_file.GetPath(path, sizeof(path));
- StreamString expr;
- expr.Printf(R"(
+ StreamString expr;
+ expr.Printf(R"(
struct __lldb_dlopen_result { void *image_ptr; const char *error_str; } the_result;
the_result.image_ptr = dlopen ("%s", 2);
if (the_result.image_ptr == (void *) 0x0)
@@ -919,96 +764,89 @@ PlatformPOSIX::DoLoadImage(lldb_private:
}
the_result;
)",
- path);
- const char *prefix = GetLibdlFunctionDeclarations();
- lldb::ValueObjectSP result_valobj_sp;
- error = EvaluateLibdlExpression(process, expr.GetData(), prefix, result_valobj_sp);
- if (error.Fail())
- return LLDB_INVALID_IMAGE_TOKEN;
-
- error = result_valobj_sp->GetError();
- if (error.Fail())
- return LLDB_INVALID_IMAGE_TOKEN;
+ path);
+ const char *prefix = GetLibdlFunctionDeclarations();
+ lldb::ValueObjectSP result_valobj_sp;
+ error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
+ result_valobj_sp);
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
- Scalar scalar;
- ValueObjectSP image_ptr_sp = result_valobj_sp->GetChildAtIndex(0, true);
- if (!image_ptr_sp || !image_ptr_sp->ResolveValue(scalar))
- {
- error.SetErrorStringWithFormat("unable to load '%s'", path);
- return LLDB_INVALID_IMAGE_TOKEN;
- }
+ error = result_valobj_sp->GetError();
+ if (error.Fail())
+ return LLDB_INVALID_IMAGE_TOKEN;
- addr_t image_ptr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
- if (image_ptr != 0 && image_ptr != LLDB_INVALID_ADDRESS)
- return process->AddImageToken(image_ptr);
-
- if (image_ptr == 0)
- {
- ValueObjectSP error_str_sp = result_valobj_sp->GetChildAtIndex(1, true);
- if (error_str_sp)
- {
- DataBufferSP buffer_sp(new DataBufferHeap(10240,0));
- size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240).first;
- if (error.Success() && num_chars > 0)
- error.SetErrorStringWithFormat("dlopen error: %s", buffer_sp->GetBytes());
- else
- error.SetErrorStringWithFormat("dlopen failed for unknown reasons.");
- return LLDB_INVALID_IMAGE_TOKEN;
- }
- }
+ Scalar scalar;
+ ValueObjectSP image_ptr_sp = result_valobj_sp->GetChildAtIndex(0, true);
+ if (!image_ptr_sp || !image_ptr_sp->ResolveValue(scalar)) {
error.SetErrorStringWithFormat("unable to load '%s'", path);
return LLDB_INVALID_IMAGE_TOKEN;
-}
+ }
-Error
-PlatformPOSIX::UnloadImage (lldb_private::Process* process, uint32_t image_token)
-{
- const addr_t image_addr = process->GetImagePtrFromToken(image_token);
- if (image_addr == LLDB_INVALID_ADDRESS)
- return Error("Invalid image token");
-
- StreamString expr;
- expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
- const char *prefix = GetLibdlFunctionDeclarations();
- lldb::ValueObjectSP result_valobj_sp;
- Error error = EvaluateLibdlExpression(process, expr.GetData(), prefix, result_valobj_sp);
- if (error.Fail())
- return error;
-
- if (result_valobj_sp->GetError().Fail())
- return result_valobj_sp->GetError();
+ addr_t image_ptr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
+ if (image_ptr != 0 && image_ptr != LLDB_INVALID_ADDRESS)
+ return process->AddImageToken(image_ptr);
+
+ if (image_ptr == 0) {
+ ValueObjectSP error_str_sp = result_valobj_sp->GetChildAtIndex(1, true);
+ if (error_str_sp) {
+ DataBufferSP buffer_sp(new DataBufferHeap(10240, 0));
+ size_t num_chars =
+ error_str_sp->ReadPointedString(buffer_sp, error, 10240).first;
+ if (error.Success() && num_chars > 0)
+ error.SetErrorStringWithFormat("dlopen error: %s",
+ buffer_sp->GetBytes());
+ else
+ error.SetErrorStringWithFormat("dlopen failed for unknown reasons.");
+ return LLDB_INVALID_IMAGE_TOKEN;
+ }
+ }
+ error.SetErrorStringWithFormat("unable to load '%s'", path);
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
+Error PlatformPOSIX::UnloadImage(lldb_private::Process *process,
+ uint32_t image_token) {
+ const addr_t image_addr = process->GetImagePtrFromToken(image_token);
+ if (image_addr == LLDB_INVALID_ADDRESS)
+ return Error("Invalid image token");
+
+ StreamString expr;
+ expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
+ const char *prefix = GetLibdlFunctionDeclarations();
+ lldb::ValueObjectSP result_valobj_sp;
+ Error error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
+ result_valobj_sp);
+ if (error.Fail())
+ return error;
- Scalar scalar;
- if (result_valobj_sp->ResolveValue(scalar))
- {
- if (scalar.UInt(1))
- return Error("expression failed: \"%s\"", expr.GetData());
- process->ResetImageToken(image_token);
- }
- return Error();
-}
+ if (result_valobj_sp->GetError().Fail())
+ return result_valobj_sp->GetError();
-lldb::ProcessSP
-PlatformPOSIX::ConnectProcess (const char* connect_url,
- const char* plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Error &error)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->ConnectProcess(connect_url,
- plugin_name,
- debugger,
- target,
- error);
+ Scalar scalar;
+ if (result_valobj_sp->ResolveValue(scalar)) {
+ if (scalar.UInt(1))
+ return Error("expression failed: \"%s\"", expr.GetData());
+ process->ResetImageToken(image_token);
+ }
+ return Error();
+}
+
+lldb::ProcessSP PlatformPOSIX::ConnectProcess(const char *connect_url,
+ const char *plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
+ debugger, target, error);
- return Platform::ConnectProcess(connect_url, plugin_name, debugger, target, error);
+ return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
+ error);
}
-const char*
-PlatformPOSIX::GetLibdlFunctionDeclarations() const
-{
- return R"(
+const char *PlatformPOSIX::GetLibdlFunctionDeclarations() const {
+ return R"(
extern "C" void* dlopen(const char*, int);
extern "C" void* dlsym(void*, const char*);
extern "C" int dlclose(void*);
@@ -1016,10 +854,9 @@ PlatformPOSIX::GetLibdlFunctionDeclarati
)";
}
-size_t
-PlatformPOSIX::ConnectToWaitingProcesses(Debugger& debugger, Error& error)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
- return Platform::ConnectToWaitingProcesses(debugger, error);
+size_t PlatformPOSIX::ConnectToWaitingProcesses(Debugger &debugger,
+ Error &error) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
+ return Platform::ConnectToWaitingProcesses(debugger, error);
}
Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h Tue Sep 6 15:57:50 2016
@@ -20,197 +20,174 @@
#include "lldb/Interpreter/Options.h"
#include "lldb/Target/Platform.h"
-class PlatformPOSIX : public lldb_private::Platform
-{
+class PlatformPOSIX : public lldb_private::Platform {
public:
- PlatformPOSIX(bool is_host);
+ PlatformPOSIX(bool is_host);
- ~PlatformPOSIX() override;
+ ~PlatformPOSIX() override;
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
-
- bool
- GetModuleSpec (const lldb_private::FileSpec& module_file_spec,
- const lldb_private::ArchSpec& arch,
- lldb_private::ModuleSpec &module_spec) override;
-
- lldb_private::OptionGroupOptions*
- GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
-
- const char *
- GetHostname () override;
-
- const char *
- GetUserName (uint32_t uid) override;
-
- const char *
- GetGroupName (uint32_t gid) override;
-
- lldb_private::Error
- PutFile (const lldb_private::FileSpec& source,
- const lldb_private::FileSpec& destination,
- uint32_t uid = UINT32_MAX,
- uint32_t gid = UINT32_MAX) override;
-
- lldb::user_id_t
- OpenFile (const lldb_private::FileSpec& file_spec,
- uint32_t flags,
- uint32_t mode,
- lldb_private::Error &error) override;
-
- bool
- CloseFile (lldb::user_id_t fd,
- lldb_private::Error &error) override;
-
- uint64_t
- ReadFile (lldb::user_id_t fd,
- uint64_t offset,
- void *dst,
- uint64_t dst_len,
- lldb_private::Error &error) override;
-
- uint64_t
- WriteFile (lldb::user_id_t fd,
- uint64_t offset,
- const void* src,
- uint64_t src_len,
- lldb_private::Error &error) override;
-
- lldb::user_id_t
- GetFileSize (const lldb_private::FileSpec& file_spec) override;
-
- lldb_private::Error
- CreateSymlink(const lldb_private::FileSpec &src,
- const lldb_private::FileSpec &dst) override;
-
- lldb_private::Error
- GetFile(const lldb_private::FileSpec &source,
- const lldb_private::FileSpec &destination) override;
-
- lldb_private::FileSpec
- GetRemoteWorkingDirectory() override;
-
- bool
- SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
-
- bool
- GetRemoteOSVersion () override;
-
- bool
- GetRemoteOSBuildString (std::string &s) override;
-
- bool
- GetRemoteOSKernelDescription (std::string &s) override;
-
- lldb_private::ArchSpec
- GetRemoteSystemArchitecture () override;
-
- const lldb::UnixSignalsSP &
- GetRemoteUnixSignals() override;
-
- size_t
- GetEnvironment (lldb_private::StringList &environment) override;
-
- bool
- IsConnected () const override;
-
- lldb_private::Error
- RunShellCommand(const char *command, // Shouldn't be nullptr
- const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass nullptr if you don't want the process exit status
- int *signo_ptr, // Pass nullptr if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass nullptr if you don't want the command output
- uint32_t timeout_sec) override; // Timeout in seconds to wait for shell program to finish
-
- lldb_private::Error
- MakeDirectory(const lldb_private::FileSpec &file_spec, uint32_t mode) override;
-
- lldb_private::Error
- GetFilePermissions(const lldb_private::FileSpec &file_spec, uint32_t &file_permissions) override;
-
- lldb_private::Error
- SetFilePermissions(const lldb_private::FileSpec &file_spec, uint32_t file_permissions) override;
-
- bool
- GetFileExists (const lldb_private::FileSpec& file_spec) override;
-
- lldb_private::Error
- Unlink(const lldb_private::FileSpec &file_spec) override;
-
- lldb_private::Error
- LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info) override;
-
- lldb_private::Error
- KillProcess (const lldb::pid_t pid) override;
-
- lldb::ProcessSP
- Attach (lldb_private::ProcessAttachInfo &attach_info,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
- lldb_private::Error &error) override;
-
- lldb::ProcessSP
- DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target, // Can be nullptr, if nullptr create a new target, else use existing one
- lldb_private::Error &error) override;
-
- std::string
- GetPlatformSpecificConnectionInformation() override;
-
- bool
- CalculateMD5 (const lldb_private::FileSpec& file_spec,
- uint64_t &low,
- uint64_t &high) override;
-
- void
- CalculateTrapHandlerSymbolNames () override;
-
- lldb_private::Error
- ConnectRemote (lldb_private::Args& args) override;
-
- lldb_private::Error
- DisconnectRemote () override;
-
- uint32_t
- DoLoadImage (lldb_private::Process* process,
- const lldb_private::FileSpec& remote_file,
- lldb_private::Error& error) override;
-
- lldb_private::Error
- UnloadImage (lldb_private::Process* process, uint32_t image_token) override;
-
- lldb::ProcessSP
- ConnectProcess (const char* connect_url,
- const char* plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Error &error) override;
-
- size_t
- ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error) override;
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+
+ bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
+ const lldb_private::ArchSpec &arch,
+ lldb_private::ModuleSpec &module_spec) override;
+
+ lldb_private::OptionGroupOptions *
+ GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
+
+ const char *GetHostname() override;
+
+ const char *GetUserName(uint32_t uid) override;
+
+ const char *GetGroupName(uint32_t gid) override;
+
+ lldb_private::Error PutFile(const lldb_private::FileSpec &source,
+ const lldb_private::FileSpec &destination,
+ uint32_t uid = UINT32_MAX,
+ uint32_t gid = UINT32_MAX) override;
+
+ lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec,
+ uint32_t flags, uint32_t mode,
+ lldb_private::Error &error) override;
+
+ bool CloseFile(lldb::user_id_t fd, lldb_private::Error &error) override;
+
+ uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+ uint64_t dst_len, lldb_private::Error &error) override;
+
+ uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
+ uint64_t src_len, lldb_private::Error &error) override;
+
+ lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
+
+ lldb_private::Error CreateSymlink(const lldb_private::FileSpec &src,
+ const lldb_private::FileSpec &dst) override;
+
+ lldb_private::Error
+ GetFile(const lldb_private::FileSpec &source,
+ const lldb_private::FileSpec &destination) override;
+
+ lldb_private::FileSpec GetRemoteWorkingDirectory() override;
+
+ bool
+ SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
+
+ bool GetRemoteOSVersion() override;
+
+ bool GetRemoteOSBuildString(std::string &s) override;
+
+ bool GetRemoteOSKernelDescription(std::string &s) override;
+
+ lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
+
+ const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
+
+ size_t GetEnvironment(lldb_private::StringList &environment) override;
+
+ bool IsConnected() const override;
+
+ lldb_private::Error RunShellCommand(
+ const char *command, // Shouldn't be nullptr
+ const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use
+ // the current working
+ // directory
+ int *status_ptr, // Pass nullptr if you don't want the process exit status
+ int *signo_ptr, // Pass nullptr if you don't want the signal that caused
+ // the process to exit
+ std::string
+ *command_output, // Pass nullptr if you don't want the command output
+ uint32_t timeout_sec)
+ override; // Timeout in seconds to wait for shell program to finish
+
+ lldb_private::Error MakeDirectory(const lldb_private::FileSpec &file_spec,
+ uint32_t mode) override;
+
+ lldb_private::Error
+ GetFilePermissions(const lldb_private::FileSpec &file_spec,
+ uint32_t &file_permissions) override;
+
+ lldb_private::Error
+ SetFilePermissions(const lldb_private::FileSpec &file_spec,
+ uint32_t file_permissions) override;
+
+ bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
+
+ lldb_private::Error Unlink(const lldb_private::FileSpec &file_spec) override;
+
+ lldb_private::Error
+ LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
+
+ lldb_private::Error KillProcess(const lldb::pid_t pid) override;
+
+ lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target, // Can be nullptr, if
+ // nullptr create a new
+ // target, else use
+ // existing one
+ lldb_private::Error &error) override;
+
+ lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target, // Can be nullptr,
+ // if nullptr
+ // create a new
+ // target, else use
+ // existing one
+ lldb_private::Error &error) override;
+
+ std::string GetPlatformSpecificConnectionInformation() override;
+
+ bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
+ uint64_t &high) override;
+
+ void CalculateTrapHandlerSymbolNames() override;
+
+ lldb_private::Error ConnectRemote(lldb_private::Args &args) override;
+
+ lldb_private::Error DisconnectRemote() override;
+
+ uint32_t DoLoadImage(lldb_private::Process *process,
+ const lldb_private::FileSpec &remote_file,
+ lldb_private::Error &error) override;
+
+ lldb_private::Error UnloadImage(lldb_private::Process *process,
+ uint32_t image_token) override;
+
+ lldb::ProcessSP ConnectProcess(const char *connect_url,
+ const char *plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
+
+ size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
+ lldb_private::Error &error) override;
protected:
- std::unique_ptr<lldb_private::OptionGroupPlatformRSync> m_option_group_platform_rsync;
- std::unique_ptr<lldb_private::OptionGroupPlatformSSH> m_option_group_platform_ssh;
- std::unique_ptr<lldb_private::OptionGroupPlatformCaching> m_option_group_platform_caching;
-
- std::map<lldb_private::CommandInterpreter*,std::unique_ptr<lldb_private::OptionGroupOptions>> m_options;
- lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote POSIX-compliant OS
-
- lldb_private::Error
- EvaluateLibdlExpression(lldb_private::Process* process,
- const char *expr_cstr,
- const char *expr_prefix,
- lldb::ValueObjectSP& result_valobj_sp);
+ std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
+ m_option_group_platform_rsync;
+ std::unique_ptr<lldb_private::OptionGroupPlatformSSH>
+ m_option_group_platform_ssh;
+ std::unique_ptr<lldb_private::OptionGroupPlatformCaching>
+ m_option_group_platform_caching;
+
+ std::map<lldb_private::CommandInterpreter *,
+ std::unique_ptr<lldb_private::OptionGroupOptions>>
+ m_options;
+ lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
+ // remote POSIX-compliant OS
+
+ lldb_private::Error
+ EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
+ const char *expr_prefix,
+ lldb::ValueObjectSP &result_valobj_sp);
- virtual const char*
- GetLibdlFunctionDeclarations() const;
+ virtual const char *GetLibdlFunctionDeclarations() const;
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformPOSIX);
+ DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
};
#endif // liblldb_PlatformPOSIX_h_
Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp Tue Sep 6 15:57:50 2016
@@ -11,7 +11,7 @@
// C Includes
#include <stdio.h>
-#if defined (_WIN32)
+#if defined(_WIN32)
#include "lldb/Host/windows/windows.h"
#include <winsock2.h>
#endif
@@ -19,14 +19,14 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Target/Process.h"
using namespace lldb;
@@ -34,161 +34,133 @@ using namespace lldb_private;
static uint32_t g_initialize_count = 0;
-namespace
-{
- class SupportedArchList
- {
- public:
- SupportedArchList()
- {
- AddArch(ArchSpec("i686-pc-windows"));
- AddArch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
- AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind32));
- AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind64));
- AddArch(ArchSpec("i386-pc-windows"));
- }
-
- size_t Count() const { return m_archs.size(); }
-
- const ArchSpec& operator[](int idx) { return m_archs[idx]; }
-
- private:
- void AddArch(const ArchSpec& spec)
- {
- auto iter = std::find_if(
- m_archs.begin(), m_archs.end(),
- [spec](const ArchSpec& rhs) { return spec.IsExactMatch(rhs); });
- if (iter != m_archs.end())
- return;
- if (spec.IsValid())
- m_archs.push_back(spec);
- }
+namespace {
+class SupportedArchList {
+public:
+ SupportedArchList() {
+ AddArch(ArchSpec("i686-pc-windows"));
+ AddArch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
+ AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind32));
+ AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind64));
+ AddArch(ArchSpec("i386-pc-windows"));
+ }
+
+ size_t Count() const { return m_archs.size(); }
+
+ const ArchSpec &operator[](int idx) { return m_archs[idx]; }
+
+private:
+ void AddArch(const ArchSpec &spec) {
+ auto iter = std::find_if(
+ m_archs.begin(), m_archs.end(),
+ [spec](const ArchSpec &rhs) { return spec.IsExactMatch(rhs); });
+ if (iter != m_archs.end())
+ return;
+ if (spec.IsValid())
+ m_archs.push_back(spec);
+ }
- std::vector<ArchSpec> m_archs;
- };
+ std::vector<ArchSpec> m_archs;
+};
} // anonymous namespace
-PlatformSP
-PlatformWindows::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
-{
- // The only time we create an instance is when we are creating a remote
- // windows platform
- const bool is_host = false;
-
- bool create = force;
- if (create == false && arch && arch->IsValid())
- {
- const llvm::Triple &triple = arch->GetTriple();
- switch (triple.getVendor())
- {
- case llvm::Triple::PC:
- create = true;
- break;
-
- case llvm::Triple::UnknownArch:
- create = !arch->TripleVendorWasSpecified();
- break;
-
- default:
- break;
- }
-
- if (create)
- {
- switch (triple.getOS())
- {
- case llvm::Triple::Win32:
- break;
-
- case llvm::Triple::UnknownOS:
- create = arch->TripleOSWasSpecified();
- break;
-
- default:
- create = false;
- break;
- }
- }
- }
- if (create)
- return PlatformSP(new PlatformWindows (is_host));
- return PlatformSP();
-}
-
-lldb_private::ConstString
-PlatformWindows::GetPluginNameStatic(bool is_host)
-{
- if (is_host)
- {
- static ConstString g_host_name(Platform::GetHostPlatformName ());
- return g_host_name;
- }
- else
- {
- static ConstString g_remote_name("remote-windows");
- return g_remote_name;
- }
-}
-
-const char *
-PlatformWindows::GetPluginDescriptionStatic(bool is_host)
-{
- return is_host ?
- "Local Windows user platform plug-in." :
- "Remote Windows user platform plug-in.";
-}
-
-lldb_private::ConstString
-PlatformWindows::GetPluginName()
-{
- return GetPluginNameStatic(IsHost());
-}
-
-void
-PlatformWindows::Initialize()
-{
- Platform::Initialize ();
-
- if (g_initialize_count++ == 0)
- {
-#if defined (_WIN32)
- WSADATA dummy;
- WSAStartup(MAKEWORD(2,2), &dummy);
- // Force a host flag to true for the default platform object.
- PlatformSP default_platform_sp (new PlatformWindows(true));
- default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
- Platform::SetHostPlatform (default_platform_sp);
+PlatformSP PlatformWindows::CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch) {
+ // The only time we create an instance is when we are creating a remote
+ // windows platform
+ const bool is_host = false;
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getVendor()) {
+ case llvm::Triple::PC:
+ create = true;
+ break;
+
+ case llvm::Triple::UnknownArch:
+ create = !arch->TripleVendorWasSpecified();
+ break;
+
+ default:
+ break;
+ }
+
+ if (create) {
+ switch (triple.getOS()) {
+ case llvm::Triple::Win32:
+ break;
+
+ case llvm::Triple::UnknownOS:
+ create = arch->TripleOSWasSpecified();
+ break;
+
+ default:
+ create = false;
+ break;
+ }
+ }
+ }
+ if (create)
+ return PlatformSP(new PlatformWindows(is_host));
+ return PlatformSP();
+}
+
+lldb_private::ConstString PlatformWindows::GetPluginNameStatic(bool is_host) {
+ if (is_host) {
+ static ConstString g_host_name(Platform::GetHostPlatformName());
+ return g_host_name;
+ } else {
+ static ConstString g_remote_name("remote-windows");
+ return g_remote_name;
+ }
+}
+
+const char *PlatformWindows::GetPluginDescriptionStatic(bool is_host) {
+ return is_host ? "Local Windows user platform plug-in."
+ : "Remote Windows user platform plug-in.";
+}
+
+lldb_private::ConstString PlatformWindows::GetPluginName() {
+ return GetPluginNameStatic(IsHost());
+}
+
+void PlatformWindows::Initialize() {
+ Platform::Initialize();
+
+ if (g_initialize_count++ == 0) {
+#if defined(_WIN32)
+ WSADATA dummy;
+ WSAStartup(MAKEWORD(2, 2), &dummy);
+ // Force a host flag to true for the default platform object.
+ PlatformSP default_platform_sp(new PlatformWindows(true));
+ default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+ Platform::SetHostPlatform(default_platform_sp);
#endif
- PluginManager::RegisterPlugin(PlatformWindows::GetPluginNameStatic(false),
- PlatformWindows::GetPluginDescriptionStatic(false),
- PlatformWindows::CreateInstance);
- }
+ PluginManager::RegisterPlugin(
+ PlatformWindows::GetPluginNameStatic(false),
+ PlatformWindows::GetPluginDescriptionStatic(false),
+ PlatformWindows::CreateInstance);
+ }
}
-void
-PlatformWindows::Terminate( void )
-{
- if (g_initialize_count > 0)
- {
- if (--g_initialize_count == 0)
- {
+void PlatformWindows::Terminate(void) {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
#ifdef _WIN32
- WSACleanup();
+ WSACleanup();
#endif
- PluginManager::UnregisterPlugin (PlatformWindows::CreateInstance);
- }
+ PluginManager::UnregisterPlugin(PlatformWindows::CreateInstance);
}
+ }
- Platform::Terminate ();
+ Platform::Terminate();
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformWindows::PlatformWindows (bool is_host) :
- Platform(is_host)
-{
-}
+PlatformWindows::PlatformWindows(bool is_host) : Platform(is_host) {}
//------------------------------------------------------------------
/// Destructor.
@@ -198,520 +170,438 @@ PlatformWindows::PlatformWindows (bool i
//------------------------------------------------------------------
PlatformWindows::~PlatformWindows() = default;
-bool
-PlatformWindows::GetModuleSpec (const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec (module_file_spec, arch, module_spec);
-
- return Platform::GetModuleSpec (module_file_spec, arch, module_spec);
-}
-
-Error
-PlatformWindows::ResolveExecutable (const ModuleSpec &ms,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(ms);
-
- if (IsHost())
- {
- // if we cant resolve the executable loation based on the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists())
- {
- resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+bool PlatformWindows::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
+ module_spec);
+
+ return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+}
+
+Error PlatformWindows::ResolveExecutable(
+ const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ ModuleSpec resolved_module_spec(ms);
+
+ if (IsHost()) {
+ // if we cant resolve the executable loation based on the current path
+ // variables
+ if (!resolved_module_spec.GetFileSpec().Exists()) {
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+ }
+
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else {
+ ms.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ error.SetErrorStringWithFormat("unable to find executable for '%s'",
+ exe_path);
+ }
+ } else {
+ if (m_remote_platform_sp) {
+ error = GetCachedExecutable(resolved_module_spec, exe_module_sp, nullptr,
+ *m_remote_platform_sp);
+ } else {
+ // We may connect to a process and use the provided executable (Don't use
+ // local $PATH).
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else
+ error.SetErrorStringWithFormat("the platform is not currently "
+ "connected, and '%s' doesn't exist in "
+ "the system root.",
+ exe_path);
+ }
+ }
+
+ if (error.Success()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ nullptr, nullptr, nullptr);
+
+ if (!exe_module_sp || exe_module_sp->GetObjectFile() == nullptr) {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain the architecture %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+ } else {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ nullptr, nullptr, nullptr);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
}
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- {
- ms.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
- }
- }
- else
- {
- if (m_remote_platform_sp)
- {
- error = GetCachedExecutable (resolved_module_spec, exe_module_sp, nullptr, *m_remote_platform_sp);
- }
- else
- {
- // We may connect to a process and use the provided executable (Don't use local $PATH).
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
}
+ }
}
+ }
- if (error.Success())
- {
- if (resolved_module_spec.GetArchitecture().IsValid())
- {
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp,
- nullptr,
- nullptr,
- nullptr);
-
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == nullptr)
- {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- }
- else
- {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp,
- nullptr,
- nullptr,
- nullptr);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
-
- return error;
+ return error;
}
-bool
-PlatformWindows::GetRemoteOSVersion ()
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetOSVersion (m_major_os_version,
- m_minor_os_version,
- m_update_os_version);
- return false;
+bool PlatformWindows::GetRemoteOSVersion() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetOSVersion(
+ m_major_os_version, m_minor_os_version, m_update_os_version);
+ return false;
}
-bool
-PlatformWindows::GetRemoteOSBuildString (std::string &s)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString (s);
- s.clear();
- return false;
+bool PlatformWindows::GetRemoteOSBuildString(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString(s);
+ s.clear();
+ return false;
}
-bool
-PlatformWindows::GetRemoteOSKernelDescription (std::string &s)
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription (s);
- s.clear();
- return false;
+bool PlatformWindows::GetRemoteOSKernelDescription(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
+ s.clear();
+ return false;
}
// Remote Platform subclasses need to override this function
-ArchSpec
-PlatformWindows::GetRemoteSystemArchitecture ()
-{
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture ();
- return ArchSpec();
-}
-
-const char *
-PlatformWindows::GetHostname ()
-{
- if (IsHost())
- return Platform::GetHostname();
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname ();
- return nullptr;
+ArchSpec PlatformWindows::GetRemoteSystemArchitecture() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture();
+ return ArchSpec();
}
-bool
-PlatformWindows::IsConnected () const
-{
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
-Error
-PlatformWindows::ConnectRemote (Args& args)
-{
- Error error;
- if (IsHost())
- {
- error.SetErrorStringWithFormat ("can't connect to the host platform '%s', always connected", GetPluginName().AsCString() );
- }
- else
- {
- if (!m_remote_platform_sp)
- m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
-
- if (m_remote_platform_sp)
- {
- if (error.Success())
- {
- if (m_remote_platform_sp)
- {
- error = m_remote_platform_sp->ConnectRemote (args);
- }
- else
- {
- error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
- }
- }
- }
- else
- error.SetErrorString ("failed to create a 'remote-gdb-server' platform");
-
- if (error.Fail())
- m_remote_platform_sp.reset();
- }
+const char *PlatformWindows::GetHostname() {
+ if (IsHost())
+ return Platform::GetHostname();
- return error;
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname();
+ return nullptr;
}
-Error
-PlatformWindows::DisconnectRemote ()
-{
- Error error;
-
- if (IsHost())
- {
- error.SetErrorStringWithFormat ("can't disconnect from the host platform '%s', always connected", GetPluginName().AsCString() );
- }
+bool PlatformWindows::IsConnected() const {
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+Error PlatformWindows::ConnectRemote(Args &args) {
+ Error error;
+ if (IsHost()) {
+ error.SetErrorStringWithFormat(
+ "can't connect to the host platform '%s', always connected",
+ GetPluginName().AsCString());
+ } else {
+ if (!m_remote_platform_sp)
+ m_remote_platform_sp =
+ Platform::Create(ConstString("remote-gdb-server"), error);
+
+ if (m_remote_platform_sp) {
+ if (error.Success()) {
+ if (m_remote_platform_sp) {
+ error = m_remote_platform_sp->ConnectRemote(args);
+ } else {
+ error.SetErrorString(
+ "\"platform connect\" takes a single argument: <connect-url>");
+ }
+ }
+ } else
+ error.SetErrorString("failed to create a 'remote-gdb-server' platform");
+
+ if (error.Fail())
+ m_remote_platform_sp.reset();
+ }
+
+ return error;
+}
+
+Error PlatformWindows::DisconnectRemote() {
+ Error error;
+
+ if (IsHost()) {
+ error.SetErrorStringWithFormat(
+ "can't disconnect from the host platform '%s', always connected",
+ GetPluginName().AsCString());
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->DisconnectRemote();
else
- {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->DisconnectRemote ();
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return error;
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
}
-bool
-PlatformWindows::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
- bool success = false;
- if (IsHost())
- {
- success = Platform::GetProcessInfo (pid, process_info);
- }
- else if (m_remote_platform_sp)
- {
- success = m_remote_platform_sp->GetProcessInfo (pid, process_info);
- }
- return success;
+bool PlatformWindows::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ bool success = false;
+ if (IsHost()) {
+ success = Platform::GetProcessInfo(pid, process_info);
+ } else if (m_remote_platform_sp) {
+ success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ }
+ return success;
}
uint32_t
-PlatformWindows::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- uint32_t match_count = 0;
- if (IsHost())
- {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses (match_info, process_infos);
- }
- else
- {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
- }
- return match_count;
+PlatformWindows::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ uint32_t match_count = 0;
+ if (IsHost()) {
+ // Let the base class figure out the host details
+ match_count = Platform::FindProcesses(match_info, process_infos);
+ } else {
+ // If we are remote, we can only return results if we are connected
+ if (m_remote_platform_sp)
+ match_count =
+ m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ }
+ return match_count;
}
-Error
-PlatformWindows::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
- Error error;
- if (IsHost())
- {
- error = Platform::LaunchProcess (launch_info);
- }
+Error PlatformWindows::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Error error;
+ if (IsHost()) {
+ error = Platform::LaunchProcess(launch_info);
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess(launch_info);
else
- {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess (launch_info);
- else
- error.SetErrorString ("the platform is not currently connected");
- }
- return error;
-}
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
+
+ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info,
+ Debugger &debugger, Target *target,
+ Error &error) {
+ // Windows has special considerations that must be followed when launching or
+ // attaching to a process. The
+ // key requirement is that when launching or attaching to a process, you must
+ // do it from the same the thread
+ // that will go into a permanent loop which will then receive debug events
+ // from the process. In particular,
+ // this means we can't use any of LLDB's generic mechanisms to do it for us,
+ // because it doesn't have the
+ // special knowledge required for setting up the background thread or passing
+ // the right flags.
+ //
+ // Another problem is that that LLDB's standard model for debugging a process
+ // is to first launch it, have
+ // it stop at the entry point, and then attach to it. In Windows this doesn't
+ // quite work, you have to
+ // specify as an argument to CreateProcess() that you're going to debug the
+ // process. So we override DebugProcess
+ // here to handle this. Launch operations go directly to the process plugin,
+ // and attach operations almost go
+ // directly to the process plugin (but we hijack the events first). In
+ // essence, we encapsulate all the logic
+ // of Launching and Attaching in the process plugin, and
+ // PlatformWindows::DebugProcess is just a pass-through
+ // to get to the process plugin.
+
+ if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
+ // This is a process attach. Don't need to launch anything.
+ ProcessAttachInfo attach_info(launch_info);
+ return Attach(attach_info, debugger, target, error);
+ } else {
+ ProcessSP process_sp =
+ target->CreateProcess(launch_info.GetListenerForProcess(debugger),
+ launch_info.GetProcessPluginName(), nullptr);
-ProcessSP
-PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, Error &error)
-{
- // Windows has special considerations that must be followed when launching or attaching to a process. The
- // key requirement is that when launching or attaching to a process, you must do it from the same the thread
- // that will go into a permanent loop which will then receive debug events from the process. In particular,
- // this means we can't use any of LLDB's generic mechanisms to do it for us, because it doesn't have the
- // special knowledge required for setting up the background thread or passing the right flags.
- //
- // Another problem is that that LLDB's standard model for debugging a process is to first launch it, have
- // it stop at the entry point, and then attach to it. In Windows this doesn't quite work, you have to
- // specify as an argument to CreateProcess() that you're going to debug the process. So we override DebugProcess
- // here to handle this. Launch operations go directly to the process plugin, and attach operations almost go
- // directly to the process plugin (but we hijack the events first). In essence, we encapsulate all the logic
- // of Launching and Attaching in the process plugin, and PlatformWindows::DebugProcess is just a pass-through
- // to get to the process plugin.
-
- if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
- {
- // This is a process attach. Don't need to launch anything.
- ProcessAttachInfo attach_info(launch_info);
- return Attach(attach_info, debugger, target, error);
- }
- else
- {
- ProcessSP process_sp = target->CreateProcess(launch_info.GetListenerForProcess(debugger),
- launch_info.GetProcessPluginName(),
- nullptr);
-
- // We need to launch and attach to the process.
- launch_info.GetFlags().Set(eLaunchFlagDebug);
- if (process_sp)
- error = process_sp->Launch(launch_info);
+ // We need to launch and attach to the process.
+ launch_info.GetFlags().Set(eLaunchFlagDebug);
+ if (process_sp)
+ error = process_sp->Launch(launch_info);
- return process_sp;
- }
+ return process_sp;
+ }
}
-lldb::ProcessSP
-PlatformWindows::Attach(ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target,
- Error &error)
-{
- error.Clear();
- lldb::ProcessSP process_sp;
- if (!IsHost())
- {
- if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
- else
- error.SetErrorString ("the platform is not currently connected");
- return process_sp;
- }
+lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info,
+ Debugger &debugger, Target *target,
+ Error &error) {
+ error.Clear();
+ lldb::ProcessSP process_sp;
+ if (!IsHost()) {
+ if (m_remote_platform_sp)
+ process_sp =
+ m_remote_platform_sp->Attach(attach_info, debugger, target, error);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ return process_sp;
+ }
- if (target == nullptr)
- {
- TargetSP new_target_sp;
- FileSpec emptyFileSpec;
- ArchSpec emptyArchSpec;
-
- error = debugger.GetTargetList().CreateTarget(debugger,
- nullptr,
- nullptr,
- false,
- nullptr,
- new_target_sp);
- target = new_target_sp.get();
- }
+ if (target == nullptr) {
+ TargetSP new_target_sp;
+ FileSpec emptyFileSpec;
+ ArchSpec emptyArchSpec;
+
+ error = debugger.GetTargetList().CreateTarget(
+ debugger, nullptr, nullptr, false, nullptr, new_target_sp);
+ target = new_target_sp.get();
+ }
- if (!target || error.Fail())
- return process_sp;
+ if (!target || error.Fail())
+ return process_sp;
- debugger.GetTargetList().SetSelectedTarget(target);
+ debugger.GetTargetList().SetSelectedTarget(target);
- const char *plugin_name = attach_info.GetProcessPluginName();
- process_sp = target->CreateProcess(attach_info.GetListenerForProcess(debugger), plugin_name, nullptr);
+ const char *plugin_name = attach_info.GetProcessPluginName();
+ process_sp = target->CreateProcess(
+ attach_info.GetListenerForProcess(debugger), plugin_name, nullptr);
- process_sp->HijackProcessEvents(attach_info.GetHijackListener());
- if (process_sp)
- error = process_sp->Attach (attach_info);
+ process_sp->HijackProcessEvents(attach_info.GetHijackListener());
+ if (process_sp)
+ error = process_sp->Attach(attach_info);
- return process_sp;
+ return process_sp;
}
-const char *
-PlatformWindows::GetUserName (uint32_t uid)
-{
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return nullptr;
-}
-
-const char *
-PlatformWindows::GetGroupName (uint32_t gid)
-{
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return nullptr;
-}
-
-Error
-PlatformWindows::GetFileWithUUID (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- if (IsRemote())
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID (platform_file, uuid_ptr, local_file);
- }
+const char *PlatformWindows::GetUserName(uint32_t uid) {
+ // Check the cache in Platform in case we have already looked this uid up
+ const char *user_name = Platform::GetUserName(uid);
+ if (user_name)
+ return user_name;
- // Default to the local case
- local_file = platform_file;
- return Error();
-}
-
-Error
-PlatformWindows::GetSharedModule (const ModuleSpec &module_spec,
- Process* process,
- ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr)
-{
- Error error;
- module_sp.reset();
-
- if (IsRemote())
- {
- // If we have a remote platform always, let it try and locate
- // the shared module first.
- if (m_remote_platform_sp)
- {
- error = m_remote_platform_sp->GetSharedModule (module_spec,
- process,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr);
- }
- }
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserName(uid);
+ return nullptr;
+}
- if (!module_sp)
- {
- // Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule (module_spec,
- process,
- module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr,
- did_create_ptr);
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return error;
+const char *PlatformWindows::GetGroupName(uint32_t gid) {
+ const char *group_name = Platform::GetGroupName(gid);
+ if (group_name)
+ return group_name;
+
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetGroupName(gid);
+ return nullptr;
}
-bool
-PlatformWindows::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- static SupportedArchList architectures;
-
- if (idx >= architectures.Count())
- return false;
- arch = architectures[idx];
- return true;
+Error PlatformWindows::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+ }
+
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
+}
+
+Error PlatformWindows::GetSharedModule(
+ const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) {
+ Error error;
+ module_sp.reset();
+
+ if (IsRemote()) {
+ // If we have a remote platform always, let it try and locate
+ // the shared module first.
+ if (m_remote_platform_sp) {
+ error = m_remote_platform_sp->GetSharedModule(
+ module_spec, process, module_sp, module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ }
+ }
+
+ if (!module_sp) {
+ // Fall back to the local platform and find the file locally
+ error = Platform::GetSharedModule(module_spec, process, module_sp,
+ module_search_paths_ptr,
+ old_module_sp_ptr, did_create_ptr);
+ }
+ if (module_sp)
+ module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
+ return error;
+}
+
+bool PlatformWindows::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ static SupportedArchList architectures;
+
+ if (idx >= architectures.Count())
+ return false;
+ arch = architectures[idx];
+ return true;
}
-void
-PlatformWindows::GetStatus (Stream &strm)
-{
- Platform::GetStatus(strm);
+void PlatformWindows::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
#ifdef _WIN32
- uint32_t major;
- uint32_t minor;
- uint32_t update;
- if (!HostInfo::GetOSVersion(major, minor, update))
- {
- strm << "Windows";
- return;
- }
+ uint32_t major;
+ uint32_t minor;
+ uint32_t update;
+ if (!HostInfo::GetOSVersion(major, minor, update)) {
+ strm << "Windows";
+ return;
+ }
- strm << "Host: Windows " << major
- << '.' << minor
- << " Build: " << update << '\n';
+ strm << "Host: Windows " << major << '.' << minor << " Build: " << update
+ << '\n';
#endif
}
-bool
-PlatformWindows::CanDebugProcess()
-{
- return true;
-}
+bool PlatformWindows::CanDebugProcess() { return true; }
-size_t
-PlatformWindows::GetEnvironment(StringList &env)
-{
- if (IsRemote())
- {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetEnvironment(env);
- return 0;
- }
+size_t PlatformWindows::GetEnvironment(StringList &env) {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetEnvironment(env);
+ return 0;
+ }
- return Host::GetEnvironment(env);
+ return Host::GetEnvironment(env);
}
-ConstString
-PlatformWindows::GetFullNameForDylib (ConstString basename)
-{
- if (basename.IsEmpty())
- return basename;
-
- StreamString stream;
- stream.Printf("%s.dll", basename.GetCString());
- return ConstString(stream.GetData());
+ConstString PlatformWindows::GetFullNameForDylib(ConstString basename) {
+ if (basename.IsEmpty())
+ return basename;
+
+ StreamString stream;
+ stream.Printf("%s.dll", basename.GetCString());
+ return ConstString(stream.GetData());
}
Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h Tue Sep 6 15:57:50 2016
@@ -16,148 +16,119 @@
// Project includes
#include "lldb/Target/Platform.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class PlatformWindows : public Platform
-{
+class PlatformWindows : public Platform {
public:
- PlatformWindows(bool is_host);
+ PlatformWindows(bool is_host);
- ~PlatformWindows() override;
+ ~PlatformWindows() override;
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- static lldb::PlatformSP
- CreateInstance (bool force, const lldb_private::ArchSpec *arch);
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force,
+ const lldb_private::ArchSpec *arch);
- static lldb_private::ConstString
- GetPluginNameStatic(bool is_host);
+ static lldb_private::ConstString GetPluginNameStatic(bool is_host);
- static const char *
- GetPluginDescriptionStatic(bool is_host);
+ static const char *GetPluginDescriptionStatic(bool is_host);
- lldb_private::ConstString
- GetPluginName() override;
+ lldb_private::ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
+ uint32_t GetPluginVersion() override { return 1; }
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- bool
- GetModuleSpec (const lldb_private::FileSpec& module_file_spec,
- const lldb_private::ArchSpec& arch,
- lldb_private::ModuleSpec &module_spec) override;
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
+ const lldb_private::ArchSpec &arch,
+ lldb_private::ModuleSpec &module_spec) override;
- Error
- ResolveExecutable(const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
+ Error ResolveExecutable(const lldb_private::ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr) override;
- const char *
- GetDescription() override
- {
- return GetPluginDescriptionStatic(IsHost());
- }
+ const char *GetDescription() override {
+ return GetPluginDescriptionStatic(IsHost());
+ }
- bool
- GetRemoteOSVersion() override;
+ bool GetRemoteOSVersion() override;
- bool
- GetRemoteOSBuildString(std::string &s) override;
+ bool GetRemoteOSBuildString(std::string &s) override;
- bool
- GetRemoteOSKernelDescription(std::string &s) override;
+ bool GetRemoteOSKernelDescription(std::string &s) override;
- // Remote Platform subclasses need to override this function
- lldb_private::ArchSpec
- GetRemoteSystemArchitecture() override;
+ // Remote Platform subclasses need to override this function
+ lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
- bool
- IsConnected() const override;
+ bool IsConnected() const override;
- lldb_private::Error
- ConnectRemote(lldb_private::Args& args) override;
+ lldb_private::Error ConnectRemote(lldb_private::Args &args) override;
- lldb_private::Error
- DisconnectRemote() override;
+ lldb_private::Error DisconnectRemote() override;
- const char *
- GetHostname() override;
+ const char *GetHostname() override;
- const char *
- GetUserName(uint32_t uid) override;
+ const char *GetUserName(uint32_t uid) override;
- const char *
- GetGroupName(uint32_t gid) override;
+ const char *GetGroupName(uint32_t gid) override;
- bool
- GetProcessInfo(lldb::pid_t pid,
- lldb_private::ProcessInstanceInfo &proc_info) override;
+ bool GetProcessInfo(lldb::pid_t pid,
+ lldb_private::ProcessInstanceInfo &proc_info) override;
- uint32_t
- FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
+ uint32_t
+ FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos) override;
- lldb_private::Error
- LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
+ lldb_private::Error
+ LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
- lldb::ProcessSP
- DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger,
- lldb_private::Target *target, lldb_private::Error &error) override;
+ lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
- lldb::ProcessSP
- Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger,
- lldb_private::Target *target, lldb_private::Error &error) override;
+ lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
- lldb_private::Error
- GetFileWithUUID(const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID* uuid, lldb_private::FileSpec &local_file) override;
+ lldb_private::Error
+ GetFileWithUUID(const lldb_private::FileSpec &platform_file,
+ const lldb_private::UUID *uuid,
+ lldb_private::FileSpec &local_file) override;
- lldb_private::Error
- GetSharedModule(const lldb_private::ModuleSpec &module_spec,
- lldb_private::Process* process,
- lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
+ lldb_private::Error
+ GetSharedModule(const lldb_private::ModuleSpec &module_spec,
+ lldb_private::Process *process, lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr) override;
- bool
- GetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch) override;
+ bool GetSupportedArchitectureAtIndex(uint32_t idx,
+ lldb_private::ArchSpec &arch) override;
- void
- GetStatus(lldb_private::Stream &strm) override;
+ void GetStatus(lldb_private::Stream &strm) override;
- bool CanDebugProcess() override;
+ bool CanDebugProcess() override;
- size_t GetEnvironment(StringList &env) override;
+ size_t GetEnvironment(StringList &env) override;
- // FIXME not sure what the _sigtramp equivalent would be on this platform
- void
- CalculateTrapHandlerSymbolNames () override
- {
- }
-
- ConstString
- GetFullNameForDylib (ConstString basename) override;
+ // FIXME not sure what the _sigtramp equivalent would be on this platform
+ void CalculateTrapHandlerSymbolNames() override {}
+
+ ConstString GetFullNameForDylib(ConstString basename) override;
protected:
- lldb::PlatformSP m_remote_platform_sp;
+ lldb::PlatformSP m_remote_platform_sp;
private:
- DISALLOW_COPY_AND_ASSIGN (PlatformWindows);
+ DISALLOW_COPY_AND_ASSIGN(PlatformWindows);
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Tue Sep 6 15:57:50 2016
@@ -41,200 +41,170 @@ using namespace lldb_private::platform_g
static bool g_initialized = false;
-void
-PlatformRemoteGDBServer::Initialize ()
-{
- Platform::Initialize ();
-
- if (g_initialized == false)
- {
- g_initialized = true;
- PluginManager::RegisterPlugin (PlatformRemoteGDBServer::GetPluginNameStatic(),
- PlatformRemoteGDBServer::GetDescriptionStatic(),
- PlatformRemoteGDBServer::CreateInstance);
- }
-}
-
-void
-PlatformRemoteGDBServer::Terminate ()
-{
- if (g_initialized)
- {
- g_initialized = false;
- PluginManager::UnregisterPlugin (PlatformRemoteGDBServer::CreateInstance);
- }
-
- Platform::Terminate ();
-}
-
-PlatformSP
-PlatformRemoteGDBServer::CreateInstance (bool force, const ArchSpec *arch)
-{
- bool create = force;
- if (!create)
- {
- create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified();
- }
- if (create)
- return PlatformSP(new PlatformRemoteGDBServer());
- return PlatformSP();
-}
-
-
-ConstString
-PlatformRemoteGDBServer::GetPluginNameStatic()
-{
- static ConstString g_name("remote-gdb-server");
- return g_name;
-}
-
-const char *
-PlatformRemoteGDBServer::GetDescriptionStatic()
-{
- return "A platform that uses the GDB remote protocol as the communication transport.";
-}
-
-const char *
-PlatformRemoteGDBServer::GetDescription ()
-{
- if (m_platform_description.empty())
- {
- if (IsConnected())
- {
- // Send the get description packet
- }
- }
-
- if (!m_platform_description.empty())
- return m_platform_description.c_str();
- return GetDescriptionStatic();
-}
-
-Error
-PlatformRemoteGDBServer::ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
-{
- // copied from PlatformRemoteiOS
-
- Error error;
- // Nothing special to do here, just use the actual file and architecture
+void PlatformRemoteGDBServer::Initialize() {
+ Platform::Initialize();
- ModuleSpec resolved_module_spec(module_spec);
-
- // Resolve any executable within an apk on Android?
- //Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists() ||
- module_spec.GetUUID().IsValid())
- {
- if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid())
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- module_search_paths_ptr,
- NULL,
- NULL);
-
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
- exe_module_sp.reset();
- }
- // No valid architecture was specified or the exact arch wasn't
- // found so ask the platform for the architectures that we should be
- // using (in the correct order) and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
- {
- error = ModuleList::GetSharedModule (resolved_module_spec,
- exe_module_sp,
- module_search_paths_ptr,
- NULL,
- NULL);
- // Did we find an executable using one of the
- if (error.Success())
- {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString (", ");
- arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp)
- {
- if (resolved_module_spec.GetFileSpec().Readable())
- {
- error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(),
- arch_names.GetString().c_str());
- }
- else
- {
- error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("'%s' does not exist",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
-
- return error;
-}
+ if (g_initialized == false) {
+ g_initialized = true;
+ PluginManager::RegisterPlugin(
+ PlatformRemoteGDBServer::GetPluginNameStatic(),
+ PlatformRemoteGDBServer::GetDescriptionStatic(),
+ PlatformRemoteGDBServer::CreateInstance);
+ }
+}
+
+void PlatformRemoteGDBServer::Terminate() {
+ if (g_initialized) {
+ g_initialized = false;
+ PluginManager::UnregisterPlugin(PlatformRemoteGDBServer::CreateInstance);
+ }
+
+ Platform::Terminate();
+}
+
+PlatformSP PlatformRemoteGDBServer::CreateInstance(bool force,
+ const ArchSpec *arch) {
+ bool create = force;
+ if (!create) {
+ create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified();
+ }
+ if (create)
+ return PlatformSP(new PlatformRemoteGDBServer());
+ return PlatformSP();
+}
+
+ConstString PlatformRemoteGDBServer::GetPluginNameStatic() {
+ static ConstString g_name("remote-gdb-server");
+ return g_name;
+}
+
+const char *PlatformRemoteGDBServer::GetDescriptionStatic() {
+ return "A platform that uses the GDB remote protocol as the communication "
+ "transport.";
+}
+
+const char *PlatformRemoteGDBServer::GetDescription() {
+ if (m_platform_description.empty()) {
+ if (IsConnected()) {
+ // Send the get description packet
+ }
+ }
+
+ if (!m_platform_description.empty())
+ return m_platform_description.c_str();
+ return GetDescriptionStatic();
+}
+
+Error PlatformRemoteGDBServer::ResolveExecutable(
+ const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ // copied from PlatformRemoteiOS
+
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ ModuleSpec resolved_module_spec(module_spec);
+
+ // Resolve any executable within an apk on Android?
+ // Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists() ||
+ module_spec.GetUUID().IsValid()) {
+ if (resolved_module_spec.GetArchitecture().IsValid() ||
+ resolved_module_spec.GetUUID().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, NULL, NULL);
+
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ return error;
+ exe_module_sp.reset();
+ }
+ // No valid architecture was specified or the exact arch wasn't
+ // found so ask the platform for the architectures that we should be
+ // using (in the correct order) and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, NULL, NULL);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
-bool
-PlatformRemoteGDBServer::GetModuleSpec (const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec)
-{
- Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetString().c_str());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' does not exist",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+
+ return error;
+}
+
+bool PlatformRemoteGDBServer::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- const auto module_path = module_file_spec.GetPath (false);
-
- if (!m_gdb_client.GetModuleInfo (module_file_spec, arch, module_spec))
- {
- if (log)
- log->Printf ("PlatformRemoteGDBServer::%s - failed to get module info for %s:%s",
- __FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str ());
- return false;
- }
+ const auto module_path = module_file_spec.GetPath(false);
+ if (!m_gdb_client.GetModuleInfo(module_file_spec, arch, module_spec)) {
if (log)
- {
- StreamString stream;
- module_spec.Dump (stream);
- log->Printf ("PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s",
- __FUNCTION__, module_path.c_str (), arch.GetTriple ().getTriple ().c_str (), stream.GetString ().c_str ());
- }
-
- return true;
-}
+ log->Printf(
+ "PlatformRemoteGDBServer::%s - failed to get module info for %s:%s",
+ __FUNCTION__, module_path.c_str(),
+ arch.GetTriple().getTriple().c_str());
+ return false;
+ }
-Error
-PlatformRemoteGDBServer::GetFileWithUUID (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file)
-{
- // Default to the local case
- local_file = platform_file;
- return Error();
+ if (log) {
+ StreamString stream;
+ module_spec.Dump(stream);
+ log->Printf(
+ "PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s",
+ __FUNCTION__, module_path.c_str(), arch.GetTriple().getTriple().c_str(),
+ stream.GetString().c_str());
+ }
+
+ return true;
+}
+
+Error PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
-PlatformRemoteGDBServer::PlatformRemoteGDBServer () :
- Platform (false), // This is a remote platform
- m_gdb_client ()
-{
-}
+PlatformRemoteGDBServer::PlatformRemoteGDBServer()
+ : Platform(false), // This is a remote platform
+ m_gdb_client() {}
//------------------------------------------------------------------
/// Destructor.
@@ -242,793 +212,679 @@ PlatformRemoteGDBServer::PlatformRemoteG
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
-PlatformRemoteGDBServer::~PlatformRemoteGDBServer()
-{
-}
-
-bool
-PlatformRemoteGDBServer::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
-{
- ArchSpec remote_arch = m_gdb_client.GetSystemArchitecture();
-
- if (idx == 0)
- {
- arch = remote_arch;
- return arch.IsValid();
- }
- else if (idx == 1 && remote_arch.IsValid() && remote_arch.GetTriple().isArch64Bit())
- {
- arch.SetTriple(remote_arch.GetTriple().get32BitArchVariant());
- return arch.IsValid();
- }
- return false;
-}
+PlatformRemoteGDBServer::~PlatformRemoteGDBServer() {}
-size_t
-PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
-{
- // This isn't needed if the z/Z packets are supported in the GDB remote
- // server. But we might need a packet to detect this.
- return 0;
-}
-
-bool
-PlatformRemoteGDBServer::GetRemoteOSVersion ()
-{
- uint32_t major, minor, update;
- if (m_gdb_client.GetOSVersion (major, minor, update))
- {
- m_major_os_version = major;
- m_minor_os_version = minor;
- m_update_os_version = update;
- return true;
- }
- return false;
+bool PlatformRemoteGDBServer::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ ArchSpec remote_arch = m_gdb_client.GetSystemArchitecture();
+
+ if (idx == 0) {
+ arch = remote_arch;
+ return arch.IsValid();
+ } else if (idx == 1 && remote_arch.IsValid() &&
+ remote_arch.GetTriple().isArch64Bit()) {
+ arch.SetTriple(remote_arch.GetTriple().get32BitArchVariant());
+ return arch.IsValid();
+ }
+ return false;
+}
+
+size_t PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode(
+ Target &target, BreakpointSite *bp_site) {
+ // This isn't needed if the z/Z packets are supported in the GDB remote
+ // server. But we might need a packet to detect this.
+ return 0;
+}
+
+bool PlatformRemoteGDBServer::GetRemoteOSVersion() {
+ uint32_t major, minor, update;
+ if (m_gdb_client.GetOSVersion(major, minor, update)) {
+ m_major_os_version = major;
+ m_minor_os_version = minor;
+ m_update_os_version = update;
+ return true;
+ }
+ return false;
}
-bool
-PlatformRemoteGDBServer::GetRemoteOSBuildString (std::string &s)
-{
- return m_gdb_client.GetOSBuildString (s);
+bool PlatformRemoteGDBServer::GetRemoteOSBuildString(std::string &s) {
+ return m_gdb_client.GetOSBuildString(s);
}
-bool
-PlatformRemoteGDBServer::GetRemoteOSKernelDescription (std::string &s)
-{
- return m_gdb_client.GetOSKernelDescription (s);
+bool PlatformRemoteGDBServer::GetRemoteOSKernelDescription(std::string &s) {
+ return m_gdb_client.GetOSKernelDescription(s);
}
// Remote Platform subclasses need to override this function
-ArchSpec
-PlatformRemoteGDBServer::GetRemoteSystemArchitecture ()
-{
- return m_gdb_client.GetSystemArchitecture();
-}
-
-FileSpec
-PlatformRemoteGDBServer::GetRemoteWorkingDirectory()
-{
- if (IsConnected())
- {
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- FileSpec working_dir;
- if (m_gdb_client.GetWorkingDir(working_dir) && log)
- log->Printf("PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'",
- working_dir.GetCString());
- return working_dir;
- }
- else
- {
- return Platform::GetRemoteWorkingDirectory();
- }
+ArchSpec PlatformRemoteGDBServer::GetRemoteSystemArchitecture() {
+ return m_gdb_client.GetSystemArchitecture();
}
-bool
-PlatformRemoteGDBServer::SetRemoteWorkingDirectory(const FileSpec &working_dir)
-{
- if (IsConnected())
- {
- // Clear the working directory it case it doesn't get set correctly. This will
- // for use to re-read it
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf("PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')",
- working_dir.GetCString());
- return m_gdb_client.SetWorkingDir(working_dir) == 0;
- }
- else
- return Platform::SetRemoteWorkingDirectory(working_dir);
-}
-
-bool
-PlatformRemoteGDBServer::IsConnected () const
-{
- return m_gdb_client.IsConnected();
-}
-
-Error
-PlatformRemoteGDBServer::ConnectRemote (Args& args)
-{
- Error error;
- if (IsConnected())
- {
- error.SetErrorStringWithFormat ("the platform is already connected to '%s', execute 'platform disconnect' to close the current connection",
- GetHostname());
- }
- else
- {
- if (args.GetArgumentCount() == 1)
- {
- m_gdb_client.SetConnection(new ConnectionFileDescriptor());
- // we're going to reuse the hostname when we connect to the debugserver
- int port;
- std::string path;
- const char *url = args.GetArgumentAtIndex(0);
- if (!url)
- return Error("URL is null.");
- if (!UriParser::Parse(url, m_platform_scheme, m_platform_hostname, port, path))
- return Error("Invalid URL: %s", url);
-
- const ConnectionStatus status = m_gdb_client.Connect(url, &error);
- if (status == eConnectionStatusSuccess)
- {
- if (m_gdb_client.HandshakeWithServer(&error))
- {
- m_gdb_client.GetHostInfo();
- // If a working directory was set prior to connecting, send it down now
- if (m_working_dir)
- m_gdb_client.SetWorkingDir(m_working_dir);
- }
- else
- {
- m_gdb_client.Disconnect();
- if (error.Success())
- error.SetErrorString("handshake failed");
- }
- }
- }
- else
- {
- error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
- }
- }
- return error;
-}
-
-Error
-PlatformRemoteGDBServer::DisconnectRemote ()
-{
- Error error;
- m_gdb_client.Disconnect(&error);
- m_remote_signals_sp.reset();
- return error;
-}
-
-const char *
-PlatformRemoteGDBServer::GetHostname ()
-{
- m_gdb_client.GetHostname (m_name);
- if (m_name.empty())
- return NULL;
- return m_name.c_str();
-}
-
-const char *
-PlatformRemoteGDBServer::GetUserName (uint32_t uid)
-{
- // Try and get a cache user name first
- const char *cached_user_name = Platform::GetUserName(uid);
- if (cached_user_name)
- return cached_user_name;
- std::string name;
- if (m_gdb_client.GetUserName(uid, name))
- return SetCachedUserName(uid, name.c_str(), name.size());
-
- SetUserNameNotFound(uid); // Negative cache so we don't keep sending packets
- return NULL;
-}
-
-const char *
-PlatformRemoteGDBServer::GetGroupName (uint32_t gid)
-{
- const char *cached_group_name = Platform::GetGroupName(gid);
- if (cached_group_name)
- return cached_group_name;
- std::string name;
- if (m_gdb_client.GetGroupName(gid, name))
- return SetCachedGroupName(gid, name.c_str(), name.size());
-
- SetGroupNameNotFound(gid); // Negative cache so we don't keep sending packets
+FileSpec PlatformRemoteGDBServer::GetRemoteWorkingDirectory() {
+ if (IsConnected()) {
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ FileSpec working_dir;
+ if (m_gdb_client.GetWorkingDir(working_dir) && log)
+ log->Printf(
+ "PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'",
+ working_dir.GetCString());
+ return working_dir;
+ } else {
+ return Platform::GetRemoteWorkingDirectory();
+ }
+}
+
+bool PlatformRemoteGDBServer::SetRemoteWorkingDirectory(
+ const FileSpec &working_dir) {
+ if (IsConnected()) {
+ // Clear the working directory it case it doesn't get set correctly. This
+ // will
+ // for use to re-read it
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')",
+ working_dir.GetCString());
+ return m_gdb_client.SetWorkingDir(working_dir) == 0;
+ } else
+ return Platform::SetRemoteWorkingDirectory(working_dir);
+}
+
+bool PlatformRemoteGDBServer::IsConnected() const {
+ return m_gdb_client.IsConnected();
+}
+
+Error PlatformRemoteGDBServer::ConnectRemote(Args &args) {
+ Error error;
+ if (IsConnected()) {
+ error.SetErrorStringWithFormat("the platform is already connected to '%s', "
+ "execute 'platform disconnect' to close the "
+ "current connection",
+ GetHostname());
+ } else {
+ if (args.GetArgumentCount() == 1) {
+ m_gdb_client.SetConnection(new ConnectionFileDescriptor());
+ // we're going to reuse the hostname when we connect to the debugserver
+ int port;
+ std::string path;
+ const char *url = args.GetArgumentAtIndex(0);
+ if (!url)
+ return Error("URL is null.");
+ if (!UriParser::Parse(url, m_platform_scheme, m_platform_hostname, port,
+ path))
+ return Error("Invalid URL: %s", url);
+
+ const ConnectionStatus status = m_gdb_client.Connect(url, &error);
+ if (status == eConnectionStatusSuccess) {
+ if (m_gdb_client.HandshakeWithServer(&error)) {
+ m_gdb_client.GetHostInfo();
+ // If a working directory was set prior to connecting, send it down
+ // now
+ if (m_working_dir)
+ m_gdb_client.SetWorkingDir(m_working_dir);
+ } else {
+ m_gdb_client.Disconnect();
+ if (error.Success())
+ error.SetErrorString("handshake failed");
+ }
+ }
+ } else {
+ error.SetErrorString(
+ "\"platform connect\" takes a single argument: <connect-url>");
+ }
+ }
+ return error;
+}
+
+Error PlatformRemoteGDBServer::DisconnectRemote() {
+ Error error;
+ m_gdb_client.Disconnect(&error);
+ m_remote_signals_sp.reset();
+ return error;
+}
+
+const char *PlatformRemoteGDBServer::GetHostname() {
+ m_gdb_client.GetHostname(m_name);
+ if (m_name.empty())
return NULL;
+ return m_name.c_str();
}
-uint32_t
-PlatformRemoteGDBServer::FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos)
-{
- return m_gdb_client.FindProcesses (match_info, process_infos);
-}
-
-bool
-PlatformRemoteGDBServer::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
- return m_gdb_client.GetProcessInfo (pid, process_info);
-}
-
-
-Error
-PlatformRemoteGDBServer::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
- Error error;
-
- if (log)
- log->Printf ("PlatformRemoteGDBServer::%s() called", __FUNCTION__);
-
- auto num_file_actions = launch_info.GetNumFileActions ();
- for (decltype(num_file_actions) i = 0; i < num_file_actions; ++i)
- {
- const auto file_action = launch_info.GetFileActionAtIndex (i);
- if (file_action->GetAction () != FileAction::eFileActionOpen)
- continue;
- switch(file_action->GetFD())
- {
- case STDIN_FILENO:
- m_gdb_client.SetSTDIN(file_action->GetFileSpec());
- break;
- case STDOUT_FILENO:
- m_gdb_client.SetSTDOUT(file_action->GetFileSpec());
- break;
- case STDERR_FILENO:
- m_gdb_client.SetSTDERR(file_action->GetFileSpec());
- break;
- }
- }
-
- m_gdb_client.SetDisableASLR (launch_info.GetFlags().Test (eLaunchFlagDisableASLR));
- m_gdb_client.SetDetachOnError (launch_info.GetFlags().Test (eLaunchFlagDetachOnError));
-
- FileSpec working_dir = launch_info.GetWorkingDirectory();
- if (working_dir)
- {
- m_gdb_client.SetWorkingDir(working_dir);
- }
-
- // Send the environment and the program + arguments after we connect
- const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector();
-
- if (envp)
- {
- const char *env_entry;
- for (int i=0; (env_entry = envp[i]); ++i)
- {
- if (m_gdb_client.SendEnvironmentPacket(env_entry) != 0)
- break;
- }
- }
-
- ArchSpec arch_spec = launch_info.GetArchitecture();
- const char *arch_triple = arch_spec.GetTriple().str().c_str();
-
- m_gdb_client.SendLaunchArchPacket(arch_triple);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::%s() set launch architecture triple to '%s'", __FUNCTION__, arch_triple ? arch_triple : "<NULL>");
-
- int arg_packet_err;
- {
- // Scope for the scoped timeout object
- process_gdb_remote::GDBRemoteCommunication::ScopedTimeout timeout(m_gdb_client, 5);
- arg_packet_err = m_gdb_client.SendArgumentsPacket (launch_info);
- }
-
- if (arg_packet_err == 0)
- {
- std::string error_str;
- if (m_gdb_client.GetLaunchSuccess (error_str))
- {
- const auto pid = m_gdb_client.GetCurrentProcessID (false);
- if (pid != LLDB_INVALID_PROCESS_ID)
- {
- launch_info.SetProcessID (pid);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::%s() pid %" PRIu64 " launched successfully", __FUNCTION__, pid);
- }
- else
- {
- if (log)
- log->Printf ("PlatformRemoteGDBServer::%s() launch succeeded but we didn't get a valid process id back!", __FUNCTION__);
- error.SetErrorString ("failed to get PID");
+const char *PlatformRemoteGDBServer::GetUserName(uint32_t uid) {
+ // Try and get a cache user name first
+ const char *cached_user_name = Platform::GetUserName(uid);
+ if (cached_user_name)
+ return cached_user_name;
+ std::string name;
+ if (m_gdb_client.GetUserName(uid, name))
+ return SetCachedUserName(uid, name.c_str(), name.size());
+
+ SetUserNameNotFound(uid); // Negative cache so we don't keep sending packets
+ return NULL;
+}
+
+const char *PlatformRemoteGDBServer::GetGroupName(uint32_t gid) {
+ const char *cached_group_name = Platform::GetGroupName(gid);
+ if (cached_group_name)
+ return cached_group_name;
+ std::string name;
+ if (m_gdb_client.GetGroupName(gid, name))
+ return SetCachedGroupName(gid, name.c_str(), name.size());
+
+ SetGroupNameNotFound(gid); // Negative cache so we don't keep sending packets
+ return NULL;
+}
+
+uint32_t PlatformRemoteGDBServer::FindProcesses(
+ const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ return m_gdb_client.FindProcesses(match_info, process_infos);
+}
+
+bool PlatformRemoteGDBServer::GetProcessInfo(
+ lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+ return m_gdb_client.GetProcessInfo(pid, process_info);
+}
+
+Error PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ Error error;
+
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::%s() called", __FUNCTION__);
+
+ auto num_file_actions = launch_info.GetNumFileActions();
+ for (decltype(num_file_actions) i = 0; i < num_file_actions; ++i) {
+ const auto file_action = launch_info.GetFileActionAtIndex(i);
+ if (file_action->GetAction() != FileAction::eFileActionOpen)
+ continue;
+ switch (file_action->GetFD()) {
+ case STDIN_FILENO:
+ m_gdb_client.SetSTDIN(file_action->GetFileSpec());
+ break;
+ case STDOUT_FILENO:
+ m_gdb_client.SetSTDOUT(file_action->GetFileSpec());
+ break;
+ case STDERR_FILENO:
+ m_gdb_client.SetSTDERR(file_action->GetFileSpec());
+ break;
+ }
+ }
+
+ m_gdb_client.SetDisableASLR(
+ launch_info.GetFlags().Test(eLaunchFlagDisableASLR));
+ m_gdb_client.SetDetachOnError(
+ launch_info.GetFlags().Test(eLaunchFlagDetachOnError));
+
+ FileSpec working_dir = launch_info.GetWorkingDirectory();
+ if (working_dir) {
+ m_gdb_client.SetWorkingDir(working_dir);
+ }
+
+ // Send the environment and the program + arguments after we connect
+ const char **envp =
+ launch_info.GetEnvironmentEntries().GetConstArgumentVector();
+
+ if (envp) {
+ const char *env_entry;
+ for (int i = 0; (env_entry = envp[i]); ++i) {
+ if (m_gdb_client.SendEnvironmentPacket(env_entry) != 0)
+ break;
+ }
+ }
+
+ ArchSpec arch_spec = launch_info.GetArchitecture();
+ const char *arch_triple = arch_spec.GetTriple().str().c_str();
+
+ m_gdb_client.SendLaunchArchPacket(arch_triple);
+ if (log)
+ log->Printf(
+ "PlatformRemoteGDBServer::%s() set launch architecture triple to '%s'",
+ __FUNCTION__, arch_triple ? arch_triple : "<NULL>");
+
+ int arg_packet_err;
+ {
+ // Scope for the scoped timeout object
+ process_gdb_remote::GDBRemoteCommunication::ScopedTimeout timeout(
+ m_gdb_client, 5);
+ arg_packet_err = m_gdb_client.SendArgumentsPacket(launch_info);
+ }
+
+ if (arg_packet_err == 0) {
+ std::string error_str;
+ if (m_gdb_client.GetLaunchSuccess(error_str)) {
+ const auto pid = m_gdb_client.GetCurrentProcessID(false);
+ if (pid != LLDB_INVALID_PROCESS_ID) {
+ launch_info.SetProcessID(pid);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::%s() pid %" PRIu64
+ " launched successfully",
+ __FUNCTION__, pid);
+ } else {
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::%s() launch succeeded but we "
+ "didn't get a valid process id back!",
+ __FUNCTION__);
+ error.SetErrorString("failed to get PID");
+ }
+ } else {
+ error.SetErrorString(error_str.c_str());
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::%s() launch failed: %s",
+ __FUNCTION__, error.AsCString());
+ }
+ } else {
+ error.SetErrorStringWithFormat("'A' packet returned an error: %i",
+ arg_packet_err);
+ }
+ return error;
+}
+
+Error PlatformRemoteGDBServer::KillProcess(const lldb::pid_t pid) {
+ if (!KillSpawnedProcess(pid))
+ return Error("failed to kill remote spawned process");
+ return Error();
+}
+
+lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
+ ProcessLaunchInfo &launch_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new target, else use
+ // existing one
+ Error &error) {
+ lldb::ProcessSP process_sp;
+ if (IsRemote()) {
+ if (IsConnected()) {
+ lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
+ std::string connect_url;
+ if (!LaunchGDBServer(debugserver_pid, connect_url)) {
+ error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
+ GetHostname());
+ } else {
+ if (target == NULL) {
+ TargetSP new_target_sp;
+
+ error = debugger.GetTargetList().CreateTarget(
+ debugger, NULL, NULL, false, NULL, new_target_sp);
+ target = new_target_sp.get();
+ } else
+ error.Clear();
+
+ if (target && error.Success()) {
+ debugger.GetTargetList().SetSelectedTarget(target);
+
+ // The darwin always currently uses the GDB remote debugger plug-in
+ // so even when debugging locally we are debugging remotely!
+ process_sp = target->CreateProcess(
+ launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+
+ if (process_sp) {
+ error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ // Retry the connect remote one time...
+ if (error.Fail())
+ error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ if (error.Success())
+ error = process_sp->Launch(launch_info);
+ else if (debugserver_pid != LLDB_INVALID_PROCESS_ID) {
+ printf("error: connect remote failed (%s)\n", error.AsCString());
+ KillSpawnedProcess(debugserver_pid);
}
+ }
}
- else
- {
- error.SetErrorString (error_str.c_str());
- if (log)
- log->Printf ("PlatformRemoteGDBServer::%s() launch failed: %s", __FUNCTION__, error.AsCString ());
- }
- }
- else
- {
- error.SetErrorStringWithFormat("'A' packet returned an error: %i", arg_packet_err);
- }
- return error;
-}
+ }
+ } else {
+ error.SetErrorString("not connected to remote gdb server");
+ }
+ }
+ return process_sp;
+}
+
+bool PlatformRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid,
+ std::string &connect_url) {
+ ArchSpec remote_arch = GetRemoteSystemArchitecture();
+ llvm::Triple &remote_triple = remote_arch.GetTriple();
+
+ uint16_t port = 0;
+ std::string socket_name;
+ bool launch_result = false;
+ if (remote_triple.getVendor() == llvm::Triple::Apple &&
+ remote_triple.getOS() == llvm::Triple::IOS) {
+ // When remote debugging to iOS, we use a USB mux that always talks
+ // to localhost, so we will need the remote debugserver to accept
+ // connections
+ // only from localhost, no matter what our current hostname is
+ launch_result =
+ m_gdb_client.LaunchGDBServer("127.0.0.1", pid, port, socket_name);
+ } else {
+ // All other hosts should use their actual hostname
+ launch_result =
+ m_gdb_client.LaunchGDBServer(nullptr, pid, port, socket_name);
+ }
-Error
-PlatformRemoteGDBServer::KillProcess (const lldb::pid_t pid)
-{
- if (!KillSpawnedProcess(pid))
- return Error("failed to kill remote spawned process");
- return Error();
-}
+ if (!launch_result)
+ return false;
-lldb::ProcessSP
-PlatformRemoteGDBServer::DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error)
-{
- lldb::ProcessSP process_sp;
- if (IsRemote())
- {
- if (IsConnected())
- {
- lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
- std::string connect_url;
- if (!LaunchGDBServer(debugserver_pid, connect_url))
- {
- error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ());
- }
- else
- {
- if (target == NULL)
- {
- TargetSP new_target_sp;
-
- error = debugger.GetTargetList().CreateTarget (debugger,
- NULL,
- NULL,
- false,
- NULL,
- new_target_sp);
- target = new_target_sp.get();
- }
- else
- error.Clear();
-
- if (target && error.Success())
- {
- debugger.GetTargetList().SetSelectedTarget(target);
-
- // The darwin always currently uses the GDB remote debugger plug-in
- // so even when debugging locally we are debugging remotely!
- process_sp = target->CreateProcess (launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
-
- if (process_sp)
- {
- error = process_sp->ConnectRemote (nullptr, connect_url.c_str());
- // Retry the connect remote one time...
- if (error.Fail())
- error = process_sp->ConnectRemote (nullptr, connect_url.c_str());
- if (error.Success())
- error = process_sp->Launch(launch_info);
- else if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
- {
- printf ("error: connect remote failed (%s)\n", error.AsCString());
- KillSpawnedProcess(debugserver_pid);
- }
- }
- }
+ connect_url =
+ MakeGdbServerUrl(m_platform_scheme, m_platform_hostname, port,
+ (socket_name.empty()) ? nullptr : socket_name.c_str());
+ return true;
+}
+
+bool PlatformRemoteGDBServer::KillSpawnedProcess(lldb::pid_t pid) {
+ return m_gdb_client.KillSpawnedProcess(pid);
+}
+
+lldb::ProcessSP PlatformRemoteGDBServer::Attach(
+ ProcessAttachInfo &attach_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new target, else use
+ // existing one
+ Error &error) {
+ lldb::ProcessSP process_sp;
+ if (IsRemote()) {
+ if (IsConnected()) {
+ lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
+ std::string connect_url;
+ if (!LaunchGDBServer(debugserver_pid, connect_url)) {
+ error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
+ GetHostname());
+ } else {
+ if (target == NULL) {
+ TargetSP new_target_sp;
+
+ error = debugger.GetTargetList().CreateTarget(
+ debugger, NULL, NULL, false, NULL, new_target_sp);
+ target = new_target_sp.get();
+ } else
+ error.Clear();
+
+ if (target && error.Success()) {
+ debugger.GetTargetList().SetSelectedTarget(target);
+
+ // The darwin always currently uses the GDB remote debugger plug-in
+ // so even when debugging locally we are debugging remotely!
+ process_sp = target->CreateProcess(
+ attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+ if (process_sp) {
+ error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ if (error.Success()) {
+ ListenerSP listener_sp = attach_info.GetHijackListener();
+ if (listener_sp)
+ process_sp->HijackProcessEvents(listener_sp);
+ error = process_sp->Attach(attach_info);
}
- }
- else
- {
- error.SetErrorString("not connected to remote gdb server");
- }
- }
- return process_sp;
-
-}
-
-bool
-PlatformRemoteGDBServer::LaunchGDBServer (lldb::pid_t &pid, std::string &connect_url)
-{
- ArchSpec remote_arch = GetRemoteSystemArchitecture ();
- llvm::Triple &remote_triple = remote_arch.GetTriple ();
-
- uint16_t port = 0;
- std::string socket_name;
- bool launch_result = false;
- if (remote_triple.getVendor () == llvm::Triple::Apple && remote_triple.getOS () == llvm::Triple::IOS)
- {
- // When remote debugging to iOS, we use a USB mux that always talks
- // to localhost, so we will need the remote debugserver to accept connections
- // only from localhost, no matter what our current hostname is
- launch_result = m_gdb_client.LaunchGDBServer ("127.0.0.1", pid, port, socket_name);
- }
- else
- {
- // All other hosts should use their actual hostname
- launch_result = m_gdb_client.LaunchGDBServer (nullptr, pid, port, socket_name);
- }
-
- if (!launch_result)
- return false;
-
- connect_url = MakeGdbServerUrl(m_platform_scheme,
- m_platform_hostname,
- port,
- (socket_name.empty()) ? nullptr : socket_name.c_str());
- return true;
-}
-
-bool
-PlatformRemoteGDBServer::KillSpawnedProcess (lldb::pid_t pid)
-{
- return m_gdb_client.KillSpawnedProcess (pid);
-}
-lldb::ProcessSP
-PlatformRemoteGDBServer::Attach (ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error)
-{
- lldb::ProcessSP process_sp;
- if (IsRemote())
- {
- if (IsConnected())
- {
- lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
- std::string connect_url;
- if (!LaunchGDBServer(debugserver_pid, connect_url))
- {
- error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ());
- }
- else
- {
- if (target == NULL)
- {
- TargetSP new_target_sp;
-
- error = debugger.GetTargetList().CreateTarget (debugger,
- NULL,
- NULL,
- false,
- NULL,
- new_target_sp);
- target = new_target_sp.get();
- }
- else
- error.Clear();
-
- if (target && error.Success())
- {
- debugger.GetTargetList().SetSelectedTarget(target);
-
- // The darwin always currently uses the GDB remote debugger plug-in
- // so even when debugging locally we are debugging remotely!
- process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
- if (process_sp)
- {
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
- if (error.Success())
- {
- ListenerSP listener_sp = attach_info.GetHijackListener();
- if (listener_sp)
- process_sp->HijackProcessEvents(listener_sp);
- error = process_sp->Attach(attach_info);
- }
-
- if (error.Fail() && debugserver_pid != LLDB_INVALID_PROCESS_ID)
- {
- KillSpawnedProcess(debugserver_pid);
- }
- }
- }
+ if (error.Fail() && debugserver_pid != LLDB_INVALID_PROCESS_ID) {
+ KillSpawnedProcess(debugserver_pid);
}
+ }
}
- else
- {
- error.SetErrorString("not connected to remote gdb server");
- }
- }
- return process_sp;
-}
-
-Error
-PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec, uint32_t mode)
-{
- Error error = m_gdb_client.MakeDirectory(file_spec, mode);
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) error = %u (%s)",
- file_spec.GetCString(), mode, error.GetError(), error.AsCString());
- return error;
-}
-
-
-Error
-PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions)
-{
- Error error = m_gdb_client.GetFilePermissions(file_spec, file_permissions);
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::GetFilePermissions(path='%s', file_permissions=%o) error = %u (%s)",
- file_spec.GetCString(), file_permissions, error.GetError(), error.AsCString());
- return error;
+ }
+ } else {
+ error.SetErrorString("not connected to remote gdb server");
+ }
+ }
+ return process_sp;
+}
+
+Error PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec,
+ uint32_t mode) {
+ Error error = m_gdb_client.MakeDirectory(file_spec, mode);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) "
+ "error = %u (%s)",
+ file_spec.GetCString(), mode, error.GetError(),
+ error.AsCString());
+ return error;
+}
+
+Error PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) {
+ Error error = m_gdb_client.GetFilePermissions(file_spec, file_permissions);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::GetFilePermissions(path='%s', "
+ "file_permissions=%o) error = %u (%s)",
+ file_spec.GetCString(), file_permissions, error.GetError(),
+ error.AsCString());
+ return error;
+}
+
+Error PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ Error error = m_gdb_client.SetFilePermissions(file_spec, file_permissions);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::SetFilePermissions(path='%s', "
+ "file_permissions=%o) error = %u (%s)",
+ file_spec.GetCString(), file_permissions, error.GetError(),
+ error.AsCString());
+ return error;
+}
+
+lldb::user_id_t PlatformRemoteGDBServer::OpenFile(const FileSpec &file_spec,
+ uint32_t flags, uint32_t mode,
+ Error &error) {
+ return m_gdb_client.OpenFile(file_spec, flags, mode, error);
}
-Error
-PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions)
-{
- Error error = m_gdb_client.SetFilePermissions(file_spec, file_permissions);
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::SetFilePermissions(path='%s', file_permissions=%o) error = %u (%s)",
- file_spec.GetCString(), file_permissions, error.GetError(), error.AsCString());
- return error;
+bool PlatformRemoteGDBServer::CloseFile(lldb::user_id_t fd, Error &error) {
+ return m_gdb_client.CloseFile(fd, error);
}
-
lldb::user_id_t
-PlatformRemoteGDBServer::OpenFile (const FileSpec& file_spec,
- uint32_t flags,
- uint32_t mode,
- Error &error)
-{
- return m_gdb_client.OpenFile (file_spec, flags, mode, error);
+PlatformRemoteGDBServer::GetFileSize(const FileSpec &file_spec) {
+ return m_gdb_client.GetFileSize(file_spec);
}
-bool
-PlatformRemoteGDBServer::CloseFile (lldb::user_id_t fd, Error &error)
-{
- return m_gdb_client.CloseFile (fd, error);
+uint64_t PlatformRemoteGDBServer::ReadFile(lldb::user_id_t fd, uint64_t offset,
+ void *dst, uint64_t dst_len,
+ Error &error) {
+ return m_gdb_client.ReadFile(fd, offset, dst, dst_len, error);
}
-lldb::user_id_t
-PlatformRemoteGDBServer::GetFileSize (const FileSpec& file_spec)
-{
- return m_gdb_client.GetFileSize(file_spec);
+uint64_t PlatformRemoteGDBServer::WriteFile(lldb::user_id_t fd, uint64_t offset,
+ const void *src, uint64_t src_len,
+ Error &error) {
+ return m_gdb_client.WriteFile(fd, offset, src, src_len, error);
}
-uint64_t
-PlatformRemoteGDBServer::ReadFile (lldb::user_id_t fd,
- uint64_t offset,
- void *dst,
- uint64_t dst_len,
- Error &error)
-{
- return m_gdb_client.ReadFile (fd, offset, dst, dst_len, error);
-}
-
-uint64_t
-PlatformRemoteGDBServer::WriteFile (lldb::user_id_t fd,
- uint64_t offset,
- const void* src,
- uint64_t src_len,
- Error &error)
-{
- return m_gdb_client.WriteFile (fd, offset, src, src_len, error);
+Error PlatformRemoteGDBServer::PutFile(const FileSpec &source,
+ const FileSpec &destination,
+ uint32_t uid, uint32_t gid) {
+ return Platform::PutFile(source, destination, uid, gid);
}
-Error
-PlatformRemoteGDBServer::PutFile (const FileSpec& source,
- const FileSpec& destination,
- uint32_t uid,
- uint32_t gid)
+Error PlatformRemoteGDBServer::CreateSymlink(
+ const FileSpec &src, // The name of the link is in src
+ const FileSpec &dst) // The symlink points to dst
{
- return Platform::PutFile(source,destination,uid,gid);
+ Error error = m_gdb_client.CreateSymlink(src, dst);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') "
+ "error = %u (%s)",
+ src.GetCString(), dst.GetCString(), error.GetError(),
+ error.AsCString());
+ return error;
}
-Error
-PlatformRemoteGDBServer::CreateSymlink(const FileSpec &src, // The name of the link is in src
- const FileSpec &dst) // The symlink points to dst
-{
- Error error = m_gdb_client.CreateSymlink(src, dst);
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') error = %u (%s)",
- src.GetCString(), dst.GetCString(), error.GetError(), error.AsCString());
- return error;
-}
-
-Error
-PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec)
-{
- Error error = m_gdb_client.Unlink(file_spec);
- Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
- if (log)
- log->Printf ("PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)",
+Error PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) {
+ Error error = m_gdb_client.Unlink(file_spec);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+ if (log)
+ log->Printf("PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)",
file_spec.GetCString(), error.GetError(), error.AsCString());
- return error;
+ return error;
}
-bool
-PlatformRemoteGDBServer::GetFileExists (const FileSpec& file_spec)
-{
- return m_gdb_client.GetFileExists (file_spec);
+bool PlatformRemoteGDBServer::GetFileExists(const FileSpec &file_spec) {
+ return m_gdb_client.GetFileExists(file_spec);
}
-Error
-PlatformRemoteGDBServer::RunShellCommand(const char *command, // Shouldn't be NULL
- const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec) // Timeout in seconds to wait for shell program to finish
+Error PlatformRemoteGDBServer::RunShellCommand(
+ const char *command, // Shouldn't be NULL
+ const FileSpec &
+ working_dir, // Pass empty FileSpec to use the current working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the
+ // process to exit
+ std::string
+ *command_output, // Pass NULL if you don't want the command output
+ uint32_t
+ timeout_sec) // Timeout in seconds to wait for shell program to finish
{
- return m_gdb_client.RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
+ return m_gdb_client.RunShellCommand(command, working_dir, status_ptr,
+ signo_ptr, command_output, timeout_sec);
}
-void
-PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames ()
-{
- m_trap_handlers.push_back (ConstString ("_sigtramp"));
+void PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
}
-const UnixSignalsSP &
-PlatformRemoteGDBServer::GetRemoteUnixSignals()
-{
- if (!IsConnected())
- return Platform::GetRemoteUnixSignals();
+const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
+ if (!IsConnected())
+ return Platform::GetRemoteUnixSignals();
- if (m_remote_signals_sp)
- return m_remote_signals_sp;
+ if (m_remote_signals_sp)
+ return m_remote_signals_sp;
- // If packet not implemented or JSON failed to parse,
- // we'll guess the signal set based on the remote architecture.
- m_remote_signals_sp = UnixSignals::Create(GetRemoteSystemArchitecture());
-
- const char packet[] = "jSignalsInfo";
- StringExtractorGDBRemote response;
- auto result = m_gdb_client.SendPacketAndWaitForResponse(
- packet, strlen(packet), response, false);
-
- if (result != decltype(result)::Success ||
- response.GetResponseType() != response.eResponse)
- return m_remote_signals_sp;
-
- auto object_sp = StructuredData::ParseJSON(response.GetStringRef());
- if (!object_sp || !object_sp->IsValid())
- return m_remote_signals_sp;
-
- auto array_sp = object_sp->GetAsArray();
- if (!array_sp || !array_sp->IsValid())
- return m_remote_signals_sp;
-
- auto remote_signals_sp = std::make_shared<lldb_private::GDBRemoteSignals>();
-
- bool done = array_sp->ForEach(
- [&remote_signals_sp](StructuredData::Object *object) -> bool
- {
- if (!object || !object->IsValid())
- return false;
-
- auto dict = object->GetAsDictionary();
- if (!dict || !dict->IsValid())
- return false;
-
- // Signal number and signal name are required.
- int signo;
- if (!dict->GetValueForKeyAsInteger("signo", signo))
- return false;
-
- std::string name;
- if (!dict->GetValueForKeyAsString("name", name))
- return false;
-
- // We can live without short_name, description, etc.
- bool suppress{false};
- auto object_sp = dict->GetValueForKey("suppress");
- if (object_sp && object_sp->IsValid())
- suppress = object_sp->GetBooleanValue();
-
- bool stop{false};
- object_sp = dict->GetValueForKey("stop");
- if (object_sp && object_sp->IsValid())
- stop = object_sp->GetBooleanValue();
-
- bool notify{false};
- object_sp = dict->GetValueForKey("notify");
- if (object_sp && object_sp->IsValid())
- notify = object_sp->GetBooleanValue();
-
- std::string description{""};
- object_sp = dict->GetValueForKey("description");
- if (object_sp && object_sp->IsValid())
- description = object_sp->GetStringValue();
-
- remote_signals_sp->AddSignal(signo,
- name.c_str(),
- suppress, stop, notify,
- description.c_str());
- return true;
- });
+ // If packet not implemented or JSON failed to parse,
+ // we'll guess the signal set based on the remote architecture.
+ m_remote_signals_sp = UnixSignals::Create(GetRemoteSystemArchitecture());
+
+ const char packet[] = "jSignalsInfo";
+ StringExtractorGDBRemote response;
+ auto result = m_gdb_client.SendPacketAndWaitForResponse(
+ packet, strlen(packet), response, false);
- if (done)
- m_remote_signals_sp = std::move(remote_signals_sp);
+ if (result != decltype(result)::Success ||
+ response.GetResponseType() != response.eResponse)
+ return m_remote_signals_sp;
+ auto object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ if (!object_sp || !object_sp->IsValid())
return m_remote_signals_sp;
-}
-std::string
-PlatformRemoteGDBServer::MakeGdbServerUrl(const std::string &platform_scheme,
- const std::string &platform_hostname,
- uint16_t port,
- const char* socket_name)
-{
- const char *override_scheme = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_SCHEME");
- const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
- const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
- int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
-
- return MakeUrl(override_scheme ? override_scheme : platform_scheme.c_str(),
- override_hostname ? override_hostname : platform_hostname.c_str(),
- port + port_offset,
- socket_name);
-}
-
-std::string
-PlatformRemoteGDBServer::MakeUrl(const char* scheme,
- const char* hostname,
- uint16_t port,
- const char* path)
-{
- StreamString result;
- result.Printf("%s://%s", scheme, hostname);
- if (port != 0)
- result.Printf(":%u", port);
- if (path)
- result.Write(path, strlen(path));
- return result.GetString();
-}
+ auto array_sp = object_sp->GetAsArray();
+ if (!array_sp || !array_sp->IsValid())
+ return m_remote_signals_sp;
-lldb::ProcessSP
-PlatformRemoteGDBServer::ConnectProcess(const char* connect_url,
- const char* plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Error &error)
-{
- if (!IsRemote() || !IsConnected())
- {
- error.SetErrorString("Not connected to remote gdb server");
- return nullptr;
- }
- return Platform::ConnectProcess(connect_url, plugin_name, debugger, target, error);
-}
+ auto remote_signals_sp = std::make_shared<lldb_private::GDBRemoteSignals>();
-size_t
-PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger& debugger, Error& error)
-{
- std::vector<std::string> connection_urls;
- GetPendingGdbServerList(connection_urls);
+ bool done = array_sp->ForEach(
+ [&remote_signals_sp](StructuredData::Object *object) -> bool {
+ if (!object || !object->IsValid())
+ return false;
+
+ auto dict = object->GetAsDictionary();
+ if (!dict || !dict->IsValid())
+ return false;
+
+ // Signal number and signal name are required.
+ int signo;
+ if (!dict->GetValueForKeyAsInteger("signo", signo))
+ return false;
+
+ std::string name;
+ if (!dict->GetValueForKeyAsString("name", name))
+ return false;
+
+ // We can live without short_name, description, etc.
+ bool suppress{false};
+ auto object_sp = dict->GetValueForKey("suppress");
+ if (object_sp && object_sp->IsValid())
+ suppress = object_sp->GetBooleanValue();
+
+ bool stop{false};
+ object_sp = dict->GetValueForKey("stop");
+ if (object_sp && object_sp->IsValid())
+ stop = object_sp->GetBooleanValue();
+
+ bool notify{false};
+ object_sp = dict->GetValueForKey("notify");
+ if (object_sp && object_sp->IsValid())
+ notify = object_sp->GetBooleanValue();
+
+ std::string description{""};
+ object_sp = dict->GetValueForKey("description");
+ if (object_sp && object_sp->IsValid())
+ description = object_sp->GetStringValue();
- for (size_t i = 0; i < connection_urls.size(); ++i)
- {
- ConnectProcess(connection_urls[i].c_str(), nullptr, debugger, nullptr, error);
- if (error.Fail())
- return i; // We already connected to i process succsessfully
- }
- return connection_urls.size();
+ remote_signals_sp->AddSignal(signo, name.c_str(), suppress, stop,
+ notify, description.c_str());
+ return true;
+ });
+ if (done)
+ m_remote_signals_sp = std::move(remote_signals_sp);
+
+ return m_remote_signals_sp;
}
-size_t
-PlatformRemoteGDBServer::GetPendingGdbServerList(std::vector<std::string>& connection_urls)
-{
- std::vector<std::pair<uint16_t, std::string>> remote_servers;
- m_gdb_client.QueryGDBServer(remote_servers);
- for (const auto& gdbserver : remote_servers)
- {
- const char* socket_name_cstr = gdbserver.second.empty() ? nullptr : gdbserver.second.c_str();
- connection_urls.emplace_back(MakeGdbServerUrl(m_platform_scheme,
- m_platform_hostname,
- gdbserver.first,
- socket_name_cstr));
- }
- return connection_urls.size();
+std::string PlatformRemoteGDBServer::MakeGdbServerUrl(
+ const std::string &platform_scheme, const std::string &platform_hostname,
+ uint16_t port, const char *socket_name) {
+ const char *override_scheme =
+ getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_SCHEME");
+ const char *override_hostname =
+ getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
+ const char *port_offset_c_str =
+ getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
+ int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
+
+ return MakeUrl(override_scheme ? override_scheme : platform_scheme.c_str(),
+ override_hostname ? override_hostname
+ : platform_hostname.c_str(),
+ port + port_offset, socket_name);
+}
+
+std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
+ const char *hostname,
+ uint16_t port, const char *path) {
+ StreamString result;
+ result.Printf("%s://%s", scheme, hostname);
+ if (port != 0)
+ result.Printf(":%u", port);
+ if (path)
+ result.Write(path, strlen(path));
+ return result.GetString();
+}
+
+lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess(
+ const char *connect_url, const char *plugin_name,
+ lldb_private::Debugger &debugger, lldb_private::Target *target,
+ lldb_private::Error &error) {
+ if (!IsRemote() || !IsConnected()) {
+ error.SetErrorString("Not connected to remote gdb server");
+ return nullptr;
+ }
+ return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
+ error);
+}
+
+size_t PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger &debugger,
+ Error &error) {
+ std::vector<std::string> connection_urls;
+ GetPendingGdbServerList(connection_urls);
+
+ for (size_t i = 0; i < connection_urls.size(); ++i) {
+ ConnectProcess(connection_urls[i].c_str(), nullptr, debugger, nullptr,
+ error);
+ if (error.Fail())
+ return i; // We already connected to i process succsessfully
+ }
+ return connection_urls.size();
+}
+
+size_t PlatformRemoteGDBServer::GetPendingGdbServerList(
+ std::vector<std::string> &connection_urls) {
+ std::vector<std::pair<uint16_t, std::string>> remote_servers;
+ m_gdb_client.QueryGDBServer(remote_servers);
+ for (const auto &gdbserver : remote_servers) {
+ const char *socket_name_cstr =
+ gdbserver.second.empty() ? nullptr : gdbserver.second.c_str();
+ connection_urls.emplace_back(
+ MakeGdbServerUrl(m_platform_scheme, m_platform_hostname,
+ gdbserver.first, socket_name_cstr));
+ }
+ return connection_urls.size();
}
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- PlatformRemoteGDBServer.h ----------------------------------------*- C++ -*-===//
+//===-- PlatformRemoteGDBServer.h ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,256 +17,194 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Target/Platform.h"
#include "../../Process/gdb-remote/GDBRemoteCommunicationClient.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"
+#include "lldb/Target/Platform.h"
namespace lldb_private {
namespace platform_gdb_server {
-class PlatformRemoteGDBServer : public Platform
-{
+class PlatformRemoteGDBServer : public Platform {
public:
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
+
+ static ConstString GetPluginNameStatic();
+
+ static const char *GetDescriptionStatic();
+
+ PlatformRemoteGDBServer();
+
+ virtual ~PlatformRemoteGDBServer();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ ConstString GetPluginName() override { return GetPluginNameStatic(); }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ Error ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr) override;
+
+ bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
+ ModuleSpec &module_spec) override;
+
+ const char *GetDescription() override;
+
+ Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid_ptr,
+ FileSpec &local_file) override;
+
+ bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
+
+ uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
+
+ Error LaunchProcess(ProcessLaunchInfo &launch_info) override;
+
+ Error KillProcess(const lldb::pid_t pid) override;
+
+ lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
+ Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a
+ // new target, else use existing
+ // one
+ Error &error) override;
+
+ lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new
+ // target, else use existing one
+ Error &error) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+
+ size_t GetSoftwareBreakpointTrapOpcode(Target &target,
+ BreakpointSite *bp_site) override;
+
+ bool GetRemoteOSVersion() override;
+
+ bool GetRemoteOSBuildString(std::string &s) override;
+
+ bool GetRemoteOSKernelDescription(std::string &s) override;
+
+ // Remote Platform subclasses need to override this function
+ ArchSpec GetRemoteSystemArchitecture() override;
- static void
- Initialize ();
+ FileSpec GetRemoteWorkingDirectory() override;
- static void
- Terminate ();
-
- static lldb::PlatformSP
- CreateInstance (bool force, const ArchSpec *arch);
-
- static ConstString
- GetPluginNameStatic();
-
- static const char *
- GetDescriptionStatic();
-
-
- PlatformRemoteGDBServer ();
-
- virtual
- ~PlatformRemoteGDBServer();
-
- //------------------------------------------------------------
- // lldb_private::PluginInterface functions
- //------------------------------------------------------------
- ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
-
- //------------------------------------------------------------
- // lldb_private::Platform functions
- //------------------------------------------------------------
- Error
- ResolveExecutable (const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
-
- bool
- GetModuleSpec (const FileSpec& module_file_spec,
- const ArchSpec& arch,
- ModuleSpec &module_spec) override;
-
- const char *
- GetDescription () override;
-
- Error
- GetFileWithUUID (const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) override;
-
- bool
- GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
- uint32_t
- FindProcesses (const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) override;
-
- Error
- LaunchProcess (ProcessLaunchInfo &launch_info) override;
-
- Error
- KillProcess (const lldb::pid_t pid) override;
-
- lldb::ProcessSP
- DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error) override;
-
- lldb::ProcessSP
- Attach (ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Error &error) override;
-
- bool
- GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) override;
-
- size_t
- GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site) override;
-
- bool
- GetRemoteOSVersion () override;
-
- bool
- GetRemoteOSBuildString (std::string &s) override;
-
- bool
- GetRemoteOSKernelDescription (std::string &s) override;
-
- // Remote Platform subclasses need to override this function
- ArchSpec
- GetRemoteSystemArchitecture () override;
-
- FileSpec
- GetRemoteWorkingDirectory() override;
-
- bool
- SetRemoteWorkingDirectory(const FileSpec &working_dir) override;
-
- // Remote subclasses should override this and return a valid instance
- // name if connected.
- const char *
- GetHostname () override;
-
- const char *
- GetUserName (uint32_t uid) override;
-
- const char *
- GetGroupName (uint32_t gid) override;
-
- bool
- IsConnected () const override;
-
- Error
- ConnectRemote (Args& args) override;
-
- Error
- DisconnectRemote () override;
-
- Error
- MakeDirectory(const FileSpec &file_spec, uint32_t file_permissions) override;
-
- Error
- GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) override;
-
- Error
- SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) override;
-
-
- lldb::user_id_t
- OpenFile (const FileSpec& file_spec, uint32_t flags, uint32_t mode, Error &error) override;
-
- bool
- CloseFile (lldb::user_id_t fd, Error &error) override;
-
- uint64_t
- ReadFile (lldb::user_id_t fd,
- uint64_t offset,
- void *data_ptr,
- uint64_t len,
- Error &error) override;
-
- uint64_t
- WriteFile (lldb::user_id_t fd,
- uint64_t offset,
- const void* data,
- uint64_t len,
- Error &error) override;
-
- lldb::user_id_t
- GetFileSize (const FileSpec& file_spec) override;
-
- Error
- PutFile (const FileSpec& source,
- const FileSpec& destination,
- uint32_t uid = UINT32_MAX,
- uint32_t gid = UINT32_MAX) override;
-
- Error
- CreateSymlink(const FileSpec &src, const FileSpec &dst) override;
-
- bool
- GetFileExists (const FileSpec& file_spec) override;
-
- Error
- Unlink(const FileSpec &path) override;
-
- Error
- RunShellCommand(const char *command, // Shouldn't be NULL
- const FileSpec &working_dir, // Pass empty FileSpec to use the current working directory
- int *status_ptr, // Pass NULL if you don't want the process exit status
- int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
- std::string *command_output, // Pass NULL if you don't want the command output
- uint32_t timeout_sec) override; // Timeout in seconds to wait for shell program to finish
-
- void
- CalculateTrapHandlerSymbolNames () override;
-
- const lldb::UnixSignalsSP &
- GetRemoteUnixSignals() override;
-
- lldb::ProcessSP
- ConnectProcess (const char* connect_url,
- const char* plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Error &error) override;
+ bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override;
- size_t
- ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error) override;
+ // Remote subclasses should override this and return a valid instance
+ // name if connected.
+ const char *GetHostname() override;
- virtual size_t
- GetPendingGdbServerList(std::vector<std::string>& connection_urls);
+ const char *GetUserName(uint32_t uid) override;
+
+ const char *GetGroupName(uint32_t gid) override;
+
+ bool IsConnected() const override;
+
+ Error ConnectRemote(Args &args) override;
+
+ Error DisconnectRemote() override;
+
+ Error MakeDirectory(const FileSpec &file_spec,
+ uint32_t file_permissions) override;
+
+ Error GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) override;
+
+ Error SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) override;
+
+ lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
+ uint32_t mode, Error &error) override;
+
+ bool CloseFile(lldb::user_id_t fd, Error &error) override;
+
+ uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *data_ptr,
+ uint64_t len, Error &error) override;
+
+ uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *data,
+ uint64_t len, Error &error) override;
+
+ lldb::user_id_t GetFileSize(const FileSpec &file_spec) override;
+
+ Error PutFile(const FileSpec &source, const FileSpec &destination,
+ uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override;
+
+ Error CreateSymlink(const FileSpec &src, const FileSpec &dst) override;
+
+ bool GetFileExists(const FileSpec &file_spec) override;
+
+ Error Unlink(const FileSpec &path) override;
+
+ Error RunShellCommand(
+ const char *command, // Shouldn't be NULL
+ const FileSpec &working_dir, // Pass empty FileSpec to use the current
+ // working directory
+ int *status_ptr, // Pass NULL if you don't want the process exit status
+ int *signo_ptr, // Pass NULL if you don't want the signal that caused the
+ // process to exit
+ std::string
+ *command_output, // Pass NULL if you don't want the command output
+ uint32_t timeout_sec)
+ override; // Timeout in seconds to wait for shell program to finish
+
+ void CalculateTrapHandlerSymbolNames() override;
+
+ const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
+
+ lldb::ProcessSP ConnectProcess(const char *connect_url,
+ const char *plugin_name,
+ lldb_private::Debugger &debugger,
+ lldb_private::Target *target,
+ lldb_private::Error &error) override;
+
+ size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
+ lldb_private::Error &error) override;
+
+ virtual size_t
+ GetPendingGdbServerList(std::vector<std::string> &connection_urls);
protected:
- process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client;
- std::string m_platform_description; // After we connect we can get a more complete description of what we are connected to
- std::string m_platform_scheme;
- std::string m_platform_hostname;
-
- lldb::UnixSignalsSP m_remote_signals_sp;
-
- // Launch the debug server on the remote host - caller connects to launched
- // debug server using connect_url.
- // Subclasses should override this method if they want to do extra actions before or
- // after launching the debug server.
- virtual bool
- LaunchGDBServer (lldb::pid_t &pid, std::string &connect_url);
-
- virtual bool
- KillSpawnedProcess (lldb::pid_t pid);
-
- virtual std::string
- MakeUrl(const char* scheme,
- const char* hostname,
- uint16_t port,
- const char* path);
+ process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client;
+ std::string m_platform_description; // After we connect we can get a more
+ // complete description of what we are
+ // connected to
+ std::string m_platform_scheme;
+ std::string m_platform_hostname;
+
+ lldb::UnixSignalsSP m_remote_signals_sp;
+
+ // Launch the debug server on the remote host - caller connects to launched
+ // debug server using connect_url.
+ // Subclasses should override this method if they want to do extra actions
+ // before or
+ // after launching the debug server.
+ virtual bool LaunchGDBServer(lldb::pid_t &pid, std::string &connect_url);
-private:
- std::string
- MakeGdbServerUrl(const std::string &platform_scheme,
- const std::string &platform_hostname,
- uint16_t port,
- const char* socket_name);
+ virtual bool KillSpawnedProcess(lldb::pid_t pid);
+
+ virtual std::string MakeUrl(const char *scheme, const char *hostname,
+ uint16_t port, const char *path);
- DISALLOW_COPY_AND_ASSIGN (PlatformRemoteGDBServer);
+private:
+ std::string MakeGdbServerUrl(const std::string &platform_scheme,
+ const std::string &platform_hostname,
+ uint16_t port, const char *socket_name);
+ DISALLOW_COPY_AND_ASSIGN(PlatformRemoteGDBServer);
};
} // namespace platform_gdb_server
} // namespace lldb_private
-#endif // liblldb_PlatformRemoteGDBServer_h_
+#endif // liblldb_PlatformRemoteGDBServer_h_
Modified: lldb/trunk/source/Plugins/Process/Darwin/CFBundle.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Darwin/CFBundle.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Darwin/CFBundle.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Darwin/CFBundle.cpp Tue Sep 6 15:57:50 2016
@@ -17,81 +17,63 @@
//----------------------------------------------------------------------
// CFBundle constructor
//----------------------------------------------------------------------
-CFBundle::CFBundle(const char *path) :
- CFReleaser<CFBundleRef>(),
- m_bundle_url()
-{
- if (path && path[0])
- SetPath(path);
+CFBundle::CFBundle(const char *path)
+ : CFReleaser<CFBundleRef>(), m_bundle_url() {
+ if (path && path[0])
+ SetPath(path);
}
//----------------------------------------------------------------------
// CFBundle copy constructor
//----------------------------------------------------------------------
-CFBundle::CFBundle(const CFBundle& rhs) :
- CFReleaser<CFBundleRef>(rhs),
- m_bundle_url(rhs.m_bundle_url)
-{
-
-}
+CFBundle::CFBundle(const CFBundle &rhs)
+ : CFReleaser<CFBundleRef>(rhs), m_bundle_url(rhs.m_bundle_url) {}
//----------------------------------------------------------------------
// CFBundle copy constructor
//----------------------------------------------------------------------
-CFBundle&
-CFBundle::operator=(const CFBundle& rhs)
-{
- *this = rhs;
- return *this;
+CFBundle &CFBundle::operator=(const CFBundle &rhs) {
+ *this = rhs;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFBundle::~CFBundle()
-{
-}
+CFBundle::~CFBundle() {}
//----------------------------------------------------------------------
// Set the path for a bundle by supplying a
//----------------------------------------------------------------------
-bool
-CFBundle::SetPath (const char *path)
-{
- CFAllocatorRef alloc = kCFAllocatorDefault;
- // Release our old bundle and ULR
- reset(); // This class is a CFReleaser<CFBundleRef>
- m_bundle_url.reset();
- // Make a CFStringRef from the supplied path
- CFString cf_path;
- cf_path.SetFileSystemRepresentation(path);
- if (cf_path.get())
- {
- // Make our Bundle URL
- m_bundle_url.reset (::CFURLCreateWithFileSystemPath (alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
- if (m_bundle_url.get())
- {
- reset (::CFBundleCreate (alloc, m_bundle_url.get()));
- }
+bool CFBundle::SetPath(const char *path) {
+ CFAllocatorRef alloc = kCFAllocatorDefault;
+ // Release our old bundle and ULR
+ reset(); // This class is a CFReleaser<CFBundleRef>
+ m_bundle_url.reset();
+ // Make a CFStringRef from the supplied path
+ CFString cf_path;
+ cf_path.SetFileSystemRepresentation(path);
+ if (cf_path.get()) {
+ // Make our Bundle URL
+ m_bundle_url.reset(::CFURLCreateWithFileSystemPath(
+ alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
+ if (m_bundle_url.get()) {
+ reset(::CFBundleCreate(alloc, m_bundle_url.get()));
}
- return get() != NULL;
+ }
+ return get() != NULL;
}
-CFStringRef
-CFBundle::GetIdentifier () const
-{
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return ::CFBundleGetIdentifier (bundle);
- return NULL;
-}
-
-
-CFURLRef
-CFBundle::CopyExecutableURL () const
-{
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return CFBundleCopyExecutableURL(bundle);
- return NULL;
+CFStringRef CFBundle::GetIdentifier() const {
+ CFBundleRef bundle = get();
+ if (bundle != NULL)
+ return ::CFBundleGetIdentifier(bundle);
+ return NULL;
+}
+
+CFURLRef CFBundle::CopyExecutableURL() const {
+ CFBundleRef bundle = get();
+ if (bundle != NULL)
+ return CFBundleCopyExecutableURL(bundle);
+ return NULL;
}
Modified: lldb/trunk/source/Plugins/Process/Darwin/CFBundle.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Darwin/CFBundle.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Darwin/CFBundle.h (original)
+++ lldb/trunk/source/Plugins/Process/Darwin/CFBundle.h Tue Sep 6 15:57:50 2016
@@ -16,28 +16,23 @@
#include "CFUtils.h"
-class CFBundle : public CFReleaser<CFBundleRef>
-{
+class CFBundle : public CFReleaser<CFBundleRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFBundle(const char *path = NULL);
- CFBundle(const CFBundle& rhs);
- CFBundle& operator=(const CFBundle& rhs);
- virtual
- ~CFBundle();
- bool
- SetPath (const char *path);
-
- CFStringRef
- GetIdentifier () const;
-
- CFURLRef
- CopyExecutableURL () const;
-
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFBundle(const char *path = NULL);
+ CFBundle(const CFBundle &rhs);
+ CFBundle &operator=(const CFBundle &rhs);
+ virtual ~CFBundle();
+ bool SetPath(const char *path);
+
+ CFStringRef GetIdentifier() const;
+
+ CFURLRef CopyExecutableURL() const;
+
protected:
- CFReleaser<CFURLRef> m_bundle_url;
+ CFReleaser<CFURLRef> m_bundle_url;
};
#endif // #ifndef __CFBundle_h__
More information about the lldb-commits
mailing list