diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp')
-rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp | 378 |
1 files changed, 171 insertions, 207 deletions
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp index 296491ffeeb..e6da63e8af6 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -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::PlatformAppleSimulator () : /// 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); + 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()); + 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); - } - } + // 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 - |