1e996fd30SGreg Clayton //===-- PlatformLinux.cpp ---------------------------------------*- C++ -*-===// 2e996fd30SGreg Clayton // 3e996fd30SGreg Clayton // The LLVM Compiler Infrastructure 4e996fd30SGreg Clayton // 5e996fd30SGreg Clayton // This file is distributed under the University of Illinois Open Source 6e996fd30SGreg Clayton // License. See LICENSE.TXT for details. 7e996fd30SGreg Clayton // 8e996fd30SGreg Clayton //===----------------------------------------------------------------------===// 9e996fd30SGreg Clayton 1093a64300SDaniel Malea #include "lldb/lldb-python.h" 1193a64300SDaniel Malea 12e996fd30SGreg Clayton #include "PlatformLinux.h" 13e996fd30SGreg Clayton 14e996fd30SGreg Clayton // C Includes 15ecc11474SStephen Wilson #include <stdio.h> 16ecc11474SStephen Wilson #include <sys/utsname.h> 17ecc11474SStephen Wilson 18e996fd30SGreg Clayton // C++ Includes 19e996fd30SGreg Clayton // Other libraries and framework includes 20e996fd30SGreg Clayton // Project includes 21e996fd30SGreg Clayton #include "lldb/Core/Error.h" 2228041352SGreg Clayton #include "lldb/Core/Debugger.h" 23e996fd30SGreg Clayton #include "lldb/Core/Module.h" 24e996fd30SGreg Clayton #include "lldb/Core/ModuleList.h" 251f746071SGreg Clayton #include "lldb/Core/ModuleSpec.h" 26ecc11474SStephen Wilson #include "lldb/Core/PluginManager.h" 27e996fd30SGreg Clayton #include "lldb/Core/StreamString.h" 28e996fd30SGreg Clayton #include "lldb/Host/FileSpec.h" 29e996fd30SGreg Clayton #include "lldb/Host/Host.h" 30ecc11474SStephen Wilson #include "lldb/Target/Target.h" 31e996fd30SGreg Clayton #include "lldb/Target/Process.h" 32e996fd30SGreg Clayton 33e996fd30SGreg Clayton using namespace lldb; 34e996fd30SGreg Clayton using namespace lldb_private; 35e996fd30SGreg Clayton 3628041352SGreg Clayton static uint32_t g_initialize_count = 0; 3728041352SGreg Clayton 38ecc11474SStephen Wilson Platform * 39b3a40ba8SGreg Clayton PlatformLinux::CreateInstance (bool force, const ArchSpec *arch) 40ecc11474SStephen Wilson { 41b3a40ba8SGreg Clayton bool create = force; 42b3a40ba8SGreg Clayton if (create == false && arch && arch->IsValid()) 43b3a40ba8SGreg Clayton { 44b3a40ba8SGreg Clayton const llvm::Triple &triple = arch->GetTriple(); 4570512317SGreg Clayton switch (triple.getVendor()) 4670512317SGreg Clayton { 4770512317SGreg Clayton case llvm::Triple::PC: 48b3a40ba8SGreg Clayton create = true; 4970512317SGreg Clayton break; 5070512317SGreg Clayton 51dbc6c0bbSGreg Clayton #if defined(__linux__) 52dbc6c0bbSGreg Clayton // Only accept "unknown" for the vendor if the host is linux and 53dbc6c0bbSGreg Clayton // it "unknown" wasn't specified (it was just returned becasue it 54dbc6c0bbSGreg Clayton // was NOT specified_ 5570512317SGreg Clayton case llvm::Triple::UnknownArch: 5670512317SGreg Clayton create = !arch->TripleVendorWasSpecified(); 5770512317SGreg Clayton break; 58dbc6c0bbSGreg Clayton #endif 5970512317SGreg Clayton default: 6070512317SGreg Clayton break; 6170512317SGreg Clayton } 6270512317SGreg Clayton 6370512317SGreg Clayton if (create) 6470512317SGreg Clayton { 6570512317SGreg Clayton switch (triple.getOS()) 6670512317SGreg Clayton { 6770512317SGreg Clayton case llvm::Triple::Linux: 6870512317SGreg Clayton break; 6970512317SGreg Clayton 70dbc6c0bbSGreg Clayton #if defined(__linux__) 71dbc6c0bbSGreg Clayton // Only accept "unknown" for the OS if the host is linux and 72dbc6c0bbSGreg Clayton // it "unknown" wasn't specified (it was just returned becasue it 73dbc6c0bbSGreg Clayton // was NOT specified) 7470512317SGreg Clayton case llvm::Triple::UnknownOS: 7570512317SGreg Clayton create = !arch->TripleOSWasSpecified(); 7670512317SGreg Clayton break; 77dbc6c0bbSGreg Clayton #endif 7870512317SGreg Clayton default: 7970512317SGreg Clayton create = false; 8070512317SGreg Clayton break; 8170512317SGreg Clayton } 8270512317SGreg Clayton } 83b3a40ba8SGreg Clayton } 84b3a40ba8SGreg Clayton if (create) 8528041352SGreg Clayton return new PlatformLinux(true); 86b3a40ba8SGreg Clayton return NULL; 87ecc11474SStephen Wilson } 88ecc11474SStephen Wilson 89ecc11474SStephen Wilson 90*57abc5d6SGreg Clayton lldb_private::ConstString 91*57abc5d6SGreg Clayton PlatformLinux::GetPluginNameStatic (bool is_host) 92ecc11474SStephen Wilson { 9328041352SGreg Clayton if (is_host) 94*57abc5d6SGreg Clayton { 95*57abc5d6SGreg Clayton static ConstString g_host_name(Platform::GetHostPlatformName ()); 96*57abc5d6SGreg Clayton return g_host_name; 97*57abc5d6SGreg Clayton } 9828041352SGreg Clayton else 99*57abc5d6SGreg Clayton { 100*57abc5d6SGreg Clayton static ConstString g_remote_name("remote-linux"); 101*57abc5d6SGreg Clayton return g_remote_name; 102*57abc5d6SGreg Clayton } 10328041352SGreg Clayton } 10428041352SGreg Clayton 10528041352SGreg Clayton const char * 10628041352SGreg Clayton PlatformLinux::GetPluginDescriptionStatic (bool is_host) 10728041352SGreg Clayton { 10828041352SGreg Clayton if (is_host) 10928041352SGreg Clayton return "Local Linux user platform plug-in."; 11028041352SGreg Clayton else 11128041352SGreg Clayton return "Remote Linux user platform plug-in."; 112ecc11474SStephen Wilson } 113ecc11474SStephen Wilson 114*57abc5d6SGreg Clayton lldb_private::ConstString 115*57abc5d6SGreg Clayton PlatformLinux::GetPluginName() 116*57abc5d6SGreg Clayton { 117*57abc5d6SGreg Clayton return GetPluginNameStatic(IsHost()); 118*57abc5d6SGreg Clayton } 119*57abc5d6SGreg Clayton 120e996fd30SGreg Clayton void 121e996fd30SGreg Clayton PlatformLinux::Initialize () 122e996fd30SGreg Clayton { 12328041352SGreg Clayton if (g_initialize_count++ == 0) 124ecc11474SStephen Wilson { 12528041352SGreg Clayton #if defined(__linux__) 12628041352SGreg Clayton PlatformSP default_platform_sp (new PlatformLinux(true)); 12728041352SGreg Clayton default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); 128e996fd30SGreg Clayton Platform::SetDefaultPlatform (default_platform_sp); 12928041352SGreg Clayton #endif 130*57abc5d6SGreg Clayton PluginManager::RegisterPlugin(PlatformLinux::GetPluginNameStatic(false), 13128041352SGreg Clayton PlatformLinux::GetPluginDescriptionStatic(false), 13228041352SGreg Clayton PlatformLinux::CreateInstance); 133ecc11474SStephen Wilson } 134e996fd30SGreg Clayton } 135e996fd30SGreg Clayton 136e996fd30SGreg Clayton void 137e996fd30SGreg Clayton PlatformLinux::Terminate () 138e996fd30SGreg Clayton { 13928041352SGreg Clayton if (g_initialize_count > 0) 14028041352SGreg Clayton { 14128041352SGreg Clayton if (--g_initialize_count == 0) 14228041352SGreg Clayton { 14328041352SGreg Clayton PluginManager::UnregisterPlugin (PlatformLinux::CreateInstance); 144e996fd30SGreg Clayton } 14528041352SGreg Clayton } 14628041352SGreg Clayton } 147e996fd30SGreg Clayton 148e996fd30SGreg Clayton Error 149e996fd30SGreg Clayton PlatformLinux::ResolveExecutable (const FileSpec &exe_file, 150e996fd30SGreg Clayton const ArchSpec &exe_arch, 151ea5e0cc3SGreg Clayton lldb::ModuleSP &exe_module_sp, 152ea5e0cc3SGreg Clayton const FileSpecList *module_search_paths_ptr) 153e996fd30SGreg Clayton { 154e996fd30SGreg Clayton Error error; 155e996fd30SGreg Clayton // Nothing special to do here, just use the actual file and architecture 156e996fd30SGreg Clayton 15728041352SGreg Clayton char exe_path[PATH_MAX]; 158e996fd30SGreg Clayton FileSpec resolved_exe_file (exe_file); 159e996fd30SGreg Clayton 16028041352SGreg Clayton if (IsHost()) 16128041352SGreg Clayton { 16228041352SGreg Clayton // If we have "ls" as the exe_file, resolve the executable location based on 163e996fd30SGreg Clayton // the current path variables 164e996fd30SGreg Clayton if (!resolved_exe_file.Exists()) 16528041352SGreg Clayton { 16628041352SGreg Clayton exe_file.GetPath(exe_path, sizeof(exe_path)); 16728041352SGreg Clayton resolved_exe_file.SetFile(exe_path, true); 16828041352SGreg Clayton } 16928041352SGreg Clayton 17028041352SGreg Clayton if (!resolved_exe_file.Exists()) 171e996fd30SGreg Clayton resolved_exe_file.ResolveExecutableLocation (); 172e996fd30SGreg Clayton 17328041352SGreg Clayton if (resolved_exe_file.Exists()) 17428041352SGreg Clayton error.Clear(); 17528041352SGreg Clayton else 17628041352SGreg Clayton { 17728041352SGreg Clayton exe_file.GetPath(exe_path, sizeof(exe_path)); 17828041352SGreg Clayton error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path); 17928041352SGreg Clayton } 18028041352SGreg Clayton } 18128041352SGreg Clayton else 18228041352SGreg Clayton { 18328041352SGreg Clayton if (m_remote_platform_sp) 18428041352SGreg Clayton { 18528041352SGreg Clayton error = m_remote_platform_sp->ResolveExecutable (exe_file, 18628041352SGreg Clayton exe_arch, 1870c90ef47SGreg Clayton exe_module_sp, 1880c90ef47SGreg Clayton NULL); 18928041352SGreg Clayton } 19028041352SGreg Clayton else 19128041352SGreg Clayton { 19228041352SGreg Clayton // We may connect to a process and use the provided executable (Don't use local $PATH). 193e996fd30SGreg Clayton 194e996fd30SGreg Clayton if (resolved_exe_file.Exists()) 19528041352SGreg Clayton error.Clear(); 19628041352SGreg Clayton else 19728041352SGreg Clayton error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path); 19828041352SGreg Clayton } 19928041352SGreg Clayton } 20028041352SGreg Clayton 20128041352SGreg Clayton if (error.Success()) 202e996fd30SGreg Clayton { 203ea5e0cc3SGreg Clayton ModuleSpec module_spec (resolved_exe_file, exe_arch); 204e996fd30SGreg Clayton if (exe_arch.IsValid()) 205e996fd30SGreg Clayton { 206ea5e0cc3SGreg Clayton error = ModuleList::GetSharedModule (module_spec, 207e996fd30SGreg Clayton exe_module_sp, 208e996fd30SGreg Clayton NULL, 2090c90ef47SGreg Clayton NULL, 210e996fd30SGreg Clayton NULL); 211e996fd30SGreg Clayton 212e635db49SSean Callanan // TODO find out why exe_module_sp might be NULL 213e635db49SSean Callanan if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) 214e996fd30SGreg Clayton { 215e996fd30SGreg Clayton exe_module_sp.reset(); 216b5ad4ec7SGreg Clayton error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s", 217b5ad4ec7SGreg Clayton exe_file.GetPath().c_str(), 218e996fd30SGreg Clayton exe_arch.GetArchitectureName()); 219e996fd30SGreg Clayton } 220e996fd30SGreg Clayton } 221e996fd30SGreg Clayton else 222e996fd30SGreg Clayton { 223e996fd30SGreg Clayton // No valid architecture was specified, ask the platform for 224e996fd30SGreg Clayton // the architectures that we should be using (in the correct order) 225e996fd30SGreg Clayton // and see if we can find a match that way 226e996fd30SGreg Clayton StreamString arch_names; 227ea5e0cc3SGreg Clayton for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx) 228e996fd30SGreg Clayton { 229ea5e0cc3SGreg Clayton error = ModuleList::GetSharedModule (module_spec, 230e996fd30SGreg Clayton exe_module_sp, 231e996fd30SGreg Clayton NULL, 2320c90ef47SGreg Clayton NULL, 233e996fd30SGreg Clayton NULL); 234e996fd30SGreg Clayton // Did we find an executable using one of the 235e996fd30SGreg Clayton if (error.Success()) 236e996fd30SGreg Clayton { 237e996fd30SGreg Clayton if (exe_module_sp && exe_module_sp->GetObjectFile()) 238e996fd30SGreg Clayton break; 239e996fd30SGreg Clayton else 240e996fd30SGreg Clayton error.SetErrorToGenericError(); 241e996fd30SGreg Clayton } 242e996fd30SGreg Clayton 243e996fd30SGreg Clayton if (idx > 0) 244e996fd30SGreg Clayton arch_names.PutCString (", "); 245ea5e0cc3SGreg Clayton arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName()); 246e996fd30SGreg Clayton } 247e996fd30SGreg Clayton 248e996fd30SGreg Clayton if (error.Fail() || !exe_module_sp) 249e996fd30SGreg Clayton { 250b5ad4ec7SGreg Clayton error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", 251b5ad4ec7SGreg Clayton exe_file.GetPath().c_str(), 252*57abc5d6SGreg Clayton GetPluginName().GetCString(), 253e996fd30SGreg Clayton arch_names.GetString().c_str()); 254e996fd30SGreg Clayton } 255e996fd30SGreg Clayton } 256e996fd30SGreg Clayton } 257e996fd30SGreg Clayton 258e996fd30SGreg Clayton return error; 259e996fd30SGreg Clayton } 260e996fd30SGreg Clayton 261e996fd30SGreg Clayton Error 26278decfd0SStephen Wilson PlatformLinux::GetFile (const FileSpec &platform_file, 26328041352SGreg Clayton const UUID *uuid_ptr, FileSpec &local_file) 264e996fd30SGreg Clayton { 26528041352SGreg Clayton if (IsRemote()) 26628041352SGreg Clayton { 26728041352SGreg Clayton if (m_remote_platform_sp) 26828041352SGreg Clayton return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file); 26928041352SGreg Clayton } 27028041352SGreg Clayton 271e996fd30SGreg Clayton // Default to the local case 272e996fd30SGreg Clayton local_file = platform_file; 273e996fd30SGreg Clayton return Error(); 274e996fd30SGreg Clayton } 275e996fd30SGreg Clayton 276e996fd30SGreg Clayton 277e996fd30SGreg Clayton //------------------------------------------------------------------ 278e996fd30SGreg Clayton /// Default Constructor 279e996fd30SGreg Clayton //------------------------------------------------------------------ 28028041352SGreg Clayton PlatformLinux::PlatformLinux (bool is_host) : 28128041352SGreg Clayton Platform(is_host), // This is the local host platform 28228041352SGreg Clayton m_remote_platform_sp () 283e996fd30SGreg Clayton { 284e996fd30SGreg Clayton } 285e996fd30SGreg Clayton 286e996fd30SGreg Clayton //------------------------------------------------------------------ 287e996fd30SGreg Clayton /// Destructor. 288e996fd30SGreg Clayton /// 289e996fd30SGreg Clayton /// The destructor is virtual since this class is designed to be 290e996fd30SGreg Clayton /// inherited from by the plug-in instance. 291e996fd30SGreg Clayton //------------------------------------------------------------------ 292e996fd30SGreg Clayton PlatformLinux::~PlatformLinux() 293e996fd30SGreg Clayton { 294e996fd30SGreg Clayton } 295e996fd30SGreg Clayton 296e996fd30SGreg Clayton bool 29713e8e1c3SJohnny Chen PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) 298e996fd30SGreg Clayton { 29928041352SGreg Clayton bool success = false; 30028041352SGreg Clayton if (IsHost()) 30128041352SGreg Clayton { 30228041352SGreg Clayton success = Platform::GetProcessInfo (pid, process_info); 30328041352SGreg Clayton } 30428041352SGreg Clayton else 30528041352SGreg Clayton { 30628041352SGreg Clayton if (m_remote_platform_sp) 30728041352SGreg Clayton success = m_remote_platform_sp->GetProcessInfo (pid, process_info); 30828041352SGreg Clayton } 30928041352SGreg Clayton return success; 310e996fd30SGreg Clayton } 311e996fd30SGreg Clayton 312e996fd30SGreg Clayton bool 313e996fd30SGreg Clayton PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) 314e996fd30SGreg Clayton { 315e996fd30SGreg Clayton if (idx == 0) 316e996fd30SGreg Clayton { 317e996fd30SGreg Clayton arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture); 318e996fd30SGreg Clayton return arch.IsValid(); 319e996fd30SGreg Clayton } 320542e4075SGreg Clayton else if (idx == 1) 321542e4075SGreg Clayton { 322542e4075SGreg Clayton // If the default host architecture is 64-bit, look for a 32-bit variant 323542e4075SGreg Clayton ArchSpec hostArch 324542e4075SGreg Clayton = Host::GetArchitecture(Host::eSystemDefaultArchitecture); 325542e4075SGreg Clayton if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) 326542e4075SGreg Clayton { 327542e4075SGreg Clayton arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); 328542e4075SGreg Clayton return arch.IsValid(); 329542e4075SGreg Clayton } 330542e4075SGreg Clayton } 331e996fd30SGreg Clayton return false; 332e996fd30SGreg Clayton } 333ecc11474SStephen Wilson 334ecc11474SStephen Wilson void 335ecc11474SStephen Wilson PlatformLinux::GetStatus (Stream &strm) 336ecc11474SStephen Wilson { 337ecc11474SStephen Wilson struct utsname un; 338ecc11474SStephen Wilson 339ecc11474SStephen Wilson if (uname(&un)) { 340ecc11474SStephen Wilson strm << "Linux"; 341ecc11474SStephen Wilson return; 342ecc11474SStephen Wilson } 343ecc11474SStephen Wilson 344ecc11474SStephen Wilson strm << un.sysname << ' ' << un.release << ' ' << un.version << '\n'; 345ecc11474SStephen Wilson } 346ecc11474SStephen Wilson 347ecc11474SStephen Wilson size_t 348ecc11474SStephen Wilson PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, 349ecc11474SStephen Wilson BreakpointSite *bp_site) 350ecc11474SStephen Wilson { 351ecc11474SStephen Wilson ArchSpec arch = target.GetArchitecture(); 35228041352SGreg Clayton const uint8_t *trap_opcode = NULL; 35328041352SGreg Clayton size_t trap_opcode_size = 0; 354ecc11474SStephen Wilson 355ecc11474SStephen Wilson switch (arch.GetCore()) 356ecc11474SStephen Wilson { 357ecc11474SStephen Wilson default: 358ecc11474SStephen Wilson assert(false && "CPU type not supported!"); 359ecc11474SStephen Wilson break; 360ecc11474SStephen Wilson 361ecc11474SStephen Wilson case ArchSpec::eCore_x86_32_i386: 362ecc11474SStephen Wilson case ArchSpec::eCore_x86_64_x86_64: 36328041352SGreg Clayton { 36428041352SGreg Clayton static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; 36528041352SGreg Clayton trap_opcode = g_i386_breakpoint_opcode; 36628041352SGreg Clayton trap_opcode_size = sizeof(g_i386_breakpoint_opcode); 36728041352SGreg Clayton } 368ecc11474SStephen Wilson break; 369ecc11474SStephen Wilson } 370ecc11474SStephen Wilson 37128041352SGreg Clayton if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) 37228041352SGreg Clayton return trap_opcode_size; 37328041352SGreg Clayton return 0; 37428041352SGreg Clayton } 37528041352SGreg Clayton 37628041352SGreg Clayton Error 37728041352SGreg Clayton PlatformLinux::LaunchProcess (ProcessLaunchInfo &launch_info) 37828041352SGreg Clayton { 37928041352SGreg Clayton Error error; 38028041352SGreg Clayton 38128041352SGreg Clayton if (IsHost()) 38228041352SGreg Clayton { 38328041352SGreg Clayton if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) 38428041352SGreg Clayton { 38528041352SGreg Clayton const bool is_localhost = true; 386d1cf11a7SGreg Clayton const bool will_debug = launch_info.GetFlags().Test(eLaunchFlagDebug); 387d1cf11a7SGreg Clayton const bool first_arg_is_full_shell_command = false; 388d1cf11a7SGreg Clayton if (!launch_info.ConvertArgumentsForLaunchingInShell (error, 389d1cf11a7SGreg Clayton is_localhost, 390d1cf11a7SGreg Clayton will_debug, 391d1cf11a7SGreg Clayton first_arg_is_full_shell_command)) 39228041352SGreg Clayton return error; 39328041352SGreg Clayton } 39428041352SGreg Clayton error = Platform::LaunchProcess (launch_info); 39528041352SGreg Clayton } 39628041352SGreg Clayton else 39728041352SGreg Clayton { 39828041352SGreg Clayton error.SetErrorString ("the platform is not currently connected"); 39928041352SGreg Clayton } 40028041352SGreg Clayton return error; 401ecc11474SStephen Wilson } 40213e8e1c3SJohnny Chen 40313e8e1c3SJohnny Chen lldb::ProcessSP 404fb2b629dSPeter Collingbourne PlatformLinux::Attach(ProcessAttachInfo &attach_info, 40513e8e1c3SJohnny Chen Debugger &debugger, 40613e8e1c3SJohnny Chen Target *target, 40713e8e1c3SJohnny Chen Listener &listener, 40813e8e1c3SJohnny Chen Error &error) 40913e8e1c3SJohnny Chen { 41028041352SGreg Clayton lldb::ProcessSP process_sp; 41128041352SGreg Clayton if (IsHost()) 41228041352SGreg Clayton { 41328041352SGreg Clayton if (target == NULL) 41428041352SGreg Clayton { 41528041352SGreg Clayton TargetSP new_target_sp; 41628041352SGreg Clayton ArchSpec emptyArchSpec; 41728041352SGreg Clayton 41828041352SGreg Clayton error = debugger.GetTargetList().CreateTarget (debugger, 419a0ca6601SGreg Clayton NULL, 42028041352SGreg Clayton emptyArchSpec, 42128041352SGreg Clayton false, 42228041352SGreg Clayton m_remote_platform_sp, 42328041352SGreg Clayton new_target_sp); 42428041352SGreg Clayton target = new_target_sp.get(); 42528041352SGreg Clayton } 42628041352SGreg Clayton else 42728041352SGreg Clayton error.Clear(); 42828041352SGreg Clayton 42928041352SGreg Clayton if (target && error.Success()) 43028041352SGreg Clayton { 43128041352SGreg Clayton debugger.GetTargetList().SetSelectedTarget(target); 43228041352SGreg Clayton 4330c90ef47SGreg Clayton process_sp = target->CreateProcess (listener, 4340c90ef47SGreg Clayton attach_info.GetProcessPluginName(), 4350c90ef47SGreg Clayton NULL); 43628041352SGreg Clayton 43728041352SGreg Clayton if (process_sp) 43828041352SGreg Clayton error = process_sp->Attach (attach_info); 43928041352SGreg Clayton } 44028041352SGreg Clayton } 44128041352SGreg Clayton else 44228041352SGreg Clayton { 44328041352SGreg Clayton if (m_remote_platform_sp) 44428041352SGreg Clayton process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); 44528041352SGreg Clayton else 44628041352SGreg Clayton error.SetErrorString ("the platform is not currently connected"); 44728041352SGreg Clayton } 44828041352SGreg Clayton return process_sp; 44913e8e1c3SJohnny Chen } 450